[−][src]Crate mpu9250
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
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 |
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 [ |
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. |
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 [ |
MagScale | Gyroscope reading full scale configuration; default: 0.6 mG per LSB |
MpuXDevice | Suported MPUx devices |
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 |