From 3639c2322b1e5464968478cb0a16608eead28eab Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Wed, 24 Mar 2021 19:58:12 +0800 Subject: [PATCH] ulp: clear rtc int at initialization Closes https://github.com/espressif/esp-idf/issues/6654 --- components/bootloader_support/src/bootloader_clock_init.c | 3 +++ components/esp_hw_support/port/esp32/rtc_init.c | 3 +++ components/esp_hw_support/port/esp32c3/rtc_init.c | 3 +++ components/esp_hw_support/port/esp32s2/rtc_init.c | 3 +++ components/esp_hw_support/port/esp32s3/rtc_init.c | 3 +++ components/esp_system/port/brownout.c | 1 + 6 files changed, 16 insertions(+) diff --git a/components/bootloader_support/src/bootloader_clock_init.c b/components/bootloader_support/src/bootloader_clock_init.c index db1a736d12..dee8bf201b 100644 --- a/components/bootloader_support/src/bootloader_clock_init.c +++ b/components/bootloader_support/src/bootloader_clock_init.c @@ -80,4 +80,7 @@ __attribute__((weak)) void bootloader_clock_configure(void) rtc_clk_32k_bootstrap(CONFIG_ESP_SYSTEM_RTC_EXT_XTAL_BOOTSTRAP_CYCLES); } #endif // CONFIG_ESP_SYSTEM_RTC_EXT_XTAL + + REG_WRITE(RTC_CNTL_INT_ENA_REG, 0); + REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX); } diff --git a/components/esp_hw_support/port/esp32/rtc_init.c b/components/esp_hw_support/port/esp32/rtc_init.c index 9b2911d42d..f86811a99f 100644 --- a/components/esp_hw_support/port/esp32/rtc_init.c +++ b/components/esp_hw_support/port/esp32/rtc_init.c @@ -96,6 +96,9 @@ void rtc_init(rtc_config_t cfg) CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD); CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_NOISO); } + + REG_WRITE(RTC_CNTL_INT_ENA_REG, 0); + REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX); } rtc_vddsdio_config_t rtc_vddsdio_get_config(void) diff --git a/components/esp_hw_support/port/esp32c3/rtc_init.c b/components/esp_hw_support/port/esp32c3/rtc_init.c index cfefb9ea79..fa4125ab7b 100644 --- a/components/esp_hw_support/port/esp32c3/rtc_init.c +++ b/components/esp_hw_support/port/esp32c3/rtc_init.c @@ -148,6 +148,9 @@ void rtc_init(rtc_config_t cfg) calibrate_ocode(); } } + + REG_WRITE(RTC_CNTL_INT_ENA_REG, 0); + REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX); } rtc_vddsdio_config_t rtc_vddsdio_get_config(void) diff --git a/components/esp_hw_support/port/esp32s2/rtc_init.c b/components/esp_hw_support/port/esp32s2/rtc_init.c index a71251eb61..d54a51ba16 100644 --- a/components/esp_hw_support/port/esp32s2/rtc_init.c +++ b/components/esp_hw_support/port/esp32s2/rtc_init.c @@ -160,6 +160,9 @@ void rtc_init(rtc_config_t cfg) calibrate_ocode(); } } + + REG_WRITE(RTC_CNTL_INT_ENA_REG, 0); + REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX); } rtc_vddsdio_config_t rtc_vddsdio_get_config(void) diff --git a/components/esp_hw_support/port/esp32s3/rtc_init.c b/components/esp_hw_support/port/esp32s3/rtc_init.c index ff8f0e7e88..72a9b67e9c 100644 --- a/components/esp_hw_support/port/esp32s3/rtc_init.c +++ b/components/esp_hw_support/port/esp32s3/rtc_init.c @@ -196,6 +196,9 @@ void rtc_init(rtc_config_t cfg) } rtc_clk_cpu_freq_set_config(&old_config); } + + REG_WRITE(RTC_CNTL_INT_ENA_REG, 0); + REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX); } rtc_vddsdio_config_t rtc_vddsdio_get_config(void) diff --git a/components/esp_system/port/brownout.c b/components/esp_system/port/brownout.c index 91eea5eecc..f65d31de5e 100644 --- a/components/esp_system/port/brownout.c +++ b/components/esp_system/port/brownout.c @@ -79,6 +79,7 @@ void esp_brownout_init(void) brownout_hal_config(&cfg); + #ifndef SOC_BROWNOUT_RESET_SUPPORTED rtc_isr_register(rtc_brownout_isr_handler, NULL, RTC_CNTL_BROWN_OUT_INT_ENA_M);