#arm #cortex-m #stm32 #hal

mpu9250

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

31 releases (11 breaking)

0.20.0 Sep 17, 2019
0.12.2 Jun 4, 2019
0.12.0 May 12, 2019
0.10.0 Mar 19, 2019
0.7.3 Oct 7, 2018

#15 in Embedded development

Download history 221/week @ 2019-12-07 4/week @ 2019-12-14 5/week @ 2019-12-21 33/week @ 2019-12-28 4/week @ 2020-01-04 335/week @ 2020-01-11 62/week @ 2020-01-18 1/week @ 2020-01-25 1/week @ 2020-02-01 31/week @ 2020-02-08 2/week @ 2020-02-15 138/week @ 2020-02-22 1/week @ 2020-02-29 62/week @ 2020-03-07 31/week @ 2020-03-14 157/week @ 2020-03-21

321 downloads per month

MIT/Apache

75KB
1.5K SLoC

mpu9250

no_std driver for the MPU9250 (and some MPU* devices) & onboard AK8963 (accelerometer + gyroscope + magnetometer IMU).

Build Status

What works

  • Reading the accelerometer, gyroscope, temperature sensor, and magnetrometer: both raw and scaled and converted values.
  • Setting DLPF, reading scales, sample rate divisor.
  • Reading the WHO_AM_I registers of mpu9250 and ak8963.
  • Getting resolutions and factory sensitivities.

Supported chips

  • MPU9250 -- Imu and Marg;
  • MPU9255 -- Imu and Marg;
  • MPU6500 -- Imu only.

Notes

MPU9255 has some extra capability in the ASIC that allows some additional gesture control but otherwise this chip is identical to the MPU9250.

Basic usage

Include library as a dependency in your Cargo.toml crates.io:

[dependencies.mpu9250]
version = "<version>"

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

extern crate mpu9250; // or just use mpu9250; if 2018 edition is used.

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

More examples

Number of examples can be found in proving-ground repo. Examples include: reading temperature, calibrating magnetrometer, reading all sensors.

Experimental I2C support

Expiremntal I2C support is enabled via i2c feature flag. When enabled, SPI support will be deactivated and type of mpu9250 driver will change from Mpu9250<SpiDevice<SPI, NCS>, MODE> will change to Mpu9250<I2cDevice<I2C>, Imu>.

The MPU9250 currently supports an IMU-only configuration. See the BeagleBone Blue example for a demonstration. Support for the AK8963 is a WPI.

Documentation

API Docs available on docs.rs.

License

Licensed under either of

at your option.

Testimonials

Started off as a fork of japaric's mpu9250 repo.

Dependencies

~165KB