esp32c3: Adds support BROWNOUT reset

This commit is contained in:
KonstantinKondrashov
2021-01-07 22:44:33 +08:00
parent c65a24063d
commit d81a93ae4c
5 changed files with 32 additions and 19 deletions

View File

@@ -35,6 +35,10 @@
#define BROWNOUT_DET_LVL CONFIG_ESP32_BROWNOUT_DET_LVL
#elif defined(CONFIG_ESP32S2_BROWNOUT_DET_LVL)
#define BROWNOUT_DET_LVL CONFIG_ESP32S2_BROWNOUT_DET_LVL
#elif defined(CONFIG_ESP32S3_BROWNOUT_DET_LVL)
#define BROWNOUT_DET_LVL CONFIG_ESP32S3_BROWNOUT_DET_LVL
#elif defined(CONFIG_ESP32C3_BROWNOUT_DET_LVL)
#define BROWNOUT_DET_LVL CONFIG_ESP32C3_BROWNOUT_DET_LVL
#else
#define BROWNOUT_DET_LVL 0
#endif
@@ -45,7 +49,7 @@
#define BROWNOUT_RESET_EN false
#endif // SOC_BROWNOUT_RESET_SUPPORTED
#ifndef SOC_BROWNOUT_RESET_SUPPORTED
static void rtc_brownout_isr_handler(void *arg)
{
/* Normally RTC ISR clears the interrupt flag after the application-supplied
@@ -61,6 +65,7 @@ static void rtc_brownout_isr_handler(void *arg)
esp_rom_printf("\r\nBrownout detector was triggered\r\n\r\n");
esp_restart_noos();
}
#endif // not SOC_BROWNOUT_RESET_SUPPORTED
void esp_brownout_init(void)
{
@@ -74,7 +79,9 @@ 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);
brownout_hal_intr_enable(true);
#endif // not SOC_BROWNOUT_RESET_SUPPORTED
}