17#ifndef M5_UNIT_IMU_IMU_MAG_DETECT_HPP
18#define M5_UNIT_IMU_IMU_MAG_DETECT_HPP
46template <
class ReadReg>
50 if (read(
static_cast<uint8_t
>(0x0C),
static_cast<uint8_t
>(0x00),
id) &&
id == 0x48) {
51 return MagKind::AK8963;
53 if (read(
static_cast<uint8_t
>(0x0E),
static_cast<uint8_t
>(0x07),
id) &&
id == 0xC4) {
54 return MagKind::MAG3110;
56 if (read(
static_cast<uint8_t
>(0x10),
static_cast<uint8_t
>(0x40),
id)) {
57 return MagKind::BMM150;
74template <
class ReadReg,
class WriteReg>
78 if (!read(
static_cast<uint8_t
>(0x68),
static_cast<uint8_t
>(0x75),
id) ||
id != 0x71) {
82 if (!read(
static_cast<uint8_t
>(0x68),
static_cast<uint8_t
>(0x6A), user_ctrl)) {
85 user_ctrl =
static_cast<uint8_t
>(user_ctrl & ~0x20);
86 if (!write(
static_cast<uint8_t
>(0x68),
static_cast<uint8_t
>(0x6A), user_ctrl)) {
89 if (!write(
static_cast<uint8_t
>(0x68),
static_cast<uint8_t
>(0x37),
static_cast<uint8_t
>(0x02))) {
@ None
No accel/gyro responded (e.g. an IMU-less M5Stack Basic)
bool enableAuxBypass(ReadReg read, WriteReg write)
Open the MPU9250 I2C bypass so its internal AK8963 appears at 0x0C on the host bus.
Definition mag_detect.hpp:75
MagKind detectBuiltinMag(ReadReg read)
Probe the internal bus for a built-in magnetometer.
Definition mag_detect.hpp:47
MagKind
Which built-in magnetometer a classic M5Stack host carries.
Definition mag_detect.hpp:27
@ BMM150
Bosch BMM150 at 0x10.
@ MAG3110
NXP MAG3110 at 0x0E (original 2017 M5Stack Gray, paired with an MPU6050)
@ AK8963
AKM AK8963 (MPU9250-internal) at 0x0C.
Top level namespace of M5Stack.
Definition ahrs_controller.cpp:26