Skip to content

Commit

Permalink
AP_Compass: probe DroneCAN compasses before I2C
Browse files Browse the repository at this point in the history
it is highly likely that a user with a DroneCAN compass will want it
to be earlier in the dev list than i2c or spi compasses
  • Loading branch information
tridge committed Oct 28, 2023
1 parent 4838576 commit afdd049
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libraries/AP_Compass/AP_Compass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,13 @@ void Compass::_detect_backends(void)
ADD_BACKEND(DRIVER_SITL, new AP_Compass_SITL());
#endif

#if AP_COMPASS_DRONECAN_ENABLED
// probe DroneCAN before I2C and SPI so that DroneCAN compasses
// default to first in the list for a new board
probe_dronecan_compasses();
CHECK_UNREG_LIMIT_RETURN;
#endif

#ifdef HAL_PROBE_EXTERNAL_I2C_COMPASSES
// allow boards to ask for external probing of all i2c compass types in hwdef.dat
_probe_external_i2c_compasses();
Expand All @@ -1321,12 +1328,10 @@ void Compass::_detect_backends(void)
}
#endif

// finally look for i2c and spi compasses not found yet
CHECK_UNREG_LIMIT_RETURN;
probe_i2c_spi_compasses();

#if AP_COMPASS_DRONECAN_ENABLED
probe_dronecan_compasses();
#endif

if (_backend_count == 0 ||
_compass_count == 0) {
DEV_PRINTF("No Compass backends available\n");
Expand Down

0 comments on commit afdd049

Please sign in to comment.