From aac6228f584d0417a919cbc58101d6f4ecb9531b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 20 Feb 2023 12:05:15 +1100 Subject: [PATCH] AP_Compass: add and use AP_COMPASS_MAG3110_ENABLED --- libraries/AP_Compass/AP_Compass.h | 2 ++ libraries/AP_Compass/AP_Compass_MAG3110.cpp | 8 ++++++-- libraries/AP_Compass/AP_Compass_MAG3110.h | 6 ++++++ libraries/AP_Compass/AP_Compass_config.h | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass.h b/libraries/AP_Compass/AP_Compass.h index d57d7f801e..74050904c0 100644 --- a/libraries/AP_Compass/AP_Compass.h +++ b/libraries/AP_Compass/AP_Compass.h @@ -453,7 +453,9 @@ private: #if AP_COMPASS_SITL_ENABLED DRIVER_SITL =13, #endif +#if AP_COMPASS_MAG3110_ENABLED DRIVER_MAG3110 =14, +#endif #if AP_COMPASS_IST8308_ENABLED DRIVER_IST8308 =15, #endif diff --git a/libraries/AP_Compass/AP_Compass_MAG3110.cpp b/libraries/AP_Compass/AP_Compass_MAG3110.cpp index 37cc16761c..69ae611c82 100644 --- a/libraries/AP_Compass/AP_Compass_MAG3110.cpp +++ b/libraries/AP_Compass/AP_Compass_MAG3110.cpp @@ -12,14 +12,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "AP_Compass_MAG3110.h" + +#if AP_COMPASS_MAG3110_ENABLED + #include #include #include #include -#include "AP_Compass_MAG3110.h" - extern const AP_HAL::HAL &hal; @@ -219,3 +221,5 @@ void AP_Compass_MAG3110::read() drain_accumulated_samples(_compass_instance); } + +#endif // AP_COMPASS_MAG3110_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_MAG3110.h b/libraries/AP_Compass/AP_Compass_MAG3110.h index 41b27b12e1..80167ba38d 100644 --- a/libraries/AP_Compass/AP_Compass_MAG3110.h +++ b/libraries/AP_Compass/AP_Compass_MAG3110.h @@ -1,5 +1,9 @@ #pragma once +#include "AP_Compass_config.h" + +#if AP_COMPASS_MAG3110_ENABLED + #include #include #include @@ -44,3 +48,5 @@ private: uint8_t _compass_instance; bool _initialised; }; + +#endif // AP_COMPASS_MAG3110_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_config.h b/libraries/AP_Compass/AP_Compass_config.h index 0332e7f1fa..a42fe8126b 100644 --- a/libraries/AP_Compass/AP_Compass_config.h +++ b/libraries/AP_Compass/AP_Compass_config.h @@ -83,6 +83,10 @@ #define AP_COMPASS_LSM9DS1_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED #endif +#ifndef AP_COMPASS_MAG3110_ENABLED +#define AP_COMPASS_MAG3110_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED +#endif + #ifndef AP_COMPASS_MMC3416_ENABLED #define AP_COMPASS_MMC3416_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED #endif