feat(newlib): Add macro ESP8266_TIME_SYSCALL_USE_FRC1 to enable clock_gettime function

This commit is contained in:
yuanjm
2019-10-15 18:48:12 +08:00
committed by dongheng
parent fafb539b56
commit efe9834313
2 changed files with 25 additions and 0 deletions

View File

@ -321,6 +321,24 @@ config ESP_ERR_TO_NAME_LOOKUP
order to save memory but this comes at the price of sacrificing
distinguishable (meaningful) output string representations.
choice ESP8266_TIME_SYSCALL
prompt "Timers used for gettimeofday function"
default ESP8266_TIME_SYSCALL_USE_FRC1
help
This setting defines which hardware timers are used to
implement 'gettimeofday' and 'time' functions in C library.
- If high-resolution timer is used, gettimeofday will
provide time at microsecond resolution.
Time will not be preserved when going into deep sleep mode.
- If no timers are used, gettimeofday and time functions
return -1 and set errno to ENOSYS.
config ESP8266_TIME_SYSCALL_USE_FRC1
bool "High-resolution timer"
config ESP8266_TIME_SYSCALL_USE_NONE
bool "None"
endchoice
endmenu
menu Wi-Fi

View File

@ -14,6 +14,7 @@
#include <stdint.h>
#include <reent.h>
#include <time.h>
#include <sys/times.h>
#include <sys/time.h>
#include <sys/errno.h>
@ -26,6 +27,12 @@
#include "task.h"
#include "driver/soc.h"
#include "sdkconfig.h"
#ifdef CONFIG_ESP8266_TIME_SYSCALL_USE_FRC1
#define WITH_FRC 1
#endif
static uint64_t s_boot_time;
static inline void set_boot_time(uint64_t time_us)