AP_COMPASS: fix errors in addition of alternate LIS3MDL I2C address

testing shows ROTATION_YAW_90 is correct for mRo Neo M8N GPS/compass
This commit is contained in:
Mark Whitehorn 2017-07-28 15:18:07 -06:00 committed by Andrew Tridgell
parent a6e9baa8f6
commit 3642ecd9ef
2 changed files with 11 additions and 8 deletions

View File

@ -593,21 +593,22 @@ void Compass::_detect_backends(void)
both_i2c_external, ROTATION_NONE), both_i2c_external, ROTATION_NONE),
AP_Compass_AK09916::name, true); AP_Compass_AK09916::name, true);
// lis3mdl // lis3mdl on bus 0 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);
ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(0, HAL_COMPASS_LIS3MDL_I2C_ADDR), 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), both_i2c_external, both_i2c_external?ROTATION_YAW_90:ROTATION_NONE),
AP_Compass_LIS3MDL::name, both_i2c_external); 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), ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(1, HAL_COMPASS_LIS3MDL_I2C_ADDR),
true, ROTATION_YAW_90), true, ROTATION_YAW_90),
AP_Compass_LIS3MDL::name, true); 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), ADD_BACKEND(DRIVER_LIS3MDL, AP_Compass_LIS3MDL::probe(*this, hal.i2c_mgr->get_device(1, HAL_COMPASS_LIS3MDL_I2C_ADDR2),
true, ROTATION_YAW_90), true, ROTATION_YAW_90),
AP_Compass_LIS3MDL::name, true); AP_Compass_LIS3MDL::name, true);

View File

@ -23,8 +23,10 @@
#include "AP_Compass_Backend.h" #include "AP_Compass_Backend.h"
#ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR #ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR
// this can also be on 0x1e
# define HAL_COMPASS_LIS3MDL_I2C_ADDR 0x1c # define HAL_COMPASS_LIS3MDL_I2C_ADDR 0x1c
#endif
#ifndef HAL_COMPASS_LIS3MDL_I2C_ADDR2
# define HAL_COMPASS_LIS3MDL_I2C_ADDR2 0x1e # define HAL_COMPASS_LIS3MDL_I2C_ADDR2 0x1e
#endif #endif