Disable ESP32 reset on low voltage

This commit is contained in:
Oleg Kalachev 2024-01-17 15:18:11 +03:00
parent 4ec6ff3f37
commit 482bb8ed71
2 changed files with 8 additions and 0 deletions

View File

@ -36,6 +36,7 @@ float motors[4]; // normalized motors thrust in range [-1..1]
void setup() { void setup() {
Serial.begin(SERIAL_BAUDRATE); Serial.begin(SERIAL_BAUDRATE);
Serial.println("Initializing flix"); Serial.println("Initializing flix");
disableBrownOut();
setupLED(); setupLED();
setupMotors(); setupMotors();
setLED(true); setLED(true);

View File

@ -4,6 +4,8 @@
// Utility functions // Utility functions
#include "math.h" #include "math.h"
#include <soc/soc.h>
#include <soc/rtc_cntl_reg.h>
float mapf(long x, long in_min, long in_max, float out_min, float out_max) { float mapf(long x, long in_min, long in_max, float out_min, float out_max) {
return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min; return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;
@ -41,3 +43,8 @@ void printArray(T arr[], int size) {
} }
Serial.println("}"); Serial.println("}");
} }
// Disable reset on low voltage
void disableBrownOut() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
}