Add ESP32 optional brownout disable

Add ESP32 brownout disable for weak onboard LDO's - eventually you'll need to change the LDO to a better one.
This commit is contained in:
Theo Arends 2020-04-17 18:27:31 +02:00 committed by Javier Arigita
parent 3f9fdc09ce
commit 8ada812218
3 changed files with 16 additions and 0 deletions

View File

@ -109,3 +109,12 @@ uint32_t ESP_getSketchSize(void)
}
return sketchsize;
}
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
void DisableBrownout(void)
{
// https://github.com/espressif/arduino-esp32/issues/863#issuecomment-347179737
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // Disable brownout detector
}

View File

@ -43,6 +43,7 @@ uint32_t ESP_getFlashChipId();
uint32_t ESP_getChipId();
String String_ESP_getChipId();
uint32_t ESP_getSketchSize();
void DisableBrownout(void);
// Analog
inline void analogWrite(uint8_t pin, int val)

View File

@ -192,6 +192,12 @@ void setup(void)
{
global_state.data = 3; // Init global state (wifi_down, mqtt_down) to solve possible network issues
#ifdef ESP32
#ifdef DISABLE_BROWNOUT
DisableBrownout();
#endif
#endif
RtcRebootLoad();
if (!RtcRebootValid()) {
RtcReboot.fast_reboot_count = 0;