Can I determine which was the GPIO that woke up in "Light Sleep"?
Posted: Wed Apr 07, 2021 12:19 pm
I have the following code (taken from examples) that determines what was the reason why it woke up.
However in case of having several GPIO interrupts I would like to determine which of them was executed.
Is there a saved value for this? Or do I have to do a kind of "trick" of reading the GPIO right after the interrupt? Any better way than that?
Thank you.
Gustavo
Code: Select all
...
esp_light_sleep_start();
printf("WakeUP!\n");
/* Determine wake up reason */
const char* wakeup_reason;
switch (esp_sleep_get_wakeup_cause()) {
case ESP_SLEEP_WAKEUP_TIMER:
wakeup_reason = "timer";
break;
case ESP_SLEEP_WAKEUP_GPIO:
wakeup_reason = "pin";
break;
default:
wakeup_reason = "other";
break;
}
printf("Returned from light sleep, reason: %s\n", wakeup_reason);
...
Is there a saved value for this? Or do I have to do a kind of "trick" of reading the GPIO right after the interrupt? Any better way than that?
Thank you.
Gustavo