AP_Compass: add and use AP_COMPASS_QMC5883L_ENABLED

This commit is contained in:
Peter Barker 2023-02-20 12:05:13 +11:00 committed by Andrew Tridgell
parent 4a44b6af86
commit 89a9636c46
5 changed files with 17 additions and 2 deletions

View File

@ -1085,7 +1085,7 @@ void Compass::_probe_external_i2c_compasses(void)
#endif // !defined(HAL_SKIP_AUTO_INTERNAL_I2C_PROBE) #endif // !defined(HAL_SKIP_AUTO_INTERNAL_I2C_PROBE)
#endif // AP_COMPASS_HMC5843_ENABLED #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 //external i2c bus
FOREACH_I2C_EXTERNAL(i) { FOREACH_I2C_EXTERNAL(i) {
ADD_BACKEND(DRIVER_QMC5883L, AP_Compass_QMC5883L::probe(GET_I2C_DEVICE(i, HAL_COMPASS_QMC5883L_I2C_ADDR), 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 #endif // AP_COMPASS_QMC5883L_ENABLED
#ifndef HAL_BUILD_AP_PERIPH #ifndef HAL_BUILD_AP_PERIPH
// AK09916 on ICM20948 // AK09916 on ICM20948

View File

@ -447,7 +447,9 @@ private:
#if AP_COMPASS_UAVCAN_ENABLED #if AP_COMPASS_UAVCAN_ENABLED
DRIVER_UAVCAN =11, DRIVER_UAVCAN =11,
#endif #endif
#if AP_COMPASS_QMC5883L_ENABLED
DRIVER_QMC5883L =12, DRIVER_QMC5883L =12,
#endif
#if AP_COMPASS_SITL_ENABLED #if AP_COMPASS_SITL_ENABLED
DRIVER_SITL =13, DRIVER_SITL =13,
#endif #endif

View File

@ -19,6 +19,8 @@
*/ */
#include "AP_Compass_QMC5883L.h" #include "AP_Compass_QMC5883L.h"
#if AP_COMPASS_QMC5883L_ENABLED
#include <stdio.h> #include <stdio.h>
#include <utility> #include <utility>
@ -216,3 +218,4 @@ void AP_Compass_QMC5883L::_dump_registers()
} }
} }
#endif // AP_COMPASS_QMC5883L_ENABLED

View File

@ -16,6 +16,10 @@
*/ */
#pragma once #pragma once
#include "AP_Compass_config.h"
#if AP_COMPASS_QMC5883L_ENABLED
#include <AP_Common/AP_Common.h> #include <AP_Common/AP_Common.h>
#include <AP_HAL/AP_HAL.h> #include <AP_HAL/AP_HAL.h>
#include <AP_HAL/I2CDevice.h> #include <AP_HAL/I2CDevice.h>
@ -66,3 +70,5 @@ private:
uint8_t _instance; uint8_t _instance;
bool _force_external:1; bool _force_external:1;
}; };
#endif // AP_COMPASS_QMC5883L_ENABLED

View File

@ -86,3 +86,7 @@
#ifndef AP_COMPASS_MMC3416_ENABLED #ifndef AP_COMPASS_MMC3416_ENABLED
#define AP_COMPASS_MMC3416_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED #define AP_COMPASS_MMC3416_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED
#endif #endif
#ifndef AP_COMPASS_QMC5883L_ENABLED
#define AP_COMPASS_QMC5883L_ENABLED AP_COMPASS_I2C_BACKEND_DEFAULT_ENABLED
#endif