Making an ESP32-based quadcopter from scratch
Python arduinoautopilotcontrol-theorydroneesp32flight-controlflight-controllermavlinkquadcopterquadcopter-firmwareuav
Move disabling brown-out code to power subsystem
Oleg Kalachev6e439859bc78
diff --git a/flix/flix.ino b/flix/flix.inoindex e03b3e3..16b62aa 100644--- a/flix/flix.ino+++ b/flix/flix.ino@@ -18,8 +18,8 @@ extern float motors[4];void setup() {Serial.begin(115200);print("Initializing flix\n");- disableBrownOut();setupParameters();+ setupPower();setupLED();setLED(true);setupMotors();diff --git a/flix/power.ino b/flix/power.inoindex d5d7304..b9e07f0 100644--- a/flix/power.ino+++ b/flix/power.ino@@ -3,6 +3,8 @@// Power management+#include <soc/soc.h>+#include <soc/rtc_cntl_reg.h>#include "lpf.h"#include "util.h"@@ -11,6 +13,11 @@ LowPassFilter<float> voltageFilter(0.2);int voltagePin = -1;float voltageScale = 2;+void setupPower() {+ // Disable reset on low voltage+ REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA);+}+void readVoltage() {if (voltagePin < 0) return;static Rate rate(10);diff --git a/flix/util.h b/flix/util.hindex 025cd5e..ffb57b3 100644--- a/flix/util.h+++ b/flix/util.h@@ -6,8 +6,6 @@#pragma once#include <math.h>-#include <soc/soc.h>-#include <soc/rtc_cntl_reg.h>const float ONE_G = 9.80665;extern float t;@@ -35,11 +33,6 @@ float wrapAngle(float angle) {return angle;}-// Disable reset on low voltage-void disableBrownOut() {- REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA);-}-// Trim and split string by spacesvoid splitString(String& str, String& token0, String& token1, String& token2) {str.trim();diff --git a/gazebo/soc/soc.h b/gazebo/soc/soc.hindex 2d3f1e2..f9817f6 100644--- a/gazebo/soc/soc.h+++ b/gazebo/soc/soc.h@@ -1,4 +1,3 @@// Dummy file to make it possible to compile simulator with Flix' util.h-#define WRITE_PERI_REG(addr, val) {}#define REG_CLR_BIT(_r, _b) {}