fix(esp_timer): Force to go light sleep ignoring ESP_ERR_SLEEP_REJECT

This commit is contained in:
Konstantin Kondrashov 2024-03-22 18:46:23 +02:00
parent 004b037743
commit b463748bfb

View File

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