M5Unit-IMU 0.0.2 git rev:e5b00aa
Loading...
Searching...
No Matches
unit_mpu9250.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
15#ifndef M5_UNIT_IMU_UNIT_UNIT_MPU9250_HPP
16#define M5_UNIT_IMU_UNIT_UNIT_MPU9250_HPP
17
18#include "unit_mpu6500.hpp"
19#include "unit_ak8963.hpp"
20
21namespace m5 {
22namespace unit {
23
28class UnitMPU9250 : public UnitMPU6500 {
29 M5_UNIT_COMPONENT_HPP_BUILDER(UnitMPU9250, 0x68);
30
31public:
35 explicit UnitMPU9250(const uint8_t addr = DEFAULT_ADDRESS, const uint8_t mag_addr = 0x0C);
37 virtual ~UnitMPU9250()
38 {
39 }
40
43 {
44 return _mag;
45 }
46
48 virtual bool begin() override;
49
50protected:
51 // Only a real MPU9250's accel/gyro die (WHO_AM_I 0x71) is accepted here
52 inline bool accepts_whoami(const uint8_t id) const override
53 {
54 return id == 0x71;
55 }
58 virtual bool start_periodic_measurement(const mpu6886::AccelRange accel_range, const mpu6886::GyroRange gyro_range,
59 const mpu6886::Dlpf dlpf, const uint8_t sample_rate_div) override;
61 virtual std::shared_ptr<Adapter> ensure_adapter(const uint8_t ch) override;
62
63private:
64 UnitAK8963 _mag;
65};
66
67} // namespace unit
68} // namespace m5
69#endif
3-axis magnetometer unit. No standalone GROVE unit exists; it is the magnetometer embedded in the MPU...
Definition unit_ak8963.hpp:31
TDK InvenSense MPU-6500 6-axis core (accel + gyro + temp)
Definition unit_mpu6500.hpp:24
TDK InvenSense MPU-9250 9-axis IMU. Accel/gyro/temp (this unit itself) + AK8963 mag (mag()).
Definition unit_mpu9250.hpp:28
UnitMPU9250(const uint8_t addr=DEFAULT_ADDRESS, const uint8_t mag_addr=0x0C)
Construct with the MPU9250's accel/gyro address and the internal AK8963 mag address.
Definition unit_mpu9250.cpp:24
UnitAK8963 & mag()
Magnetometer sub-unit (add to an AhrsController for Mag). Accel/gyro/temp is this unit itself.
Definition unit_mpu9250.hpp:42
virtual ~UnitMPU9250()
Destructor.
Definition unit_mpu9250.hpp:37
virtual bool begin() override
Begin the accel/gyro die, then open the aux bypass. The framework begins the mag child next.
Definition unit_mpu9250.cpp:62
bool accepts_whoami(const uint8_t id) const override
Accepted WHO_AM_I id(s) for this chip; begin() rejects the device unless this returns true.
Definition unit_mpu9250.hpp:52
virtual std::shared_ptr< Adapter > ensure_adapter(const uint8_t ch) override
Share this composite's bus with the mag child, duplicated at the child's address.
Definition unit_mpu9250.cpp:34
Top level namespace of M5Stack.
Definition ahrs_controller.cpp:26
Unit-related namespace.
UnitAK8963 (3-axis magnetometer) unit component.
UnitMPU6500 (TDK InvenSense 6-axis IMU core)
AccelRange
Accelerometer full scale range (register value = enum << 3)
Definition unit_mpu6886_data.hpp:24
GyroRange
Gyroscope full scale range (register value = enum << 3)
Definition unit_mpu6886_data.hpp:35
Dlpf
Gyro/temp digital low pass filter (REG_CONFIG reg DLPF_CFG, valid when FCHOICE_B=00)
Definition unit_mpu6886_data.hpp:46