Merge branch 'feat/vbat_bringup_test' into 'master'

feat(vbat): Add support to use vbat as rtc battery

See merge request espressif/esp-idf!36189
This commit is contained in:
C.S.M
2025-01-15 18:15:21 +08:00
40 changed files with 1173 additions and 638 deletions

View File

@@ -151,6 +151,10 @@ if(NOT non_os_build)
list(APPEND srcs "power_supply/brownout.c")
endif()
if(CONFIG_ESP_VBAT_INIT_AUTO)
list(APPEND srcs "power_supply/vbat.c")
endif()
else()
if(ESP_TEE_BUILD)
list(APPEND srcs "esp_clk.c" "hw_random.c")

View File

@@ -247,7 +247,7 @@ menu "Hardware Settings"
orsource "./port/$IDF_TARGET/Kconfig.ldo"
orsource "./power_supply/port/$IDF_TARGET/Kconfig.bod"
orsource "./power_supply/port/$IDF_TARGET/Kconfig.power"
# Invisible bringup bypass options for esp_hw_support component
config ESP_BRINGUP_BYPASS_CPU_CLK_SETTING

View File

@@ -91,7 +91,8 @@ void esp_brownout_init(void)
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
rtc_isr_register(rtc_brownout_isr_handler, NULL, RTC_CNTL_BROWN_OUT_INT_ENA_M, RTC_INTR_FLAG_IRAM);
#else
esp_intr_alloc_intrstatus(power_supply_periph_signal.irq, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED, (uint32_t)brownout_ll_intr_get_status_reg(), BROWNOUT_DETECTOR_LL_INTERRUPT_MASK, &rtc_brownout_isr_handler, NULL, NULL);
intr_handle_t bod_intr;
esp_intr_alloc_intrstatus(power_supply_periph_signal.irq, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED, (uint32_t)brownout_ll_intr_get_status_reg(), BROWNOUT_DETECTOR_LL_INTERRUPT_MASK, &rtc_brownout_isr_handler, NULL, &bod_intr);
#endif
brownout_ll_intr_enable(true);

View File

@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the VBAT (RTC Backup Battery) management system.
*
* @return
* - ESP_OK: Initialization was successful.
*/
esp_err_t esp_vbat_init(void);
#ifdef __cplusplus
}
#endif

View File

@@ -1,64 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.43V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.48V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.58V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.62V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.67V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.70V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.77V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.80V +/- 0.05"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
Two occasions need to restart the chip with interrupt so far.
(1). For ESP32 version 1, brown-out reset function doesn't work (see ESP32 errata 3.4).
So that we must restart from interrupt.
(2). For special workflow, the chip needs do more things instead of restarting directly. This part
needs to be done in callback function of interrupt.
endmenu

View File

@@ -0,0 +1,68 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.43V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.48V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.58V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.62V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.67V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.70V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.77V +/- 0.05"
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.80V +/- 0.05"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
Two occasions need to restart the chip with interrupt so far.
(1). For ESP32 version 1, brown-out reset function doesn't work (see ESP32 errata 3.4).
So that we must restart from interrupt.
(2). For special workflow, the chip needs do more things instead of restarting directly. This part
needs to be done in callback function of interrupt.
endmenu
endmenu

View File

@@ -1,55 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,59 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,55 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C3 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,59 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C3 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,55 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA && SOC_BOD_SUPPORTED
default y
help
The ESP32-C5 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,59 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C5 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,55 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C6 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,59 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C6 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,55 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C61 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,59 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-C61 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.51V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.64V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.76V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.92V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "3.10V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.27V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,61 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-H2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.94V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.88V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.83V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.78V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.73V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.62V"
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.57V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,65 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-H2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.94V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.88V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.83V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.78V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.73V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.62V"
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.57V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,61 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-H21 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.94V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.88V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.83V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.78V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.73V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.62V"
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.57V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,65 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-H21 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_0
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.94V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.88V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.83V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.78V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.73V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "2.62V"
config ESP_BROWNOUT_DET_LVL_SEL_0
bool "2.57V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 0 if ESP_BROWNOUT_DET_LVL_SEL_0
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,49 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-P4 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
default ESP_BROWNOUT_DET_LVL_SEL_7
depends on ESP_BROWNOUT_DET
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
Please note that this config is only valid when P4 SOC version is above v1.0. When you are using a
earlier P4 SOC version (v0.x), the brownout value should be fixed around 2.52V and not configurable.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.6V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.52V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.42V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,159 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-P4 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
default ESP_BROWNOUT_DET_LVL_SEL_7
depends on ESP_BROWNOUT_DET
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each chip.
Please note that this config is only valid when P4 SOC version is above v1.0. When you are using a
earlier P4 SOC version (v0.x), the brownout value should be fixed around 2.52V and not configurable.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.6V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.52V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.42V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
menu "RTC Backup Battery"
config ESP_VBAT_INIT_AUTO
bool "Enable VBAT power supply for RTC battery"
default n
depends on SOC_VBAT_SUPPORTED
help
Enable this option to allow the use of a button cell battery to power the RTC (Real-Time Clock) domain.
When this option is enabled, the hardware will configure VBAT as the power supply source for the RTC.
- Ensure a compatible battery (2.5V ~ 3.6V) is connected to the VBAT pin.
- The VBAT battery provides power to retain RTC state and keep low-power peripherals active
during deep sleep.
- When this option is disabled, the RTC battery input (VBAT) must not be left floating.
config ESP_VBAT_USE_RECHARGEABLE_BATTERY
bool "The battery for RTC battery is a rechargeable battery"
default n
depends on ESP_VBAT_INIT_AUTO
help
Select this option if the RTC backup battery used in your design is a rechargeable battery.
When enabled, the system will configure the RTC battery management circuitry to operate
in a mode suitable for charging a rechargeable battery. This includes enabling
charging current regulation via resistor and voltage monitoring to ensure safe and efficient charging.
Use this option carefully to avoid damage to non-rechargeable batteries.
choice ESP_VBAT_DET_LVL_LOW_SEL
prompt "VBAT start charging voltage level"
default ESP_VBAT_DET_LVL_LOW_SEL_6
depends on ESP_VBAT_USE_RECHARGEABLE_BATTERY
help
The brownout detector will start charging when the supply voltage drops below the selected threshold.
This ensures that the power supply is maintained at a stable level.
config ESP_VBAT_DET_LVL_LOW_SEL_7
bool "2.6V"
config ESP_VBAT_DET_LVL_LOW_SEL_6
bool "2.52V"
config ESP_VBAT_DET_LVL_LOW_SEL_5
bool "2.42V"
endchoice
choice ESP_VBAT_DET_LVL_HIGH_SEL
prompt "VBAT stop charging voltage level"
default ESP_VBAT_DET_LVL_HIGH_SEL_7
depends on ESP_VBAT_USE_RECHARGEABLE_BATTERY
help
The brownout detector will stop charging when the supply voltage arrives the selected threshold.
config ESP_VBAT_DET_LVL_HIGH_SEL_7
bool "2.6V"
config ESP_VBAT_DET_LVL_HIGH_SEL_6
bool "2.52V"
config ESP_VBAT_DET_LVL_HIGH_SEL_5
bool "2.42V"
endchoice
choice ESP_VBAT_BROWNOUT_DET_LVL_SEL
prompt "VBAT brownout voltage level"
default ESP_VBAT_BROWNOUT_DET_LVL_SEL_5
depends on ESP_VBAT_INIT_AUTO
help
The brownout detector will git a brownout signal when vbat brownout detected.
config ESP_VBAT_BROWNOUT_DET_LVL_SEL_7
bool "2.6V"
config ESP_VBAT_BROWNOUT_DET_LVL_SEL_6
bool "2.52V"
config ESP_VBAT_BROWNOUT_DET_LVL_SEL_5
bool "2.42V"
endchoice
config ESP_VBAT_DET_LVL_LOW
int
depends on ESP_VBAT_USE_RECHARGEABLE_BATTERY
default 5 if ESP_VBAT_DET_LVL_LOW_SEL_5
default 6 if ESP_VBAT_DET_LVL_LOW_SEL_6
default 7 if ESP_VBAT_DET_LVL_LOW_SEL_7
config ESP_VBAT_DET_LVL_HIGH
int
depends on ESP_VBAT_USE_RECHARGEABLE_BATTERY
default 5 if ESP_VBAT_DET_LVL_HIGH_SEL_5
default 6 if ESP_VBAT_DET_LVL_HIGH_SEL_6
default 7 if ESP_VBAT_DET_LVL_HIGH_SEL_7
config ESP_VBAT_BROWNOUT_DET_LVL
int
default 5 if ESP_VBAT_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_VBAT_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_VBAT_BROWNOUT_DET_LVL_SEL_7
config ESP_VBAT_CHARGER_CIRCUIT_RESISTOR_VAL
int "vbat charger circuit resistor value (ohms), should be multiple of 500"
depends on ESP_VBAT_USE_RECHARGEABLE_BATTERY
range 1000 8500
default 1000
help
The resistor value of charger circuit.
endmenu
endmenu

View File

@@ -1,59 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-S2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP3-S2 chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.44V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.56V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.84V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.98V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.19V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "3.30V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,63 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-S2 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP3-S2 chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.44V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.56V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.84V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.98V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.19V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "3.30V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -1,59 +0,0 @@
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-S3 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP3-S3 chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.44V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.56V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.84V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.98V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.19V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "3.30V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu

View File

@@ -0,0 +1,63 @@
menu "Power Supplier"
menu "Brownout Detector"
config ESP_BROWNOUT_DET
bool "Hardware brownout detect & reset"
depends on !IDF_ENV_FPGA
default y
help
The ESP32-S3 has a built-in brownout detector which can detect if the voltage is lower than
a specific value. If this happens, it will reset the chip in order to prevent unintended
behaviour.
choice ESP_BROWNOUT_DET_LVL_SEL
prompt "Brownout voltage level"
depends on ESP_BROWNOUT_DET
default ESP_BROWNOUT_DET_LVL_SEL_7
help
The brownout detector will reset the chip when the supply voltage is approximately
below this level. Note that there may be some variation of brownout voltage level
between each ESP3-S3 chip.
#The voltage levels here are estimates, more work needs to be done to figure out the exact voltages
#of the brownout threshold levels.
config ESP_BROWNOUT_DET_LVL_SEL_7
bool "2.44V"
config ESP_BROWNOUT_DET_LVL_SEL_6
bool "2.56V"
config ESP_BROWNOUT_DET_LVL_SEL_5
bool "2.67V"
config ESP_BROWNOUT_DET_LVL_SEL_4
bool "2.84V"
config ESP_BROWNOUT_DET_LVL_SEL_3
bool "2.98V"
config ESP_BROWNOUT_DET_LVL_SEL_2
bool "3.19V"
config ESP_BROWNOUT_DET_LVL_SEL_1
bool "3.30V"
endchoice
config ESP_BROWNOUT_DET_LVL
int
default 1 if ESP_BROWNOUT_DET_LVL_SEL_1
default 2 if ESP_BROWNOUT_DET_LVL_SEL_2
default 3 if ESP_BROWNOUT_DET_LVL_SEL_3
default 4 if ESP_BROWNOUT_DET_LVL_SEL_4
default 5 if ESP_BROWNOUT_DET_LVL_SEL_5
default 6 if ESP_BROWNOUT_DET_LVL_SEL_6
default 7 if ESP_BROWNOUT_DET_LVL_SEL_7
config ESP_BROWNOUT_USE_INTR
bool
default n
help
This config allows to trigger an interrupt when brownout detected. Software restart will be done
at the end of the default callback.
This is because for some special workflow, the chip needs do more things when brownout happens
before restart instead of restarting directly. This part needs to be done in callback function
of interrupt.
endmenu
endmenu

View File

@@ -0,0 +1,92 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "esp_attr.h"
#include "esp_intr_alloc.h"
#include "hal/vbat_ll.h"
#include "hal/brownout_ll.h"
#include "hal/vbat_hal.h"
#include "freertos/FreeRTOS.h"
#include "sdkconfig.h"
#include "esp_private/startup_internal.h"
#include "esp_check.h"
#include "soc/power_supply_periph.h"
#define VBAT_BROWNOUT_DET_LVL CONFIG_ESP_VBAT_BROWNOUT_DET_LVL
#if CONFIG_ESP_VBAT_USE_RECHARGEABLE_BATTERY
#define VBAT_CHARGE_DET_LVL_LOW CONFIG_ESP_VBAT_DET_LVL_LOW
#define VBAT_CHARGE_DET_LVL_HIGH CONFIG_ESP_VBAT_DET_LVL_HIGH
#define VBAT_CHARGER_RESISTOR_VALUE CONFIG_ESP_VBAT_CHARGER_CIRCUIT_RESISTOR_VAL
#if (VBAT_CHARGER_RESISTOR_VALUE < 1000 || VBAT_CHARGER_RESISTOR_VALUE > 4500 || VBAT_CHARGER_RESISTOR_VALUE % 500 != 0)
#error "vbat charger resistor (ESP_VBAT_CHARGER_CIRCUIT_RESISTOR_VAL) must be between 1000 and 4500 ohms and must be a multiple of 500."
#endif
#if (VBAT_BROWNOUT_DET_LVL >= VBAT_CHARGE_DET_LVL_LOW)
#error "vbat charger low threshold is equal or lower than vbat brownout threshold, please put vbat brownout threshold lower than vbat charger low threshold"
#endif
#endif
static const char TAG[] = "VBAT";
IRAM_ATTR static void vbat_isr_handler(void *arg)
{
uint32_t int_status;
vbat_ll_get_interrupt_status(&int_status);
vbat_ll_clear_intr_mask(int_status);
if (int_status & VBAT_LL_CHARGER_UNDERVOLTAGE_INTR) {
ESP_DRAM_LOGW(TAG, "RTC battery voltage low, start charging...");
vbat_ll_start_battery_charge(true);
}
if (int_status & VBAT_LL_CHARGER_UPVOLTAGE_INTR) {
ESP_DRAM_LOGW(TAG, "RTC battery voltage reaches high limit , stop charging...");
vbat_ll_start_battery_charge(false);
}
if (int_status & VBAT_LL_BROWNOUT_INTR) {
// TODO: A callback may needed here to inform an under voltage event.
ESP_DRAM_LOGW(TAG, "RTC battery voltage low, please change battery...");
}
}
esp_err_t esp_vbat_init(void)
{
intr_handle_t vbat_intr;
#if CONFIG_ESP_VBAT_USE_RECHARGEABLE_BATTERY
vbat_hal_config_t vbat_cfg = {
.enable_vbat_charger = true,
.charger_resistor_value = VBAT_CHARGER_RESISTOR_VALUE,
.low_threshold = VBAT_CHARGE_DET_LVL_LOW,
.high_threshold = VBAT_CHARGE_DET_LVL_HIGH,
.brownout_threshold = VBAT_BROWNOUT_DET_LVL,
.undervoltage_filter_time = 20,
.upvoltage_filter_time = 10,
.interrupt_mask = (VBAT_LL_CHARGER_MASK | VBAT_LL_DETECT_MASK),
};
#else
vbat_hal_config_t vbat_cfg = {
.enable_vbat_charger = false,
.brownout_threshold = VBAT_BROWNOUT_DET_LVL,
.interrupt_mask = VBAT_LL_DETECT_MASK,
};
#endif
vbat_hal_config(&vbat_cfg);
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(power_supply_periph_signal.irq, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED, (uint32_t)brownout_ll_intr_get_status_reg(), VBAT_LL_CHARGER_MASK | VBAT_LL_DETECT_MASK, &vbat_isr_handler, NULL, &vbat_intr), TAG, "Allocate vbat isr failed");
return ESP_OK;
}