mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-06 08:37:29 +02:00
esp_timer: Timers with skip_unhandled_events option won't wake up system from light sleep
This commit is contained in:
committed by
bot
parent
cdad1eaa9c
commit
f9ad16bb66
@@ -622,7 +622,7 @@ void IRAM_ATTR vApplicationSleep( TickType_t xExpectedIdleTime )
|
||||
int core_id = xPortGetCoreID();
|
||||
if (!should_skip_light_sleep(core_id)) {
|
||||
/* Calculate how much we can sleep */
|
||||
int64_t next_esp_timer_alarm = esp_timer_get_next_alarm();
|
||||
int64_t next_esp_timer_alarm = esp_timer_get_next_alarm_for_wake_up();
|
||||
int64_t now = esp_timer_get_time();
|
||||
int64_t time_until_next_alarm = next_esp_timer_alarm - now;
|
||||
int64_t wakeup_delay_us = portTICK_PERIOD_MS * 1000LL * xExpectedIdleTime;
|
||||
|
||||
@@ -360,6 +360,42 @@ TEST_CASE("esp_timer produces correct delays with light sleep", "[pm]")
|
||||
#undef NUM_INTERVALS
|
||||
}
|
||||
|
||||
static void timer_cb1(void *arg)
|
||||
{
|
||||
++*((int*) arg);
|
||||
}
|
||||
|
||||
TEST_CASE("esp_timer with SKIP_UNHANDLED_EVENTS does not wake up CPU from sleep", "[pm]")
|
||||
{
|
||||
int count_calls = 0;
|
||||
int timer_interval_ms = 50;
|
||||
|
||||
const esp_timer_create_args_t timer_args = {
|
||||
.name = "timer_cb1",
|
||||
.arg = &count_calls,
|
||||
.callback = &timer_cb1,
|
||||
.skip_unhandled_events = true,
|
||||
};
|
||||
esp_timer_handle_t periodic_timer;
|
||||
esp_timer_create(&timer_args, &periodic_timer);
|
||||
TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, timer_interval_ms * 1000));
|
||||
|
||||
light_sleep_enable();
|
||||
|
||||
const unsigned count_delays = 5;
|
||||
unsigned i = count_delays;
|
||||
while (i-- > 0) {
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
}
|
||||
TEST_ASSERT_INT_WITHIN(1, count_delays, count_calls);
|
||||
|
||||
light_sleep_disable();
|
||||
|
||||
TEST_ESP_OK(esp_timer_stop(periodic_timer));
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer));
|
||||
}
|
||||
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user