diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index 0bf0bb0445..eef8add899 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -1085,7 +1085,7 @@ void Compass::_probe_external_i2c_compasses(void) #endif // !defined(HAL_SKIP_AUTO_INTERNAL_I2C_PROBE) #endif // AP_COMPASS_HMC5843_ENABLED -#if AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED || defined(HAL_USE_I2C_MAG_QMC5883L) +#if AP_COMPASS_QMC5883L_ENABLED //external i2c bus FOREACH_I2C_EXTERNAL(i) { ADD_BACKEND(DRIVER_QMC5883L, AP_Compass_QMC5883L::probe(GET_I2C_DEVICE(i, HAL_COMPASS_QMC5883L_I2C_ADDR), @@ -1103,7 +1103,7 @@ void Compass::_probe_external_i2c_compasses(void) } } #endif -#endif +#endif // AP_COMPASS_QMC5883L_ENABLED #ifndef HAL_BUILD_AP_PERIPH // AK09916 on ICM20948 diff --git a/libraries/AP_Compass/AP_Compass.h b/libraries/AP_Compass/AP_Compass.h index a78304c908..d57d7f801e 100644 --- a/libraries/AP_Compass/AP_Compass.h +++ b/libraries/AP_Compass/AP_Compass.h @@ -447,7 +447,9 @@ private: #if AP_COMPASS_UAVCAN_ENABLED DRIVER_UAVCAN =11, #endif +#if AP_COMPASS_QMC5883L_ENABLED DRIVER_QMC5883L =12, +#endif #if AP_COMPASS_SITL_ENABLED DRIVER_SITL =13, #endif diff --git a/libraries/AP_Compass/AP_Compass_QMC5883L.cpp b/libraries/AP_Compass/AP_Compass_QMC5883L.cpp index adc7b5ba93..ad1bea4989 100644 --- a/libraries/AP_Compass/AP_Compass_QMC5883L.cpp +++ b/libraries/AP_Compass/AP_Compass_QMC5883L.cpp @@ -19,6 +19,8 @@ */ #include "AP_Compass_QMC5883L.h" +#if AP_COMPASS_QMC5883L_ENABLED + #include #include @@ -216,3 +218,4 @@ void AP_Compass_QMC5883L::_dump_registers() } } +#endif // AP_COMPASS_QMC5883L_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_QMC5883L.h b/libraries/AP_Compass/AP_Compass_QMC5883L.h index bbf601585f..d133c8677b 100644 --- a/libraries/AP_Compass/AP_Compass_QMC5883L.h +++ b/libraries/AP_Compass/AP_Compass_QMC5883L.h @@ -16,6 +16,10 @@ */ #pragma once +#include "AP_Compass_config.h" + +#if AP_COMPASS_QMC5883L_ENABLED + #include #include #include @@ -66,3 +70,5 @@ private: uint8_t _instance; bool _force_external:1; }; + +#endif // AP_COMPASS_QMC5883L_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_config.h b/libraries/AP_Compass/AP_Compass_config.h index ad6d6f9885..0332e7f1fa 100644 --- a/libraries/AP_Compass/AP_Compass_config.h +++ b/libraries/AP_Compass/AP_Compass_config.h @@ -86,3 +86,7 @@ #ifndef AP_COMPASS_MMC3416_ENABLED #define AP_COMPASS_MMC3416_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