8static const char *
const TAG =
"deep_sleep.bk72xx";
10#ifdef USE_DEEP_SLEEP_ON_WAKE
12 switch (lt_get_reboot_reason()) {
13 case REBOOT_REASON_SLEEP_GPIO:
15 case REBOOT_REASON_SLEEP_RTC:
17 case REBOOT_REASON_SLEEP_USB:
29 LOG_PIN(
" Wakeup Pin: ", item.wakeup_pin);
45 ESP_LOGV(TAG,
"Waiting for pin to switch state to enter deep sleep...");
59 item.wakeup_level = !item.wakeup_level;
62 ESP_LOGI(TAG,
"Wake-up on P%u %s (%" PRId32
")", item.wakeup_pin->get_pin(), item.wakeup_level ?
"HIGH" :
"LOW",
63 static_cast<int32_t
>(item.wakeup_pin_mode));
67 lt_deep_sleep_config_timer((*this->
sleep_duration_ / 1000) & 0xFFFFFFFF);
70 lt_deep_sleep_config_gpio(1 << item.wakeup_pin->get_pin(), item.wakeup_level);
71 lt_deep_sleep_keep_floating_gpio(1 << item.wakeup_pin->get_pin(),
true);
74 lt_deep_sleep_enter();
void status_set_warning()
bool pin_prevents_sleep_(WakeUpPinItem &pin_item) const
optional< uint64_t > sleep_duration_
FixedVector< WakeUpPinItem > wakeup_pins_
optional< uint32_t > get_run_duration_() const
bool get_real_pin_state_(InternalGPIOPin &pin) const
bool next_enter_deep_sleep_
optional< uint32_t > run_duration_
void dump_config_platform_()
@ WAKEUP_PIN_MODE_KEEP_AWAKE
As long as the wakeup pin is still in the wakeup state, keep awake.
@ WAKEUP_PIN_MODE_INVERT_WAKEUP
Automatically invert the wakeup level.
WakeupCause get_wakeup_cause()
Return why the device woke from deep sleep. Implemented per platform.
WakeupCause
Why the device woke from deep sleep. Passed to on_wake automations.
@ WAKEUP_CAUSE_GPIO
The device was woken by a GPIO pin (wakeup_pin or esp32_ext1_wakeup).
@ WAKEUP_CAUSE_TIMER
The device was woken by the sleep timer.
@ WAKEUP_CAUSE_UNKNOWN
The device woke from deep sleep, but the source could not be identified.
@ WAKEUP_CAUSE_NONE
The device did not wake from deep sleep (for example a cold boot, reset or OTA restart).
WakeupPinMode wakeup_pin_mode
InternalGPIOPin * wakeup_pin