Crate mpu9250[][src]

no_std driver for the MPU9250 & onboard AK8963 (accelerometer + gyroscope + magnetometer IMU)

Connections

  • NCS
  • SCL = SCK
  • SDA = SDI = MOSI
  • AD0 = SDO = MISO

Usage

Use embedded-hal implementation to get SPI, NCS, and delay, then create mpu handle

// to create sensor with mag support and default configuration:
let mut mpu = Mpu9250::marg_default(spi, ncs, &mut delay)?;
// to create sensor without mag support and default configuration:
let mut mpu = Mpu9250::imu_default(spi, ncs, &mut delay)?;
// to get all supported measurements:
let all = mpu.all()?;
println!("{:?}", all);

More examples (for stm32) in [Proving ground] repo.

References

Structs

Imu

Accelerometer + Gyroscope + Temperature Sensor

ImuMeasurements

Scaled IMU measurements converted to units

Marg

Magnetometer + Accelerometer + Gyroscope + Temperature Sensor

MargMeasurements

MARG measurements scaled with respective scales and converted to appropriate units.

Mpu9250

MPU9250 driver

UnscaledImuMeasurements

Unscaled IMU measurements (LSB)

UnscaledMargMeasurements

Unscaled MARG measurements (LSB)

Enums

AccelDataRateConfig

Controls the accelerometer data rate and bandwidth. Can be either set to FChoice, or to one of the 8 digital low pass filter modes. If the DLPF mode is used rate and bandwith can be further tweaked by Sample Rate Divisor. See page 13 of [Register map] for details. Noise Density for all values is 300 μg/rtHz. Default is dlpf with default dlpf mode.

AccelScale

Accelerometer reading full scale configuration, default: +2g.

Dlpf

Digital low pass filter configuration; default: _0;

Error

MPU Error

GyroScale

Gyroscope reading full scale configuration; default: +250 dps.

GyroTempDataRateConfig

Controls the gyroscope and temperature sensor data rates and bandwidth. Can be either set to one of two FChoices, or to one of the 8 digital low pass filter modes. If the DLPF mode is used rate and bandwith can be further tweaked by Sample Rate Divisor. See page 13 of [Register map] for details. Default is dlpf with default dlpf mode.

MagScale

Gyroscope reading full scale configuration; default: 0.6 mG per LSB

Constants

MODE

SPI mode