From 750772c349e0c25e4f2f7a152fe77c00fcd67234 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 26 Oct 2022 23:02:23 +1100 Subject: [PATCH] AP_Baro: tidy includes into AP_Baro_config.h --- libraries/AP_Baro/AP_Baro.h | 18 +----- libraries/AP_Baro/AP_Baro_BMP085.h | 4 -- libraries/AP_Baro/AP_Baro_BMP280.h | 4 -- libraries/AP_Baro/AP_Baro_BMP388.h | 4 -- libraries/AP_Baro/AP_Baro_Backend.h | 4 -- libraries/AP_Baro/AP_Baro_DPS280.h | 4 -- libraries/AP_Baro/AP_Baro_Dummy.h | 4 -- libraries/AP_Baro/AP_Baro_ExternalAHRS.h | 2 - libraries/AP_Baro/AP_Baro_FBM320.h | 4 -- libraries/AP_Baro/AP_Baro_ICM20789.h | 4 -- libraries/AP_Baro/AP_Baro_ICP101XX.h | 6 +- libraries/AP_Baro/AP_Baro_ICP201XX.h | 6 +- libraries/AP_Baro/AP_Baro_KellerLD.h | 4 -- libraries/AP_Baro/AP_Baro_LPS2XH.h | 4 -- libraries/AP_Baro/AP_Baro_MS5611.h | 4 -- libraries/AP_Baro/AP_Baro_SPL06.h | 4 -- libraries/AP_Baro/AP_Baro_UAVCAN.h | 4 -- libraries/AP_Baro/AP_Baro_config.h | 82 ++++++++++++++++++++++++ 18 files changed, 86 insertions(+), 80 deletions(-) create mode 100644 libraries/AP_Baro/AP_Baro_config.h diff --git a/libraries/AP_Baro/AP_Baro.h b/libraries/AP_Baro/AP_Baro.h index 264acae5b6..9f8298fad0 100644 --- a/libraries/AP_Baro/AP_Baro.h +++ b/libraries/AP_Baro/AP_Baro.h @@ -1,23 +1,13 @@ #pragma once +#include "AP_Baro_config.h" + #include #include #include #include #include -#ifndef AP_SIM_BARO_ENABLED -#define AP_SIM_BARO_ENABLED AP_SIM_ENABLED -#endif - -#ifndef AP_BARO_EXTERNALAHRS_ENABLED -#define AP_BARO_EXTERNALAHRS_ENABLED HAL_EXTERNAL_AHRS_ENABLED -#endif - -#ifndef AP_BARO_MSP_ENABLED -#define AP_BARO_MSP_ENABLED HAL_MSP_SENSORS_ENABLED -#endif - // maximum number of sensor instances #ifndef BARO_MAX_INSTANCES #define BARO_MAX_INSTANCES 3 @@ -31,10 +21,6 @@ #define BARO_TIMEOUT_MS 500 // timeout in ms since last successful read #define BARO_DATA_CHANGE_TIMEOUT_MS 2000 // timeout in ms since last successful read that involved temperature of pressure changing -#ifndef HAL_BARO_WIND_COMP_ENABLED -#define HAL_BARO_WIND_COMP_ENABLED !HAL_MINIMIZE_FEATURES -#endif - class AP_Baro_Backend; class AP_Baro diff --git a/libraries/AP_Baro/AP_Baro_BMP085.h b/libraries/AP_Baro/AP_Baro_BMP085.h index 92b7178e83..0b77e93b05 100644 --- a/libraries/AP_Baro/AP_Baro_BMP085.h +++ b/libraries/AP_Baro/AP_Baro_BMP085.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_BMP085_ENABLED -#define AP_BARO_BMP085_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_BMP085_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_BMP280.h b/libraries/AP_Baro/AP_Baro_BMP280.h index 48c62aebf8..32969e47b5 100644 --- a/libraries/AP_Baro/AP_Baro_BMP280.h +++ b/libraries/AP_Baro/AP_Baro_BMP280.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_BMP280_ENABLED -#define AP_BARO_BMP280_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_BMP280_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_BMP388.h b/libraries/AP_Baro/AP_Baro_BMP388.h index a6126a4c6b..fbae256674 100644 --- a/libraries/AP_Baro/AP_Baro_BMP388.h +++ b/libraries/AP_Baro/AP_Baro_BMP388.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_BMP388_ENABLED -#define AP_BARO_BMP388_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_BMP388_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_Backend.h b/libraries/AP_Baro/AP_Baro_Backend.h index 045fffcca3..476473bf5d 100644 --- a/libraries/AP_Baro/AP_Baro_Backend.h +++ b/libraries/AP_Baro/AP_Baro_Backend.h @@ -2,10 +2,6 @@ #include "AP_Baro.h" -#ifndef AP_BARO_BACKEND_DEFAULT_ENABLED -#define AP_BARO_BACKEND_DEFAULT_ENABLED 1 -#endif - class AP_Baro_Backend { public: diff --git a/libraries/AP_Baro/AP_Baro_DPS280.h b/libraries/AP_Baro/AP_Baro_DPS280.h index 783a744102..799d71a600 100644 --- a/libraries/AP_Baro/AP_Baro_DPS280.h +++ b/libraries/AP_Baro/AP_Baro_DPS280.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_DPS280_ENABLED -#define AP_BARO_DPS280_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_DPS280_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_Dummy.h b/libraries/AP_Baro/AP_Baro_Dummy.h index d43f512b3e..7c76ebe414 100644 --- a/libraries/AP_Baro/AP_Baro_Dummy.h +++ b/libraries/AP_Baro/AP_Baro_Dummy.h @@ -6,10 +6,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_DUMMY_ENABLED -#define AP_BARO_DUMMY_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_DUMMY_ENABLED class AP_Baro_Dummy : public AP_Baro_Backend diff --git a/libraries/AP_Baro/AP_Baro_ExternalAHRS.h b/libraries/AP_Baro/AP_Baro_ExternalAHRS.h index 1b5dbdf823..2950b36570 100644 --- a/libraries/AP_Baro/AP_Baro_ExternalAHRS.h +++ b/libraries/AP_Baro/AP_Baro_ExternalAHRS.h @@ -5,8 +5,6 @@ #include "AP_Baro_Backend.h" -// AP_BARO_EXTERNALAHRS_ENABLED is defined in AP_Baro.h - #if AP_BARO_EXTERNALAHRS_ENABLED class AP_Baro_ExternalAHRS : public AP_Baro_Backend diff --git a/libraries/AP_Baro/AP_Baro_FBM320.h b/libraries/AP_Baro/AP_Baro_FBM320.h index 9cb0507094..546cbebabb 100644 --- a/libraries/AP_Baro/AP_Baro_FBM320.h +++ b/libraries/AP_Baro/AP_Baro_FBM320.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_FBM320_ENABLED -#define AP_BARO_FBM320_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_FBM320_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_ICM20789.h b/libraries/AP_Baro/AP_Baro_ICM20789.h index a7a2390623..71e3f7831d 100644 --- a/libraries/AP_Baro/AP_Baro_ICM20789.h +++ b/libraries/AP_Baro/AP_Baro_ICM20789.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_ICM20789_ENABLED -#define AP_BARO_ICM20789_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_ICM20789_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_ICP101XX.h b/libraries/AP_Baro/AP_Baro_ICP101XX.h index ee94db8af7..3d80646360 100755 --- a/libraries/AP_Baro/AP_Baro_ICP101XX.h +++ b/libraries/AP_Baro/AP_Baro_ICP101XX.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_ICP101XX_ENABLED -#define AP_BARO_ICP101XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_ICP101XX_ENABLED #include @@ -64,4 +60,4 @@ private: uint32_t measure_interval = 0; }; -#endif // AP_BARO_ICP101XX_ENABLED \ No newline at end of file +#endif // AP_BARO_ICP101XX_ENABLED diff --git a/libraries/AP_Baro/AP_Baro_ICP201XX.h b/libraries/AP_Baro/AP_Baro_ICP201XX.h index 5401816234..14352c3c73 100755 --- a/libraries/AP_Baro/AP_Baro_ICP201XX.h +++ b/libraries/AP_Baro/AP_Baro_ICP201XX.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_ICP201XX_ENABLED -#define AP_BARO_ICP201XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_ICP201XX_ENABLED #include @@ -82,4 +78,4 @@ private: } _forced_meas_trigger{FORCED_MEAS_TRIGGER::FORCE_MEAS_STANDBY}; }; -#endif // AP_BARO_ICP201XX_ENABLED \ No newline at end of file +#endif // AP_BARO_ICP201XX_ENABLED diff --git a/libraries/AP_Baro/AP_Baro_KellerLD.h b/libraries/AP_Baro/AP_Baro_KellerLD.h index 235acff0a0..9a33ccd627 100644 --- a/libraries/AP_Baro/AP_Baro_KellerLD.h +++ b/libraries/AP_Baro/AP_Baro_KellerLD.h @@ -27,10 +27,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_KELLERLD_ENABLED -#define AP_BARO_KELLERLD_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_KELLERLD_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_LPS2XH.h b/libraries/AP_Baro/AP_Baro_LPS2XH.h index 7ca571f145..96e3a8dad3 100644 --- a/libraries/AP_Baro/AP_Baro_LPS2XH.h +++ b/libraries/AP_Baro/AP_Baro_LPS2XH.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_LPS2XH_ENABLED -#define AP_BARO_LPS2XH_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_LPS2XH_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_MS5611.h b/libraries/AP_Baro/AP_Baro_MS5611.h index 4115a3f8a3..2f124db228 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.h +++ b/libraries/AP_Baro/AP_Baro_MS5611.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_MS56XX_ENABLED -#define AP_BARO_MS56XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_MS56XX_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_SPL06.h b/libraries/AP_Baro/AP_Baro_SPL06.h index 6c7f148097..7dcba34ee8 100644 --- a/libraries/AP_Baro/AP_Baro_SPL06.h +++ b/libraries/AP_Baro/AP_Baro_SPL06.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_SPL06_ENABLED -#define AP_BARO_SPL06_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED -#endif - #if AP_BARO_SPL06_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_UAVCAN.h b/libraries/AP_Baro/AP_Baro_UAVCAN.h index 9ac8af6dfc..2edcc2e871 100644 --- a/libraries/AP_Baro/AP_Baro_UAVCAN.h +++ b/libraries/AP_Baro/AP_Baro_UAVCAN.h @@ -2,10 +2,6 @@ #include "AP_Baro_Backend.h" -#ifndef AP_BARO_UAVCAN_ENABLED -#define AP_BARO_UAVCAN_ENABLED (AP_BARO_BACKEND_DEFAULT_ENABLED && HAL_ENABLE_LIBUAVCAN_DRIVERS) -#endif - #if AP_BARO_UAVCAN_ENABLED #include diff --git a/libraries/AP_Baro/AP_Baro_config.h b/libraries/AP_Baro/AP_Baro_config.h new file mode 100644 index 0000000000..87df55266b --- /dev/null +++ b/libraries/AP_Baro/AP_Baro_config.h @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include + +#ifndef HAL_BARO_WIND_COMP_ENABLED +#define HAL_BARO_WIND_COMP_ENABLED !HAL_MINIMIZE_FEATURES +#endif + +// backend support: +#ifndef AP_BARO_BACKEND_DEFAULT_ENABLED +#define AP_BARO_BACKEND_DEFAULT_ENABLED 1 +#endif + +#ifndef AP_BARO_BMP085_ENABLED +#define AP_BARO_BMP085_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_BMP280_ENABLED +#define AP_BARO_BMP280_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_BMP388_ENABLED +#define AP_BARO_BMP388_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_DPS280_ENABLED +#define AP_BARO_DPS280_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_DUMMY_ENABLED +#define AP_BARO_DUMMY_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_EXTERNALAHRS_ENABLED +#define AP_BARO_EXTERNALAHRS_ENABLED HAL_EXTERNAL_AHRS_ENABLED +#endif + +#ifndef AP_BARO_FBM320_ENABLED +#define AP_BARO_FBM320_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_ICM20789_ENABLED +#define AP_BARO_ICM20789_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_ICP101XX_ENABLED +#define AP_BARO_ICP101XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_ICP201XX_ENABLED +#define AP_BARO_ICP201XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_KELLERLD_ENABLED +#define AP_BARO_KELLERLD_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_LPS2XH_ENABLED +#define AP_BARO_LPS2XH_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_MS56XX_ENABLED +#define AP_BARO_MS56XX_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_MSP_ENABLED +#define AP_BARO_MSP_ENABLED HAL_MSP_SENSORS_ENABLED +#endif + +#ifndef AP_SIM_BARO_ENABLED +#define AP_SIM_BARO_ENABLED AP_SIM_ENABLED +#endif + +#ifndef AP_BARO_SPL06_ENABLED +#define AP_BARO_SPL06_ENABLED AP_BARO_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_BARO_UAVCAN_ENABLED +#define AP_BARO_UAVCAN_ENABLED (AP_BARO_BACKEND_DEFAULT_ENABLED && HAL_ENABLE_LIBUAVCAN_DRIVERS) +#endif