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 }; 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 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat index 775a0e2ac263d..4e2ed6ef1d558 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/FSOPowerStack/hwdef.dat @@ -23,27 +23,24 @@ 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 AP_PERIPH_FSO_POWERSTACK_ENABLED 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 @@ -54,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 @@ -186,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