MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / getWakeupReason

Method getWakeupReason

lib/hal/HalGPIO.cpp:289–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289HalGPIO::WakeupReason HalGPIO::getWakeupReason() const {
290 const auto wakeupCause = esp_sleep_get_wakeup_cause();
291 const auto resetReason = esp_reset_reason();
292
293 const bool usbConnected = isUsbConnected();
294
295 if ((wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED && resetReason == ESP_RST_POWERON && !usbConnected) ||
296 (wakeupCause == ESP_SLEEP_WAKEUP_GPIO && resetReason == ESP_RST_DEEPSLEEP && usbConnected)) {
297 return WakeupReason::PowerButton;
298 }
299 if (wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED && resetReason == ESP_RST_UNKNOWN && usbConnected) {
300 return WakeupReason::AfterFlash;
301 }
302 if (wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED && resetReason == ESP_RST_POWERON && usbConnected) {
303 return WakeupReason::AfterUSBPower;
304 }
305 return WakeupReason::Other;
306}

Callers 2

beginMethod · 0.80
setupFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected