How to enable sleep timer in wake stub?
Posted: Tue Oct 17, 2017 5:08 am
I have a simple application that must follow the following logic:
1. Go to deep sleep and wake on GPIO button press;
2. When GPIO button is pressed, a wake stub launches, checks if this is the first time the button was pressed, and if it is, immediately goes back to sleep (instead of waking the main processor). However, before going back to sleep, it launches an RTC timer such that EITHER the GPIO button being pressed a second time OR the timer expiring cause a wakeup.
How can I do this?
I know how to put the system in deep sleep with wake-up triggered by a GPIO button press using either of these:
I know how to put the system in deep sleep with wake-up triggered by a timer using this:
But how do I start a timer INSIDE THE WAKE STUB instead of launching the timer in the main program?
I have seen various posts asking variants of this question but have not yet found an answer.
1. Go to deep sleep and wake on GPIO button press;
2. When GPIO button is pressed, a wake stub launches, checks if this is the first time the button was pressed, and if it is, immediately goes back to sleep (instead of waking the main processor). However, before going back to sleep, it launches an RTC timer such that EITHER the GPIO button being pressed a second time OR the timer expiring cause a wakeup.
How can I do this?
I know how to put the system in deep sleep with wake-up triggered by a GPIO button press using either of these:
Code: Select all
esp_sleep_enable_ext0_wakeup(WAKEUP_PIN, 0);
Code: Select all
const int ext_wakeup_pin_1 = 33;
const uint64_t mask = 1ULL << ext_wakeup_pin_1;
esp_sleep_enable_ext1_wakeup(mask, ESP_EXT1_WAKEUP_ALL_LOW);
Code: Select all
const int deep_sleep_sec = 10;
esp_sleep_enable_timer_wakeup(deep_sleep_sec*1000000);
I have seen various posts asking variants of this question but have not yet found an answer.