esp_timer: Timers with skip_unhandled_events option won't wake up system from light sleep

This commit is contained in:
KonstantinKondrashov
2021-04-19 20:48:16 +08:00
committed by bot
parent cdad1eaa9c
commit f9ad16bb66
7 changed files with 72 additions and 1 deletions

View File

@@ -598,3 +598,26 @@ int64_t IRAM_ATTR esp_timer_get_next_alarm(void)
}
return next_alarm;
}
int64_t IRAM_ATTR esp_timer_get_next_alarm_for_wake_up(void)
{
int64_t next_alarm = INT64_MAX;
for (esp_timer_dispatch_t dispatch_method = ESP_TIMER_TASK; dispatch_method < ESP_TIMER_MAX; ++dispatch_method) {
timer_list_lock(dispatch_method);
esp_timer_handle_t it;
LIST_FOREACH(it, &s_timers[dispatch_method], list_entry) {
if (it == NULL) {
break;
}
// timers with the SKIP_UNHANDLED_EVENTS flag do not want to wake up CPU from a sleep mode.
if ((it->flags & FL_SKIP_UNHANDLED_EVENTS) == 0) {
if (next_alarm > it->alarm) {
next_alarm = it->alarm;
}
break;
}
}
timer_list_unlock(dispatch_method);
}
return next_alarm;
}