newlib: Fix clock_getres() improves accuracy

Returns not rounded value of resolution for WITH_RTC and !WITH_FRC
This commit is contained in:
KonstantinKondrashov
2020-10-07 17:39:11 +08:00
parent 80f993bf31
commit 7ae7adf16a
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

@@ -539,6 +539,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