diff --git a/components/esp_common/include/esp_private/system_internal.h b/components/esp_common/include/esp_private/system_internal.h index 4f5c90e817..12d7c2db88 100644 --- a/components/esp_common/include/esp_private/system_internal.h +++ b/components/esp_common/include/esp_private/system_internal.h @@ -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); diff --git a/components/esp_system/system_time.c b/components/esp_system/system_time.c index 8fae106ce8..9c1f76a855 100644 --- a/components/esp_system/system_time.c +++ b/components/esp_system/system_time.c @@ -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(); } \ No newline at end of file diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 4e4c570579..975bc6c3d9 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -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 \ No newline at end of file diff --git a/components/newlib/time.c b/components/newlib/time.c index 0e998136b3..221b2c377c 100644 --- a/components/newlib/time.c +++ b/components/newlib/time.c @@ -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