diff --git a/components/esp_system/README.md b/components/esp_system/README.md index b54343b21b..f01e59d828 100644 --- a/components/esp_system/README.md +++ b/components/esp_system/README.md @@ -26,4 +26,10 @@ If persistence is enabled, RTC time is also used in conjuction with system time. 4. RTC time (`esp_rtc_get_time_us`) -Time read from RTC timer. \ No newline at end of file +Time read from RTC timer. + +### Brownout + +on some boards, we name BOD1 as ana_bod, to unify the usage, using BOD1 in following passage. + +BOD1 will be a little faster then BOD0, but BOD0 can be widely used(can reset rf, flash, or using interrupt, etc.) So, in IDF code, we use BOD1 in bootloader and BOD0 in the app. diff --git a/components/hal/brownout_hal.c b/components/hal/brownout_hal.c index 8d0c13c3c5..c46dd2e091 100644 --- a/components/hal/brownout_hal.c +++ b/components/hal/brownout_hal.c @@ -10,6 +10,8 @@ void brownout_hal_config(const brownout_hal_config_t *cfg) { + // If brownout software control is enabled, hw ana reset should be disabled, because it always has the highest priority. + brownout_ll_ana_reset_enable(false); brownout_ll_set_intr_wait_cycles(2); brownout_ll_enable_flash_power_down(cfg->flash_power_down); brownout_ll_enable_rf_power_down(cfg->rf_power_down); diff --git a/components/hal/esp32/include/hal/brownout_ll.h b/components/hal/esp32/include/hal/brownout_ll.h index cae801d8b5..d18fcfd245 100644 --- a/components/hal/esp32/include/hal/brownout_ll.h +++ b/components/hal/esp32/include/hal/brownout_ll.h @@ -93,6 +93,16 @@ static inline void brownout_ll_intr_enable(bool enable) RTCCNTL.int_ena.rtc_brown_out = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + // Not supported on ESP32 +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32c2/include/hal/brownout_ll.h b/components/hal/esp32c2/include/hal/brownout_ll.h index 8a384f8798..f44f5228c7 100644 --- a/components/hal/esp32c2/include/hal/brownout_ll.h +++ b/components/hal/esp32c2/include/hal/brownout_ll.h @@ -96,6 +96,16 @@ static inline void brownout_ll_intr_enable(bool enable) RTCCNTL.int_ena.rtc_brown_out = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + RTCCNTL.brown_out.ana_rst_en = enable; +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32c3/include/hal/brownout_ll.h b/components/hal/esp32c3/include/hal/brownout_ll.h index 203544e3eb..d415ebed53 100644 --- a/components/hal/esp32c3/include/hal/brownout_ll.h +++ b/components/hal/esp32c3/include/hal/brownout_ll.h @@ -96,6 +96,16 @@ static inline void brownout_ll_intr_enable(bool enable) RTCCNTL.int_ena.rtc_brown_out = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + RTCCNTL.brown_out.ana_rst_en = enable; +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32c6/include/hal/brownout_ll.h b/components/hal/esp32c6/include/hal/brownout_ll.h index 197d2e2771..e0614583a4 100644 --- a/components/hal/esp32c6/include/hal/brownout_ll.h +++ b/components/hal/esp32c6/include/hal/brownout_ll.h @@ -96,6 +96,16 @@ static inline void brownout_ll_intr_enable(bool enable) LP_ANA_PERI.int_ena.bod_mode0 = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + LP_ANA_PERI.bod_mode1_cntl.bod_mode1_reset_ena = enable; +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32h2/include/hal/brownout_ll.h b/components/hal/esp32h2/include/hal/brownout_ll.h index 9d0ca3b00b..7885decbfd 100644 --- a/components/hal/esp32h2/include/hal/brownout_ll.h +++ b/components/hal/esp32h2/include/hal/brownout_ll.h @@ -96,6 +96,16 @@ static inline void brownout_ll_intr_enable(bool enable) LP_ANA_PERI.int_ena.bod_mode0_int_ena = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + LP_ANA_PERI.bod_mode1_cntl.bod_mode1_reset_ena = enable; +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32s2/include/hal/brownout_ll.h b/components/hal/esp32s2/include/hal/brownout_ll.h index 0a683e9cb3..6a8b7cfe57 100644 --- a/components/hal/esp32s2/include/hal/brownout_ll.h +++ b/components/hal/esp32s2/include/hal/brownout_ll.h @@ -97,6 +97,16 @@ static inline void brownout_ll_intr_enable(bool enable) RTCCNTL.int_ena.rtc_brown_out = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + // Not supported on ESP32S2 +} + /** * @brief Clear interrupt bits. */ diff --git a/components/hal/esp32s3/include/hal/brownout_ll.h b/components/hal/esp32s3/include/hal/brownout_ll.h index 9e6f5458c9..37a2020c12 100644 --- a/components/hal/esp32s3/include/hal/brownout_ll.h +++ b/components/hal/esp32s3/include/hal/brownout_ll.h @@ -96,6 +96,16 @@ static inline void brownout_ll_intr_enable(bool enable) RTCCNTL.int_ena.rtc_brown_out = enable; } +/** + * @brief Enable brownout hardware reset + * + * @param enable + */ +static inline void brownout_ll_ana_reset_enable(bool enable) +{ + RTCCNTL.brown_out.ana_rst_en = enable; +} + /** * @brief Clear interrupt bits. */