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:
KonstantinKondrashov
2022-04-12 01:50:08 +08:00
parent 466e8702b8
commit 1e0eef52d3
4 changed files with 27 additions and 8 deletions

View File

@@ -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);