From 0824eca7761b52c86f12fb854b997b9fcc723eff Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 25 Sep 2023 18:16:34 +1000 Subject: [PATCH] AP_GPS: use AP_GPS_ENABLED to exclude more code when GPS not compiled in --- libraries/AP_GPS/AP_GPS.cpp | 6 ++++++ libraries/AP_GPS/AP_GPS.h | 10 ++++++---- libraries/AP_GPS/AP_GPS_UBLOX.h | 6 ++++-- libraries/AP_GPS/AP_GPS_config.h | 8 ++++++-- libraries/AP_GPS/GPS_Backend.cpp | 6 ++++++ libraries/AP_GPS/GPS_Backend.h | 6 ++++++ .../AP_HAL_ChibiOS/hwdef/SpeedyBeeF405WING/hwdef.dat | 1 + 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/libraries/AP_GPS/AP_GPS.cpp b/libraries/AP_GPS/AP_GPS.cpp index fa77cf3dd0..23033fd0b4 100644 --- a/libraries/AP_GPS/AP_GPS.cpp +++ b/libraries/AP_GPS/AP_GPS.cpp @@ -12,6 +12,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "AP_GPS_config.h" + +#if AP_GPS_ENABLED + #include "AP_GPS.h" #include @@ -2330,3 +2334,5 @@ AP_GPS &gps() } }; + +#endif // AP_GPS_ENABLED diff --git a/libraries/AP_GPS/AP_GPS.h b/libraries/AP_GPS/AP_GPS.h index fb6b5740c4..a097e25138 100644 --- a/libraries/AP_GPS/AP_GPS.h +++ b/libraries/AP_GPS/AP_GPS.h @@ -14,6 +14,10 @@ */ #pragma once +#include "AP_GPS_config.h" + +#if AP_GPS_ENABLED + #include #include #include @@ -59,10 +63,6 @@ #define GPS_MOVING_BASELINE GPS_MAX_RECEIVERS>1 #endif -#ifndef HAL_MSP_GPS_ENABLED -#define HAL_MSP_GPS_ENABLED HAL_MSP_SENSORS_ENABLED -#endif - #if GPS_MOVING_BASELINE #include "MovingBase.h" #endif // GPS_MOVING_BASELINE @@ -791,3 +791,5 @@ private: namespace AP { AP_GPS &gps(); }; + +#endif // AP_GPS_ENABLED diff --git a/libraries/AP_GPS/AP_GPS_UBLOX.h b/libraries/AP_GPS/AP_GPS_UBLOX.h index eea8967af9..68afe623b4 100644 --- a/libraries/AP_GPS/AP_GPS_UBLOX.h +++ b/libraries/AP_GPS/AP_GPS_UBLOX.h @@ -20,11 +20,13 @@ // UBlox Lea6H protocol: http://www.u-blox.com/images/downloads/Product_Docs/u-blox6_ReceiverDescriptionProtocolSpec_%28GPS.G6-SW-10018%29.pdf #pragma once -#include "AP_GPS.h" -#include "GPS_Backend.h" +#include "AP_GPS_config.h" #if AP_GPS_UBLOX_ENABLED +#include "AP_GPS.h" +#include "GPS_Backend.h" + #include /* diff --git a/libraries/AP_GPS/AP_GPS_config.h b/libraries/AP_GPS/AP_GPS_config.h index 508307f02a..954a1f3bcf 100644 --- a/libraries/AP_GPS/AP_GPS_config.h +++ b/libraries/AP_GPS/AP_GPS_config.h @@ -12,7 +12,7 @@ #endif #ifndef AP_GPS_DRONECAN_ENABLED -#define AP_GPS_DRONECAN_ENABLED HAL_ENABLE_DRONECAN_DRIVERS +#define AP_GPS_DRONECAN_ENABLED AP_GPS_BACKEND_DEFAULT_ENABLED && HAL_ENABLE_DRONECAN_DRIVERS #endif #ifndef AP_GPS_ERB_ENABLED @@ -27,6 +27,10 @@ #define AP_GPS_MAV_ENABLED AP_GPS_BACKEND_DEFAULT_ENABLED && HAL_GCS_ENABLED #endif +#ifndef HAL_MSP_GPS_ENABLED +#define HAL_MSP_GPS_ENABLED AP_GPS_BACKEND_DEFAULT_ENABLED && HAL_MSP_SENSORS_ENABLED +#endif + #ifndef AP_GPS_NMEA_ENABLED #define AP_GPS_NMEA_ENABLED AP_GPS_BACKEND_DEFAULT_ENABLED #endif @@ -56,5 +60,5 @@ #endif #ifndef AP_GPS_UBLOX_ENABLED - #define AP_GPS_UBLOX_ENABLED 1 + #define AP_GPS_UBLOX_ENABLED AP_GPS_BACKEND_DEFAULT_ENABLED #endif diff --git a/libraries/AP_GPS/GPS_Backend.cpp b/libraries/AP_GPS/GPS_Backend.cpp index a6e28c5fa6..300a3bda79 100644 --- a/libraries/AP_GPS/GPS_Backend.cpp +++ b/libraries/AP_GPS/GPS_Backend.cpp @@ -13,6 +13,10 @@ along with this program. If not, see . */ +#include "AP_GPS_config.h" + +#if AP_GPS_ENABLED + #include "AP_GPS.h" #include "GPS_Backend.h" #include @@ -524,3 +528,5 @@ void AP_GPS_Backend::logging_start(void) logging_loop(); } #endif // AP_GPS_DEBUG_LOGGING_ENABLED + +#endif // AP_GPS_ENABLED diff --git a/libraries/AP_GPS/GPS_Backend.h b/libraries/AP_GPS/GPS_Backend.h index 38db811785..f69125f145 100644 --- a/libraries/AP_GPS/GPS_Backend.h +++ b/libraries/AP_GPS/GPS_Backend.h @@ -18,6 +18,10 @@ */ #pragma once +#include "AP_GPS_config.h" + +#if AP_GPS_ENABLED + #include #include #include @@ -180,3 +184,5 @@ private: #endif }; + +#endif // AP_GPS_ENABLED diff --git a/libraries/AP_HAL_ChibiOS/hwdef/SpeedyBeeF405WING/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/SpeedyBeeF405WING/hwdef.dat index e3f0538e2a..1ddb85368e 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/SpeedyBeeF405WING/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/SpeedyBeeF405WING/hwdef.dat @@ -218,6 +218,7 @@ define AP_AIRSPEED_ASP5033_ENABLED 1 define AP_GPS_BACKEND_DEFAULT_ENABLED 0 define AP_GPS_UBLOX_ENABLED 1 define AP_GPS_NMEA_ENABLED 1 +define HAL_MSP_GPS_ENABLED 1 define AP_TRAMP_ENABLED 1