From 5da359c2534a70f1d9ab8dddf128631b163f6865 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 18 Jun 2020 14:01:25 +0200 Subject: [PATCH] sleep: enable sleep reject when entering light sleep --- components/esp32/sleep_modes.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/esp32/sleep_modes.c b/components/esp32/sleep_modes.c index 08ac0a41c8..5d69984e7f 100644 --- a/components/esp32/sleep_modes.c +++ b/components/esp32/sleep_modes.c @@ -202,6 +202,14 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_WAKEUP_FORCE_EN); } + uint32_t reject_triggers = 0; + if ((pd_flags & RTC_SLEEP_PD_DIG) == 0 && (s_config.wakeup_triggers & RTC_GPIO_TRIG_EN)) { + /* Light sleep, enable sleep reject for faster return from this function, + * in case the wakeup is already triggerred. + */ + reject_triggers = RTC_CNTL_LIGHT_SLP_REJECT_EN_M | RTC_CNTL_GPIO_REJECT_EN_M; + } + // Enter sleep rtc_sleep_config_t config = RTC_SLEEP_CONFIG_DEFAULT(pd_flags); rtc_sleep_init(config); @@ -211,7 +219,7 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) s_config.sleep_duration > 0) { timer_wakeup_prepare(); } - uint32_t result = rtc_sleep_start(s_config.wakeup_triggers, 0); + uint32_t result = rtc_sleep_start(s_config.wakeup_triggers, reject_triggers); // Restore CPU frequency rtc_clk_cpu_freq_set_config(&cpu_freq_config);