From 3df5a0244838bee1b0f456d09e1a531c8ca39084 Mon Sep 17 00:00:00 2001 From: mirkix Date: Sun, 24 Apr 2016 10:23:47 +0200 Subject: [PATCH] AP_Compass: Add HMC5843 and second AK8963 autodetection to BBBmini --- libraries/AP_Compass/AP_Compass.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index f89680337d..4cac8d4bd3 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -453,6 +453,30 @@ void Compass::_detect_backends(void) } #elif HAL_COMPASS_DEFAULT == HAL_COMPASS_QFLIGHT _add_backend(AP_Compass_QFLIGHT::detect(*this)); +#elif HAL_COMPASS_DEFAULT == HAL_COMPASS_BBBMINI + AP_Compass_Backend *backend = AP_Compass_HMC5843::probe(*this, hal.i2c_mgr->get_device(HAL_COMPASS_HMC5843_I2C_BUS, HAL_COMPASS_HMC5843_I2C_ADDR)); + if (backend) { + _add_backend(backend); + hal.console->printf("HMC5843: External compass detected\n"); + } else { + hal.console->printf("HMC5843: External compass not detected\n"); + } + + backend = AP_Compass_AK8963::probe_mpu9250(*this, 0); + if (backend) { + _add_backend(backend); + hal.console->printf("AK8953: Onboard compass detected\n"); + } else { + hal.console->printf("AK8953: Onboard compass not detected\n"); + } + + backend = AP_Compass_AK8963::probe_mpu9250(*this, 1); + if (backend) { + _add_backend(backend); + hal.console->printf("AK8953: External compass detected\n"); + } else { + hal.console->printf("AK8953: External compass not detected\n"); + } #elif HAL_COMPASS_DEFAULT == HAL_COMPASS_AK8963_MPU9250 _add_backend(AP_Compass_AK8963::probe_mpu9250(*this, 0)); #elif HAL_COMPASS_DEFAULT == HAL_COMPASS_HMC5843