From 1889d3dea5a969cb43abe4ff2a9263e7a9f97c7b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 20 Feb 2023 12:05:18 +1100 Subject: [PATCH] AP_Compass: add and use AP_COMPASS_MMC5XX3_ENABLED --- libraries/AP_Compass/AP_Compass.h | 2 ++ libraries/AP_Compass/AP_Compass_MMC5xx3.cpp | 5 +++++ libraries/AP_Compass/AP_Compass_MMC5xx3.h | 6 ++++++ libraries/AP_Compass/AP_Compass_config.h | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/libraries/AP_Compass/AP_Compass.h b/libraries/AP_Compass/AP_Compass.h index 6bb13e1759..27f4a42980 100644 --- a/libraries/AP_Compass/AP_Compass.h +++ b/libraries/AP_Compass/AP_Compass.h @@ -468,7 +468,9 @@ private: #if AP_COMPASS_EXTERNALAHRS_ENABLED DRIVER_EXTERNALAHRS =18, #endif +#if AP_COMPASS_MMC5XX3_ENABLED DRIVER_MMC5XX3 =19, +#endif }; bool _driver_enabled(enum DriverType driver_type); diff --git a/libraries/AP_Compass/AP_Compass_MMC5xx3.cpp b/libraries/AP_Compass/AP_Compass_MMC5xx3.cpp index 0c164ca444..afb141a430 100644 --- a/libraries/AP_Compass/AP_Compass_MMC5xx3.cpp +++ b/libraries/AP_Compass/AP_Compass_MMC5xx3.cpp @@ -15,6 +15,8 @@ #include "AP_Compass_MMC5xx3.h" +#if AP_COMPASS_MMC5XX3_ENABLED + #include #include @@ -305,3 +307,6 @@ void AP_Compass_MMC5XX3::read() { drain_accumulated_samples(compass_instance); } + +#endif // AP_COMPASS_MMC5XX3_ENABLED + diff --git a/libraries/AP_Compass/AP_Compass_MMC5xx3.h b/libraries/AP_Compass/AP_Compass_MMC5xx3.h index 543e1ae1a7..8acd6e5633 100644 --- a/libraries/AP_Compass/AP_Compass_MMC5xx3.h +++ b/libraries/AP_Compass/AP_Compass_MMC5xx3.h @@ -14,6 +14,10 @@ */ #pragma once +#include "AP_Compass_config.h" + +#if AP_COMPASS_MMC5XX3_ENABLED + #include #include #include @@ -72,3 +76,5 @@ private: enum Rotation rotation; }; + +#endif // AP_COMPASS_MMC5XX3_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_config.h b/libraries/AP_Compass/AP_Compass_config.h index 91e8b6a82e..3c1c91bd76 100644 --- a/libraries/AP_Compass/AP_Compass_config.h +++ b/libraries/AP_Compass/AP_Compass_config.h @@ -91,6 +91,10 @@ #define AP_COMPASS_MMC3416_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED #endif +#ifndef AP_COMPASS_MMC5XX3_ENABLED +#define AP_COMPASS_MMC5XX3_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED +#endif + #ifndef AP_COMPASS_QMC5883L_ENABLED #define AP_COMPASS_QMC5883L_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED #endif