From b463748bfb999024912c8be50772fdf5386a6ffc Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Fri, 22 Mar 2024 18:46:23 +0200 Subject: [PATCH] fix(esp_timer): Force to go light sleep ignoring ESP_ERR_SLEEP_REJECT --- .../test_apps/main/test_esp_timer_light_sleep.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c b/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c index 45214f8749..45a92f0b51 100644 --- a/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c +++ b/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c @@ -36,17 +36,19 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee int period_cb_ms = 10; int interval_ms = 50; - TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000)); - TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000)); printf("Run light sleep\n"); printf("count_calls should be around = %d\n", interval_ms / period_cb_ms); + TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000)); + TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000)); for (int i = 0; i < 3; i++) { - count_calls = 0; - TEST_ESP_OK(esp_light_sleep_start()); + do { + count_calls = 0; + } while (esp_light_sleep_start() != ESP_OK); esp_rom_delay_us(interval_ms * 1000); - printf("count_calls = %d\n", count_calls); - TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, count_calls); + int saved_count_calls = count_calls; + printf("count_calls = %d\n", saved_count_calls); TEST_ESP_OK(esp_timer_dump(stdout)); + TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, saved_count_calls); } TEST_ESP_OK(esp_timer_stop(periodic_timer)); // times_skipped is about 12 (4 from each sleep time). @@ -54,4 +56,4 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee TEST_ESP_OK(esp_timer_delete(periodic_timer)); } -#endif // SOC_SLEEP_SUPPORTED +#endif // SOC_LIGHT_SLEEP_SUPPORTED