From 57975000fe530a3b69b6a553858559493b51dbec Mon Sep 17 00:00:00 2001 From: jingli Date: Mon, 23 May 2022 01:00:19 +0800 Subject: [PATCH] esp_hw_support/sleep: fix cannot lightsleep again after a wakeup from ULP Since ulp wakeup signal are connected to ulp int raw(except esp32), we need to clear ulp int raw before sleep when ulp wakeup enabled. Otherwise, if the ulp int raw is already set, chip will not sleep properly. Closes https://github.com/espressif/esp-idf/issues/6229 --- components/esp32s2/sleep_modes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp32s2/sleep_modes.c b/components/esp32s2/sleep_modes.c index 419ed36665..5e18eb6388 100644 --- a/components/esp32s2/sleep_modes.c +++ b/components/esp32s2/sleep_modes.c @@ -198,7 +198,9 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) } // Enable ULP wakeup if (s_config.wakeup_triggers & RTC_ULP_TRIG_EN) { - // no-op for esp32s2 + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_ULP_CP_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_TRAP_INT_CLR); } extern void regi2c_analog_cali_reg_read(void);