Skip to content

Commit

Permalink
AP_Compass: Add in BMM350 Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
cuav-chen2 authored and peterbarker committed Sep 11, 2024
1 parent ead48b6 commit be46b65
Show file tree
Hide file tree
Showing 6 changed files with 631 additions and 1 deletion.
20 changes: 19 additions & 1 deletion libraries/AP_Compass/AP_Compass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "AP_Compass_AK8963.h"
#include "AP_Compass_Backend.h"
#include "AP_Compass_BMM150.h"
#include "AP_Compass_BMM350.h"
#include "AP_Compass_HMC5843.h"
#include "AP_Compass_IST8308.h"
#include "AP_Compass_IST8310.h"
Expand Down Expand Up @@ -515,7 +516,7 @@ const AP_Param::GroupInfo Compass::var_info[] = {
// @Param: DISBLMSK
// @DisplayName: Compass disable driver type mask
// @Description: This is a bitmask of driver types to disable. If a driver type is set in this mask then that driver will not try to find a sensor at startup
// @Bitmask: 0:HMC5883,1:LSM303D,2:AK8963,3:BMM150,4:LSM9DS1,5:LIS3MDL,6:AK09916,7:IST8310,8:ICM20948,9:MMC3416,11:DroneCAN,12:QMC5883,14:MAG3110,15:IST8308,16:RM3100,17:MSP,18:ExternalAHRS
// @Bitmask: 0:HMC5883,1:LSM303D,2:AK8963,3:BMM150,4:LSM9DS1,5:LIS3MDL,6:AK09916,7:IST8310,8:ICM20948,9:MMC3416,11:DroneCAN,12:QMC5883,14:MAG3110,15:IST8308,16:RM3100,17:MSP,18:ExternalAHRS,21:BMM350
// @User: Advanced
AP_GROUPINFO("DISBLMSK", 33, Compass, _driver_type_mask, 0),

Expand Down Expand Up @@ -1313,6 +1314,23 @@ void Compass::_probe_external_i2c_compasses(void)
}
}
#endif // AP_COMPASS_BMM150_ENABLED

#if AP_COMPASS_BMM350_ENABLED
// BMM350 on I2C
FOREACH_I2C_EXTERNAL(i) {
for (uint8_t addr=BMM350_I2C_ADDR_MIN; addr <= BMM350_I2C_ADDR_MAX; addr++) {
ADD_BACKEND(DRIVER_BMM350,
AP_Compass_BMM350::probe(GET_I2C_DEVICE(i, addr), true, ROTATION_NONE));
}
}
#if !defined(HAL_SKIP_AUTO_INTERNAL_I2C_PROBE)
FOREACH_I2C_INTERNAL(i) {
for (uint8_t addr=BMM350_I2C_ADDR_MIN; addr <= BMM350_I2C_ADDR_MAX; addr++) {
ADD_BACKEND(DRIVER_BMM350, AP_Compass_BMM350::probe(GET_I2C_DEVICE(i, addr), all_external, ROTATION_NONE));
}
}
#endif
#endif // AP_COMPASS_BMM350_ENABLED
}

/*
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_Compass/AP_Compass.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ friend class AP_Compass_Backend;
#if AP_COMPASS_QMC5883P_ENABLED
DRIVER_QMC5883P =20,
#endif
#if AP_COMPASS_BMM350_ENABLED
DRIVER_BMM350 =21,
#endif
};

bool _driver_enabled(enum DriverType driver_type);
Expand Down
Loading

0 comments on commit be46b65

Please sign in to comment.