mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 06:27:29 +00:00
esp_hw_support: Fix time spent in light sleep when RTC is used for gettimeofday
The esp_timer was not advanced correctly.
This commit is contained in:
@@ -61,14 +61,16 @@ void app_main(void)
|
||||
/* Timekeeping continues in light sleep, and timers are scheduled
|
||||
* correctly after light sleep.
|
||||
*/
|
||||
ESP_LOGI(TAG, "Entering light sleep for 0.5s, time since boot: %lld us",
|
||||
esp_timer_get_time());
|
||||
int64_t t1 = esp_timer_get_time();
|
||||
ESP_LOGI(TAG, "Entering light sleep for 0.5s, time since boot: %lld us", t1);
|
||||
|
||||
ESP_ERROR_CHECK(esp_sleep_enable_timer_wakeup(500000));
|
||||
esp_light_sleep_start();
|
||||
|
||||
ESP_LOGI(TAG, "Woke up from light sleep, time since boot: %lld us",
|
||||
esp_timer_get_time());
|
||||
int64_t t2 = esp_timer_get_time();
|
||||
ESP_LOGI(TAG, "Woke up from light sleep, time since boot: %lld us", t2);
|
||||
|
||||
assert(abs((t2 - t1) - 500000) < 1000);
|
||||
|
||||
/* Let the timer run for a little bit more */
|
||||
usleep(2000000);
|
||||
|
Reference in New Issue
Block a user