Crate mpu9250

Source
Expand description

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);
// One can also use conf module to supply configuration:
let mut mpu =
    Mpu9250::marg(spi,
                  ncs,
                  &mut delay,
                  MpuConfig::marg().mag_scale(conf::MagScale::_14BITS))?;

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

§References

Structs§

DmpConfiguration
Dmp configuration
DmpFeatures
Dmp features to enable, default with raw gyro and accel and 6 axes quaternion
DmpMeasurement
DMP measurement scaled with respective scales and converted to appropriate units. Each measurement will be present only if the corresponding features is activated in dmp features
I2cDevice
An I2C device. Use I2CDevice when the MPU9250 is connected via I2C
Imu
Accelerometer + Gyroscope + Temperature Sensor
ImuMeasurements
Scaled IMU measurements converted to units
InterruptConfig
Interrupt configuration Defaults: active high, push-pull, 50 us pulse, cleared only by reading INT_STATUS
InterruptEnable
Enable interrupt for:
Marg
Magnetometer + Accelerometer + Gyroscope + Temperature Sensor
MargMeasurements
MARG measurements scaled with respective scales and converted to appropriate units.
Mpu9250
MPU9250 driver
MpuConfig
Configuration of MPU9250
SpiDevice
A SPI device. Use a SPI device when the MPU9250 is connected via SPI
UnscaledDmpMeasurement
DMP measurement scaled with respective scales and converted to appropriate units. Each measurement will be present only if the corresponding features is activated in dmp features
UnscaledImuMeasurements
Unscaled IMU measurements (LSB)
UnscaledMargMeasurements
Unscaled MARG measurements (LSB)

Enums§

AccelDataRate
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;
DmpRate
Dmp data output rate, default 100Hz
Error
MPU Error
GyroScale
Gyroscope reading full scale configuration; default: +250 dps.
GyroTempDataRate
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.
I2CError
I2C Error
MagScale
Gyroscope reading full scale configuration; default: 0.6 mG per LSB
MpuXDevice
Suported MPUx devices
Orientation
DMP base orienatation, default Z axe pointing up
SpiError
SPI Error

Constants§

G
G constant
MODE
SPI mode

Traits§

Device
An MPU communication device abstraction
NineDOFDevice
The trait describes how to aquire 9 degrees-of-freedom measurements (plug a temperature reading) from an MPU