Browse Source

AP_Compass: added AK09918 support

minor update over AK09916
gps-1.3.1
Andrew Tridgell 3 years ago
parent
commit
613f970870
  1. 15
      libraries/AP_Compass/AP_Compass_AK09916.cpp
  2. 1
      libraries/AP_Compass/AP_Compass_AK09916.h
  3. 1
      libraries/AP_Compass/AP_Compass_Backend.h

15
libraries/AP_Compass/AP_Compass_AK09916.cpp

@ -50,6 +50,7 @@ extern const AP_HAL::HAL &hal; @@ -50,6 +50,7 @@ extern const AP_HAL::HAL &hal;
#define ICM_WHOAMI_VAL 0xEA
#define AK09916_Device_ID 0x09
#define AK09918_Device_ID 0x0c
#define AK09916_MILLIGAUSS_SCALE 10.0f
extern const AP_HAL::HAL &hal;
@ -227,7 +228,7 @@ bool AP_Compass_AK09916::init() @@ -227,7 +228,7 @@ bool AP_Compass_AK09916::init()
_initialized = true;
/* register the compass instance in the frontend */
_bus->set_device_type(DEVTYPE_AK09916);
_bus->set_device_type(_devtype);
if (!register_compass(_bus->get_bus_id(), _compass_instance)) {
goto fail;
}
@ -315,9 +316,15 @@ bool AP_Compass_AK09916::_check_id() @@ -315,9 +316,15 @@ bool AP_Compass_AK09916::_check_id()
uint8_t deviceid = 0;
/* Read AK09916's id */
if (_bus->register_read(REG_DEVICE_ID, &deviceid) &&
deviceid == AK09916_Device_ID) {
return true;
if (_bus->register_read(REG_DEVICE_ID, &deviceid)) {
switch (deviceid) {
case AK09916_Device_ID:
_devtype = DEVTYPE_AK09916;
return true;
case AK09918_Device_ID:
_devtype = DEVTYPE_AK09918;
return true;
}
}
}

1
libraries/AP_Compass/AP_Compass_AK09916.h

@ -82,6 +82,7 @@ private: @@ -82,6 +82,7 @@ private:
uint8_t _compass_instance;
bool _initialized;
enum Rotation _rotation;
enum AP_Compass_Backend::DevTypes _devtype;
};

1
libraries/AP_Compass/AP_Compass_Backend.h

@ -65,6 +65,7 @@ public: @@ -65,6 +65,7 @@ public:
DEVTYPE_RM3100 = 0x11,
DEVTYPE_RM3100_2 = 0x12, // unused, past mistake
DEVTYPE_MMC5883 = 0x13,
DEVTYPE_AK09918 = 0x14,
};
#if HAL_MSP_COMPASS_ENABLED

Loading…
Cancel
Save