From 20e41d62650f0644b0d2af6b0f3b2f5fef23f72d Mon Sep 17 00:00:00 2001 From: Chen Yi Qun Date: Mon, 17 May 2021 12:02:32 +0800 Subject: [PATCH] fix esp32s2 fall into sleep forever when deep-sleep time is set to 0(backport v4.2) --- components/esp32/include/esp_sleep.h | 2 ++ components/esp32/sleep_modes.c | 3 +-- components/esp32s2/include/esp_sleep.h | 2 ++ components/esp32s2/sleep_modes.c | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp32/include/esp_sleep.h b/components/esp32/include/esp_sleep.h index a1d912b5e2..ead14f186e 100644 --- a/components/esp32/include/esp_sleep.h +++ b/components/esp32/include/esp_sleep.h @@ -286,6 +286,8 @@ esp_err_t esp_light_sleep_start(void); * * This function does not return. * + * @note The device will wake up immediately if the deep-sleep time is set to 0 + * * @param time_in_us deep-sleep time, unit: microsecond */ void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); diff --git a/components/esp32/sleep_modes.c b/components/esp32/sleep_modes.c index efa23660d6..ea2152c00d 100644 --- a/components/esp32/sleep_modes.c +++ b/components/esp32/sleep_modes.c @@ -198,8 +198,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) rtc_sleep_init(config); // Configure timer wakeup - if ((s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) && - s_config.sleep_duration > 0) { + if (s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) { timer_wakeup_prepare(); } diff --git a/components/esp32s2/include/esp_sleep.h b/components/esp32s2/include/esp_sleep.h index 58d3f64209..ad87004fdf 100644 --- a/components/esp32s2/include/esp_sleep.h +++ b/components/esp32s2/include/esp_sleep.h @@ -297,6 +297,8 @@ esp_err_t esp_light_sleep_start(void); * * This function does not return. * + * @note The device will wake up immediately if the deep-sleep time is set to 0 + * * @param time_in_us deep-sleep time, unit: microsecond */ void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); diff --git a/components/esp32s2/sleep_modes.c b/components/esp32s2/sleep_modes.c index b32b01dffb..cbd9a0f3a6 100644 --- a/components/esp32s2/sleep_modes.c +++ b/components/esp32s2/sleep_modes.c @@ -223,8 +223,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) rtc_sleep_init(config); // Configure timer wakeup - if ((s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) && - s_config.sleep_duration > 0) { + if (s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) { timer_wakeup_prepare(); }