From ca36766a6b0dd18ecb902f191002a92f20f94740 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 9 Feb 2026 15:48:08 +1100 Subject: [PATCH 1/5] hwdef: FSOPowerStack: remove pointless hwdef lines --- libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat index 205b7f71977f9..4118437138f5d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef-bl.dat @@ -43,14 +43,8 @@ define STM32_SERIAL_USE_USART3 FALSE define HAL_USE_EMPTY_IO TRUE -# avoid timer and RCIN threads to save memory -define HAL_NO_TIMER_THREAD -define HAL_RCIN_THREAD_ENABLED 0 - define DMA_RESERVE_SIZE 0 -define HAL_SCHEDULER_LOOP_DELAY_ENABLED 0 - # default to all pins low to avoid ESD issues DEFAULTGPIO OUTPUT LOW PULLDOWN From dc8ef2dba325f6776613905ab238d109e9f54582 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 9 Feb 2026 16:06:18 +1100 Subject: [PATCH 2/5] hwdef: FSOPowerStack: tidy battery defines removes duplicates and groups things together --- .../AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat index 775a0e2ac263d..9fb8a00761347 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat @@ -23,17 +23,20 @@ FLASH_SIZE_KB 512 # Enable Options define AP_TEMPERATURE_SENSOR_ENABLED 1 define AP_TEMPERATURE_SENSOR_TSYS03_ENABLED 1 + +# Power monitoring define AP_PERIPH_BATTERY_ENABLED 1 -define AP_BATTERY_SUM_ENABLED 1 +define AP_BATT_MONITOR_MAX_INSTANCES 10 +define AP_BATTERY_BACKEND_DEFAULT_ENABLED 0 +define AP_BATTERY_ANALOG_ENABLED 1 define AP_BATTERY_INA2XX_ENABLED 1 +define AP_BATTERY_SUM_ENABLED 1 + define AP_PERIPH_RC_OUT_ENABLED 1 + define AP_PERIPH_NOTIFY_ENABLED 1 -define HAL_PERIPH_ENABLE_FSO_POWER_STACK 1 -define AP_BATT_MONITOR_MAX_INSTANCES 10 -define AP_BATTERY_BACKEND_DEFAULT_ENABLED 0 -define AP_BATTERY_INA2XX_ENABLED 1 -define AP_BATTERY_ANALOG_ENABLED 1 +define HAL_PERIPH_ENABLE_FSO_POWER_STACK 1 # enable DAC define AP_DAC_ENABLED 1 From f0e82822200ab06ed53bd947ec0a9db9d9f4fe60 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 9 Feb 2026 16:11:30 +1100 Subject: [PATCH 3/5] hwdef: FSOPowerStack: remove lines which do nothing --- .../AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat index 9fb8a00761347..0eafe68d75caf 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat @@ -41,12 +41,6 @@ define HAL_PERIPH_ENABLE_FSO_POWER_STACK 1 # enable DAC define AP_DAC_ENABLED 1 -# Disable Options -define HAL_RCIN_THREAD_ENABLED 0 -define HAL_USE_RTC FALSE -define HAL_SERIAL_ESC_COMM_ENABLED 0 -define HAL_SCHEDULER_LOOP_DELAY_ENABLED 0 - # enable serial LED define AP_NOTIFY_NEOPIXEL_ENABLED 1 define AP_SERIALLED_ENABLED 1 @@ -57,8 +51,6 @@ define STM32_PPRE2 STM32_PPRE2_DIV8 # Set Options define DMA_RESERVE_SIZE 0 -env DISABLE_SCRIPTING 1 - # ---------------------- UARTs --------------------------- define AP_PERIPH_SERIAL_OPTIONS_ENABLED 1 @@ -189,9 +181,6 @@ define HAL_GPIO_LED_ON 1 define AP_NOTIFY_GPIO_LED_RGB_ENABLED 1 define DEFAULT_NTF_LED_TYPES 257 -define HAL_LOGGING_ENABLED 0 -define HAL_MONITOR_THREAD_ENABLED 0 - define HAL_DEVICE_THREAD_STACK 768 # we setup a small defaults.parm From 2720cf3246a52d116bceddb9be3d8d6ff9076ed8 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 9 Feb 2026 16:43:53 +1100 Subject: [PATCH 4/5] AP_HAL_ChibiOS: canonicalise PowerStack enable define value brings this in-line with AP_Periph and AP standards --- libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat index 0eafe68d75caf..4e2ed6ef1d558 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat @@ -36,7 +36,7 @@ define AP_PERIPH_RC_OUT_ENABLED 1 define AP_PERIPH_NOTIFY_ENABLED 1 -define HAL_PERIPH_ENABLE_FSO_POWER_STACK 1 +define AP_PERIPH_FSO_POWERSTACK_ENABLED 1 # enable DAC define AP_DAC_ENABLED 1 From 6c38cf3e68d151fe0d6d129006bd82c24eba77ad Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 9 Feb 2026 16:43:53 +1100 Subject: [PATCH 5/5] AP_Periph: canonicalise PowerStack enable define value brings this in-line with AP_Periph and AP standards --- Tools/AP_Periph/AP_Periph.cpp | 12 ++++++------ Tools/AP_Periph/AP_Periph.h | 20 ++++++++++++-------- Tools/AP_Periph/FSOPowerStack.cpp | 4 ++-- Tools/AP_Periph/FSOPowerStack.h | 4 ++-- Tools/AP_Periph/Parameters.cpp | 4 ++-- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Tools/AP_Periph/AP_Periph.cpp b/Tools/AP_Periph/AP_Periph.cpp index 973418c369db7..319298333facc 100644 --- a/Tools/AP_Periph/AP_Periph.cpp +++ b/Tools/AP_Periph/AP_Periph.cpp @@ -315,10 +315,10 @@ void AP_Periph_FW::init() relay.init(); #endif -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED FSO_power_stack.init(); -#endif - +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED + #if AP_SCRIPTING_ENABLED scripting.init(); #endif @@ -525,10 +525,10 @@ void AP_Periph_FW::update() batt_balance_update(); #endif -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED FSO_power_stack.update(battery.last_read_ms == now); -#endif - +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED + static uint32_t fiftyhz_last_update_ms; if (now - fiftyhz_last_update_ms >= 20) { // update at 50Hz diff --git a/Tools/AP_Periph/AP_Periph.h b/Tools/AP_Periph/AP_Periph.h index f22d05d0e8567..a5033a76815c2 100644 --- a/Tools/AP_Periph/AP_Periph.h +++ b/Tools/AP_Periph/AP_Periph.h @@ -50,11 +50,6 @@ #endif #include -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK -#include "FSOPowerStack.h" -#endif -#include - #if AP_PERIPH_RELAY_ENABLED #if AP_PERIPH_PWM_HARDPOINT_ENABLED #error "Relay and PWM_HARDPOINT both use hardpoint message" @@ -111,6 +106,15 @@ #define AP_SIM_PARAM_ENABLED AP_SIM_ENABLED #endif +#ifndef AP_PERIPH_FSO_POWERSTACK_ENABLED +#define AP_PERIPH_FSO_POWERSTACK_ENABLED 0 +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED + +#if AP_PERIPH_FSO_POWERSTACK_ENABLED +#include "FSOPowerStack.h" +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED +#include + #if defined(HAL_PERIPH_LISTEN_FOR_SERIAL_UART_REBOOT_CMD_PORT) && !defined(HAL_DEBUG_BUILD) && !defined(HAL_PERIPH_LISTEN_FOR_SERIAL_UART_REBOOT_NON_DEBUG) /* this checking for reboot can lose bytes on GPS modules and other * serial devices. It is really only relevant on a debug build if you @@ -398,10 +402,10 @@ class AP_Periph_FW { BattBalance battery_balance; #endif -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED FSOPowerStack FSO_power_stack; -#endif - +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED + #if AP_PERIPH_BATTERY_TAG_ENABLED BatteryTag battery_tag; #endif diff --git a/Tools/AP_Periph/FSOPowerStack.cpp b/Tools/AP_Periph/FSOPowerStack.cpp index 2203a5ee545e0..e1a85d1c7673a 100644 --- a/Tools/AP_Periph/FSOPowerStack.cpp +++ b/Tools/AP_Periph/FSOPowerStack.cpp @@ -15,7 +15,7 @@ #include "AP_Periph.h" -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED #include @@ -1649,5 +1649,5 @@ void FSOPowerStack::update(bool battery_read) report_errors(); } -#endif // HAL_PERIPH_ENABLE_FSO_POWER_STACK +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED diff --git a/Tools/AP_Periph/FSOPowerStack.h b/Tools/AP_Periph/FSOPowerStack.h index a0395d105b8d2..c6e5a008d19d8 100644 --- a/Tools/AP_Periph/FSOPowerStack.h +++ b/Tools/AP_Periph/FSOPowerStack.h @@ -1,6 +1,6 @@ #pragma once -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED #include @@ -244,6 +244,6 @@ class FSOPowerStack { bool done_late_init; }; -#endif // HAL_PERIPH_ENABLE_FSO_POWER_STACK +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED diff --git a/Tools/AP_Periph/Parameters.cpp b/Tools/AP_Periph/Parameters.cpp index e9cfa9c328f3b..67f1f8985f07d 100644 --- a/Tools/AP_Periph/Parameters.cpp +++ b/Tools/AP_Periph/Parameters.cpp @@ -751,11 +751,11 @@ const AP_Param::Info AP_Periph_FW::var_info[] = { GSCALAR(servo_command_timeout_ms, "SRV_CMD_TIME_OUT", 200), #endif -#ifdef HAL_PERIPH_ENABLE_FSO_POWER_STACK +#if AP_PERIPH_FSO_POWERSTACK_ENABLED // @Group: FSO // @Path: FSOPowerStack.cpp GOBJECT(FSO_power_stack, "AAA", FSOPowerStack), -#endif +#endif // AP_PERIPH_FSO_POWERSTACK_ENABLED AP_VAREND };