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 committed May 6, 2024
1 parent b66ecd8 commit 654620c
Show file tree
Hide file tree
Showing 8 changed files with 698 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(self,
Feature('Compass', 'AK09916', 'AP_COMPASS_AK09916_ENABLED', 'Enable AK09916 compasses', 1, None),
Feature('Compass', 'AK8963', 'AP_COMPASS_AK8963_ENABLED', 'Enable AK8963 compasses', 1, None),
Feature('Compass', 'BMM150', 'AP_COMPASS_BMM150_ENABLED', 'Enable BMM150 compasses', 1, None),
Feature('Compass', 'BMM350', 'AP_COMPASS_BMM350_ENABLED', 'Enable BMM350 compasses', 1, None),
Feature('Compass', 'EXTERNALAHRS_COMPASS', 'AP_COMPASS_EXTERNALAHRS_ENABLED', 'Enable ExternalAHRS compasses', 0, "AHRS_EXT"), # noqa
Feature('Compass', 'HMC5843', 'AP_COMPASS_HMC5843_ENABLED', 'Enable HMC5843 compasses', 1, None),
Feature('Compass', 'ICM20948', 'AP_COMPASS_ICM20948_ENABLED', 'Enable AK09916 on ICM20948 compasses', 1, "AK09916"),
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/decode_devid.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def num(s):
0x14 : "DEVTYPE_AK09918",
0x15 : "DEVTYPE_AK09915",
0x16 : "DEVTYPE_QMC5883P",
0x17 : "DEVTYPE_BMM350",
}

imu_types = {
Expand Down
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 654620c

Please sign in to comment.