From bdc36349b44454f13d765d44e81d44c1bd2d20ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Mon, 28 Sep 2015 17:46:19 -0300 Subject: [PATCH] AP_Compass: AK8963: Add support to use a AK8963 behind of a MPU9250 over I2C To be able to use AK8963 connected to the auxiliary I2C bus of a MPU9250 we need first initialize it. --- libraries/AP_Compass/AP_Compass_AK8963.cpp | 9 +++++++++ libraries/AP_Compass/AP_Compass_AK8963.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/libraries/AP_Compass/AP_Compass_AK8963.cpp b/libraries/AP_Compass/AP_Compass_AK8963.cpp index 6744d133b1..567c0d294e 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.cpp +++ b/libraries/AP_Compass/AP_Compass_AK8963.cpp @@ -89,6 +89,15 @@ AP_Compass_Backend *AP_Compass_AK8963::detect_i2c(Compass &compass, return _detect(compass, bus); } +AP_Compass_Backend *AP_Compass_AK8963::detect_mpu9250_i2c(Compass &compass, + AP_HAL::I2CDriver *i2c, + uint8_t addr) +{ + AP_InertialSensor &ins = *AP_InertialSensor::get_instance(); + ins.detect_backends(); + return detect_i2c(compass, i2c, addr); +} + AP_Compass_Backend *AP_Compass_AK8963::_detect(Compass &compass, AP_AK8963_SerialBus *bus) { diff --git a/libraries/AP_Compass/AP_Compass_AK8963.h b/libraries/AP_Compass/AP_Compass_AK8963.h index e979b956d9..6a62c820bc 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.h +++ b/libraries/AP_Compass/AP_Compass_AK8963.h @@ -39,6 +39,9 @@ class AP_Compass_AK8963 : public AP_Compass_Backend { public: static AP_Compass_Backend *detect_mpu9250(Compass &compass, uint8_t mpu9250_instance); + static AP_Compass_Backend *detect_mpu9250_i2c(Compass &compass, + AP_HAL::I2CDriver *i2c, + uint8_t addr); static AP_Compass_Backend *detect_i2c(Compass &compass, AP_HAL::I2CDriver *i2c, uint8_t addr);