Fix IMU magnetometer diagnostics

This commit is contained in:
Josh
2026-04-24 00:31:47 +02:00
parent 53ba59e4cd
commit 92a2ccc689
10 changed files with 828 additions and 221 deletions
+15 -7
View File
@@ -115,8 +115,10 @@ class AK09918 {
AK09918_err_type_t isDataSkip();
// Get magnet data in uT
AK09918_err_type_t getData(int16_t* axis_x, int16_t* axis_y, int16_t* axis_z);
// Get raw I2C magnet data
AK09918_err_type_t getRawData(int16_t* axis_x, int16_t* axis_y, int16_t* axis_z);
// Get raw I2C magnet data
AK09918_err_type_t getRawData(int16_t* axis_x, int16_t* axis_y, int16_t* axis_z);
// Diagnostic/fallback read without checking ST1.DRDY first.
AK09918_err_type_t getRawDataUnchecked(int16_t* axis_x, int16_t* axis_y, int16_t* axis_z);
// Return the working mode of AK09918
@@ -129,10 +131,16 @@ class AK09918 {
AK09918_err_type_t reset();
// Get details of AK09918_err_type_t
String strError(AK09918_err_type_t err);
// Get device ID
uint16_t getDeviceID();
// Get device ID
uint16_t getDeviceID();
// Set/get 7-bit I2C address. Most AK09918 boards use 0x0C; some docs list
// 8-bit write/read addresses 0x0C/0x0D, which corresponds to 7-bit 0x06.
void setAddress(uint8_t addr);
uint8_t getAddress();
// Read CNTL2 register directly (0x08=continuous100Hz, 0x00=power-down)
uint8_t getRawMode();
// Read any register by address for diagnostics.
uint8_t readRegister(uint8_t reg);
private:
uint8_t _getRawMode();
@@ -146,4 +154,4 @@ class AK09918 {
};
#endif // __IMU_9DOF_AK09918_H__
#endif // __IMU_9DOF_AK09918_H__