diff --git a/libraries/AP_Compass/AP_Compass_HMC5843.cpp b/libraries/AP_Compass/AP_Compass_HMC5843.cpp index a9c3d4b10c..6c8f917645 100644 --- a/libraries/AP_Compass/AP_Compass_HMC5843.cpp +++ b/libraries/AP_Compass/AP_Compass_HMC5843.cpp @@ -126,6 +126,7 @@ AP_Compass_Backend *AP_Compass_HMC5843::probe(AP_HAL::OwnPtr dev return sensor; } +#if AP_INERTIALSENSOR_ENABLED AP_Compass_Backend *AP_Compass_HMC5843::probe_mpu6000(enum Rotation rotation) { AP_InertialSensor &ins = *AP_InertialSensor::get_singleton(); @@ -145,6 +146,7 @@ AP_Compass_Backend *AP_Compass_HMC5843::probe_mpu6000(enum Rotation rotation) return sensor; } +#endif bool AP_Compass_HMC5843::init() { @@ -488,6 +490,7 @@ AP_HAL::Device::PeriodicHandle AP_HMC5843_BusDriver_HALDevice::register_periodic } +#if AP_INERTIALSENSOR_ENABLED /* HMC5843 on an auxiliary bus of IMU driver */ AP_HMC5843_BusDriver_Auxiliary::AP_HMC5843_BusDriver_Auxiliary(AP_InertialSensor &ins, uint8_t backend_id, uint8_t addr) @@ -496,14 +499,12 @@ AP_HMC5843_BusDriver_Auxiliary::AP_HMC5843_BusDriver_Auxiliary(AP_InertialSensor * Only initialize members. Fails are handled by configure or while * getting the semaphore */ -#if AP_INERTIALSENSOR_ENABLED _bus = ins.get_auxiliary_bus(backend_id); if (!_bus) { return; } _slave = _bus->request_next_slave(addr); -#endif } AP_HMC5843_BusDriver_Auxiliary::~AP_HMC5843_BusDriver_Auxiliary() @@ -585,5 +586,6 @@ uint32_t AP_HMC5843_BusDriver_Auxiliary::get_bus_id(void) const { return _bus->get_bus_id(); } +#endif // AP_INERTIALSENSOR_ENABLED #endif // AP_COMPASS_HMC5843_ENABLED diff --git a/libraries/AP_Compass/AP_Compass_HMC5843.h b/libraries/AP_Compass/AP_Compass_HMC5843.h index e3427c2d3d..a2750c6cef 100644 --- a/libraries/AP_Compass/AP_Compass_HMC5843.h +++ b/libraries/AP_Compass/AP_Compass_HMC5843.h @@ -13,6 +13,7 @@ #include #include "AP_Compass_Backend.h" +#include class AuxiliaryBus; class AuxiliaryBusSlave; @@ -26,7 +27,9 @@ public: bool force_external, enum Rotation rotation); +#if AP_INERTIALSENSOR_ENABLED static AP_Compass_Backend *probe_mpu6000(enum Rotation rotation); +#endif static constexpr const char *name = "HMC5843"; @@ -124,6 +127,7 @@ private: AP_HAL::OwnPtr _dev; }; +#if AP_INERTIALSENSOR_ENABLED class AP_HMC5843_BusDriver_Auxiliary : public AP_HMC5843_BusDriver { public: @@ -153,5 +157,6 @@ private: AuxiliaryBusSlave *_slave; bool _started; }; +#endif // AP_INERTIALSENSOR_ENABLED #endif // AP_COMPASS_HMC5843_ENABLED