diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index 941406b6fc..9eb7864ee7 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -593,21 +593,22 @@ void Compass::_detect_backends(void) both_i2c_external, ROTATION_NONE), AP_Compass_AK09916::name, true); - // lis3mdl - ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(1, HAL_COMPASS_LIS3MDL_I2C_ADDR), - true, ROTATION_YAW_90), - AP_Compass_LIS3MDL::name, true); - + // lis3mdl on bus 0 with default address ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(0, HAL_COMPASS_LIS3MDL_I2C_ADDR), both_i2c_external, both_i2c_external?ROTATION_YAW_90:ROTATION_NONE), AP_Compass_LIS3MDL::name, both_i2c_external); - // external lis3mdl in mRo Neo-M8N GPS module + // lis3mdl on bus 0 with alternate address + ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(0, HAL_COMPASS_LIS3MDL_I2C_ADDR2), + both_i2c_external, both_i2c_external?ROTATION_YAW_90:ROTATION_NONE), + AP_Compass_LIS3MDL::name, both_i2c_external); + + // external lis3mdl on bus 1 with default address ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(1, HAL_COMPASS_LIS3MDL_I2C_ADDR), true, ROTATION_YAW_90), AP_Compass_LIS3MDL::name, true); - // external lis3mdl in mRo Neo-M8N GPS module (alternate I2C address) + // external lis3mdl on bus 1 with alternate address ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(1, HAL_COMPASS_LIS3MDL_I2C_ADDR2), true, ROTATION_YAW_90), AP_Compass_LIS3MDL::name, true); diff --git a/libraries/AP_Compass/AP_Compass_LIS3MDL.h b/libraries/AP_Compass/AP_Compass_LIS3MDL.h index d208a025bf..bb5b0f1249 100644 --- a/libraries/AP_Compass/AP_Compass_LIS3MDL.h +++ b/libraries/AP_Compass/AP_Compass_LIS3MDL.h @@ -23,8 +23,10 @@ #include "AP_Compass_Backend.h" #ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR -// this can also be on 0x1e # define HAL_COMPASS_LIS3MDL_I2C_ADDR 0x1c +#endif + +#ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR2 # define HAL_COMPASS_LIS3MDL_I2C_ADDR2 0x1e #endif