]> granicus.if.org Git - esp-idf/commitdiff
soc/rtc: restore dbg attenuation when waking from sleep
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 4 Apr 2018 07:05:16 +0000 (15:05 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 26 Apr 2018 10:52:46 +0000 (18:52 +0800)
This fixes inability to enter deep sleep after waking up from light sleep

components/soc/esp32/include/soc/rtc_cntl_reg.h
components/soc/esp32/rtc_init.c
components/soc/esp32/rtc_sleep.c

index d54a7dde7cf44c45ebd6a0b333086bf76f3c6efe..090b3f7072ce059996fd80230dd65aca1bfed28f 100644 (file)
 #define RTC_CNTL_DBG_ATTEN_M  ((RTC_CNTL_DBG_ATTEN_V)<<(RTC_CNTL_DBG_ATTEN_S))
 #define RTC_CNTL_DBG_ATTEN_V  0x3
 #define RTC_CNTL_DBG_ATTEN_S  24
-
+#define RTC_CNTL_DBG_ATTEN_DEFAULT  3
 #define RTC_CNTL_REG          (DR_REG_RTCCNTL_BASE + 0x7c)
 /* RTC_CNTL_FORCE_PU : R/W ;bitpos:[31] ;default: 1'd1 ; */
 /*description: RTC_REG force power up*/
index dfd066908770388706cf7124ade142f6428bae4b..43374d6b0276c52b45e7f9b3a7e8e99f2907f975 100644 (file)
@@ -30,7 +30,7 @@ void rtc_init(rtc_config_t cfg)
     REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_XTL_BUF_WAIT, cfg.xtal_wait);
     REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, cfg.ck8m_wait);
 
-    REG_SET_FIELD(RTC_CNTL_BIAS_CONF_REG, RTC_CNTL_DBG_ATTEN, 0x3);
+    REG_SET_FIELD(RTC_CNTL_BIAS_CONF_REG, RTC_CNTL_DBG_ATTEN, RTC_CNTL_DBG_ATTEN_DEFAULT);
     SET_PERI_REG_MASK(RTC_CNTL_BIAS_CONF_REG,
             RTC_CNTL_DEC_HEARTBEAT_WIDTH | RTC_CNTL_INC_HEARTBEAT_PERIOD);
 
index ae34e273af77bd8fcff247eca8a6ee2eb2d7aef0..b0ffb2ff2bdcceab92e1cd32b6e43b79f89d4c72 100644 (file)
@@ -219,5 +219,8 @@ uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt)
     uint32_t reject = REG_GET_FIELD(RTC_CNTL_INT_RAW_REG, RTC_CNTL_SLP_REJECT_INT_RAW);
     SET_PERI_REG_MASK(RTC_CNTL_INT_CLR_REG,
             RTC_CNTL_SLP_REJECT_INT_CLR | RTC_CNTL_SLP_WAKEUP_INT_CLR);
+
+    /* restore DBG_ATTEN to the default value */
+    REG_SET_FIELD(RTC_CNTL_BIAS_CONF_REG, RTC_CNTL_DBG_ATTEN, RTC_CNTL_DBG_ATTEN_DEFAULT);
     return reject;
 }