Merge branch 'bugfix/clock_getres_accuracy_resolution' into 'master'

newlib: Fix clock_getres() improves accuracy

See merge request espressif/esp-idf!10743
This commit is contained in:
Angus Gratton 2020-10-22 16:50:29 +08:00
commit 4df4bd9558
4 changed files with 4 additions and 4 deletions

View File

@ -72,7 +72,7 @@ int64_t esp_system_get_time(void);
/**
* @brief Get the resolution of the time returned by `esp_system_get_time`.
*
* @returns the resolution in microseconds
* @returns the resolution in nanoseconds
*/
uint32_t esp_system_get_time_resolution(void);

View File

@ -42,5 +42,5 @@ int64_t IRAM_ATTR __attribute__((weak)) esp_system_get_time(void)
uint32_t IRAM_ATTR __attribute__((weak)) esp_system_get_time_resolution(void)
{
return 1000000L / rtc_clk_slow_freq_get_hz();
return 1000000000L / rtc_clk_slow_freq_get_hz();
}

View File

@ -534,6 +534,6 @@ int64_t IRAM_ATTR esp_system_get_time(void)
uint32_t IRAM_ATTR esp_system_get_time_resolution(void)
{
return 1;
return 1000;
}
#endif

View File

@ -287,7 +287,7 @@ int clock_getres (clockid_t clock_id, struct timespec *res)
}
res->tv_sec = 0;
res->tv_nsec = esp_system_get_time_resolution() * 1000;
res->tv_nsec = esp_system_get_time_resolution();
return 0;
#else