From 2a662793c2be2ffbc71c14459393273c49b88502 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 30 Jul 2020 15:29:55 +1000 Subject: [PATCH] AP_Compass: support probing RM3100 on all 4 addresses --- libraries/AP_Compass/AP_Compass.cpp | 19 +++++++++++++++---- libraries/AP_Compass/AP_Compass_RM3100.h | 5 ++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass.cpp b/libraries/AP_Compass/AP_Compass.cpp index b3b67a3200..e80c54cd07 100644 --- a/libraries/AP_Compass/AP_Compass.cpp +++ b/libraries/AP_Compass/AP_Compass.cpp @@ -1103,14 +1103,25 @@ void Compass::_probe_external_i2c_compasses(void) true, ROTATION_NONE)); } +#ifdef HAL_COMPASS_RM3100_I2C_ADDR + const uint8_t rm3100_addresses[] = { HAL_COMPASS_RM3100_I2C_ADDR }; +#else + // RM3100 can be on 4 different addresses + const uint8_t rm3100_addresses[] = { HAL_COMPASS_RM3100_I2C_ADDR1, + HAL_COMPASS_RM3100_I2C_ADDR2, + HAL_COMPASS_RM3100_I2C_ADDR3, + HAL_COMPASS_RM3100_I2C_ADDR4 }; +#endif // external i2c bus FOREACH_I2C_EXTERNAL(i) { - ADD_BACKEND(DRIVER_RM3100, AP_Compass_RM3100::probe(GET_I2C_DEVICE(i, HAL_COMPASS_RM3100_I2C_ADDR), - true, ROTATION_NONE)); + for (uint8_t j=0; j