From 6e439859bc787c6ba355e966eb49863b3c89c517 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 23 Apr 2026 15:06:07 +0300 Subject: [PATCH] Move disabling brown-out code to power subsystem --- flix/flix.ino | 2 +- flix/power.ino | 7 +++++++ flix/util.h | 7 ------- gazebo/soc/soc.h | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/flix/flix.ino b/flix/flix.ino index 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.ino index d5d7304..b9e07f0 100644 --- a/flix/power.ino +++ b/flix/power.ino @@ -3,6 +3,8 @@ // Power management +#include +#include #include "lpf.h" #include "util.h" @@ -11,6 +13,11 @@ LowPassFilter 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.h index 025cd5e..ffb57b3 100644 --- a/flix/util.h +++ b/flix/util.h @@ -6,8 +6,6 @@ #pragma once #include -#include -#include 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 spaces void splitString(String& str, String& token0, String& token1, String& token2) { str.trim(); diff --git a/gazebo/soc/soc.h b/gazebo/soc/soc.h index 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) {}