forked from espressif/esp-idf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refactor/move_bod_to_hw_support' into 'master'
refactor(bod): Move brownout handling file from esp_system to esp_hw_support See merge request espressif/esp-idf!36191
- Loading branch information
Showing
48 changed files
with
433 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
components/esp_hw_support/power_supply/include/esp_private/brownout.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Initialize the brownout detection system | ||
* | ||
* This function configures and enables the brownout detection hardware, which monitors | ||
* the power supply voltage and triggers appropriate system actions if the voltage | ||
* drops below a predefined threshold. Brownout detection helps ensure the stability | ||
* and reliability of the system under low-voltage conditions. | ||
*/ | ||
void esp_brownout_init(void); | ||
|
||
/** | ||
* @brief Disable the brownout detection system | ||
* | ||
* This function disables the brownout detection hardware, stopping voltage monitoring | ||
* and associated system actions. Use this function with caution, as disabling brownout | ||
* detection may increase the risk of system instability or malfunction under low-voltage | ||
* conditions. | ||
*/ | ||
void esp_brownout_disable(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
64 changes: 64 additions & 0 deletions
64
components/esp_hw_support/power_supply/port/esp32/Kconfig.bod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
components/esp_hw_support/power_supply/port/esp32s2/Kconfig.bod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
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 |
Oops, something went wrong.