M5Unit-IMU 0.0.2 git rev:e5b00aa
Loading...
Searching...
No Matches
m5::unit::UnitMPU9250 Class Reference

TDK InvenSense MPU-9250 9-axis IMU. Accel/gyro/temp (this unit itself) + AK8963 mag (mag()). More...

#include <unit_mpu9250.hpp>

Inheritance diagram for m5::unit::UnitMPU9250:
m5::unit::UnitMPU6500 m5::unit::UnitMPU6xxx m5::imu::IMUDataSource

Public Member Functions

 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.
 
virtual ~UnitMPU9250 ()
 Destructor.
 
UnitAK8963 & mag ()
 Magnetometer sub-unit (add to an AhrsController for Mag). Accel/gyro/temp is this unit itself.
 
virtual bool begin () override
 Begin the accel/gyro die, then open the aux bypass. The framework begins the mag child next.
 
- Public Member Functions inherited from m5::unit::UnitMPU6500
 UnitMPU6500 (const uint8_t addr=DEFAULT_ADDRESS)
 
- Public Member Functions inherited from m5::unit::UnitMPU6xxx
virtual void update (const bool force=false) override
 Update the unit.
 
config_t config () const
 Gets the configuration.
 
void config (const config_t &cfg)
 Set the configuration.
 
bool writeAccelRange (const mpu6886::AccelRange range)
 Write the accelerometer range.
 
bool writeGyroRange (const mpu6886::GyroRange range)
 Write the gyroscope range.
 
bool readAccelRange (mpu6886::AccelRange &range)
 Read the accelerometer range from the device (REG_ACCEL_CONFIG bits[4:3])
 
bool readGyroRange (mpu6886::GyroRange &range)
 Read the gyroscope range from the device (REG_GYRO_CONFIG bits[4:3])
 
bool writeSampleRateDiv (const uint8_t div)
 Write the sample rate divider.
 
bool readSampleRateDiv (uint8_t &div)
 Read the sample rate divider from the device (REG_SMPLRT_DIV)
 
bool writeDlpf (const mpu6886::Dlpf dlpf)
 Write the digital low-pass filter bandwidth.
 
bool readDlpf (mpu6886::Dlpf &dlpf)
 Read the digital low-pass filter bandwidth from the device (REG_CONFIG bits[2:0])
 
bool softReset ()
 Soft reset (REG_PWR_MGMT_1 DEVICE_RESET), leaving the chip initialized but unconfigured and stopped.
 
bool startPeriodicMeasurement (const mpu6886::AccelRange accel_range, const mpu6886::GyroRange gyro_range, const mpu6886::Dlpf dlpf, const uint8_t sample_rate_div)
 Start periodic measurement.
 
bool startPeriodicMeasurement ()
 Start periodic measurement in the current settings.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
bool sleep () override
 Put the chip to sleep (REG_PWR_MGMT_1 SLEEP)
 
bool wakeup () override
 Wake the chip from sleep()
 
virtual m5::imu::Capability imuSpec () const override
 Capability of this unit.
 
virtual m5::imu::Capability readImuRaw (m5::imu::imu_raw_data_t &out) override
 Read the latest raw IMU data.
 
virtual void imuConvertParam (m5::imu::imu_convert_param_t &out) const override
 Gets the conversion parameters for raw IMU data.
 

Protected Member Functions

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.
 
virtual bool start_periodic_measurement (const mpu6886::AccelRange accel_range, const mpu6886::GyroRange gyro_range, const mpu6886::Dlpf dlpf, const uint8_t sample_rate_div) override
 Base config + re-open the aux bypass (the base writes INT_PIN_CFG=0xC0, which closes it and would cut off the AK8963 child at 0x0C on a stop -> start cycle)
 
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.
 
- Protected Member Functions inherited from m5::unit::UnitMPU6500
float temperature_res () const override
 Temperature conversion: degC per LSB (imu_convert_param_t::temp_res)
 
float temperature_offset () const override
 Temperature conversion: degC offset (imu_convert_param_t::temp_offset)
 
- Protected Member Functions inherited from m5::unit::UnitMPU6xxx
 UnitMPU6xxx (const uint8_t addr=DEFAULT_ADDRESS)
 Protected: UnitMPU6xxx is abstract, constructed only by concrete derived chips.
 
bool start_periodic_measurement ()
 
bool stop_periodic_measurement ()
 
bool read_measurement (mpu6886::Data &d)
 
bool write_register8_verified (const uint8_t reg, const uint8_t val)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitMPU6xxx, mpu6886::Data)
 

Detailed Description

TDK InvenSense MPU-9250 9-axis IMU. Accel/gyro/temp (this unit itself) + AK8963 mag (mag()).

Constructor & Destructor Documentation

◆ UnitMPU9250()

m5::unit::UnitMPU9250::UnitMPU9250 ( const uint8_t addr = DEFAULT_ADDRESS,
const uint8_t mag_addr = 0x0C )
explicit

Construct with the MPU9250's accel/gyro address and the internal AK8963 mag address.

Parameters
[in]addrMPU9250 accel/gyro I2C address (defaults to the chip's factory address)
[in]mag_addrAK8963 magnetometer I2C address (defaults to 0x0C, its factory address)

Member Function Documentation

◆ accepts_whoami()

bool m5::unit::UnitMPU9250::accepts_whoami ( const uint8_t id) const
inlineoverrideprotectedvirtual

Accepted WHO_AM_I id(s) for this chip; begin() rejects the device unless this returns true.

Reimplemented from m5::unit::UnitMPU6500.

◆ begin()

bool m5::unit::UnitMPU9250::begin ( )
overridevirtual

Begin the accel/gyro die, then open the aux bypass. The framework begins the mag child next.

Reimplemented from m5::unit::UnitMPU6xxx.

◆ start_periodic_measurement()

bool m5::unit::UnitMPU9250::start_periodic_measurement ( const mpu6886::AccelRange accel_range,
const mpu6886::GyroRange gyro_range,
const mpu6886::Dlpf dlpf,
const uint8_t sample_rate_div )
overrideprotectedvirtual

Base config + re-open the aux bypass (the base writes INT_PIN_CFG=0xC0, which closes it and would cut off the AK8963 child at 0x0C on a stop -> start cycle)

Reimplemented from m5::unit::UnitMPU6xxx.