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
Dmp configuration
Dmp features to enable, default with raw gyro and accel and 6 axes quaternion
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
An I2C device. Use I2CDevice when the MPU9250 is connected via I2C
Accelerometer + Gyroscope + Temperature Sensor
Scaled IMU measurements converted to units
Interrupt configuration Defaults: active high, push-pull, 50 us pulse, cleared only by reading INT_STATUS
Enable interrupt for:
Magnetometer + Accelerometer + Gyroscope + Temperature Sensor
MARG measurements scaled with respective scales and converted to appropriate units.
MPU9250 driver
Configuration of MPU9250
A SPI device. Use a SPI device when the MPU9250 is connected via SPI
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
Unscaled IMU measurements (LSB)
Unscaled MARG measurements (LSB)
Enums
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.
Accelerometer reading full scale configuration, default: +2g.
Digital low pass filter configuration; default: _0;
Dmp data output rate, default 100Hz
MPU Error
Gyroscope reading full scale configuration; default: +250 dps.
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.
I2C Error
Gyroscope reading full scale configuration; default: 0.6 mG per LSB
Suported MPUx devices
DMP base orienatation, default Z axe pointing up
SPI Error
Constants
Traits
An MPU communication device abstraction
The trait describes how to aquire 9 degrees-of-freedom measurements (plug a temperature reading) from an MPU