Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/proffan/icm426xx
Rust driver for ICM426xx series IMUs.
https://github.com/proffan/icm426xx
Last synced: about 1 month ago
JSON representation
Rust driver for ICM426xx series IMUs.
- Host: GitHub
- URL: https://github.com/proffan/icm426xx
- Owner: ProfFan
- Created: 2024-07-18T04:35:38.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-27T18:31:56.000Z (5 months ago)
- Last Synced: 2024-10-31T11:55:33.052Z (about 2 months ago)
- Language: Rust
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `icm426xx` - ICM-426xx 6-axis motion sensor driver in Rust
[![crates.io](https://img.shields.io/crates/v/icm426xx.svg)](https://crates.io/crates/icm426xx)
[![docs.rs](https://docs.rs/icm426xx/badge.svg)](https://docs.rs/icm426xx)This is a platform agnostic Rust driver for the ICM-426xx 6-axis motion sensor using the `embedded-hal` traits.
Currently supported devices:
- ICM-42688-P
We support both the I2C and SPI interface, but currently only the SPI interface is tested. PRs are welcome!
Similarly, we support both the async and blocking interface, but currently only the async interface is tested.
Only the FIFO-based, 20-bit data mode is supported. Please open an issue if you need support for other modes.
## Usage
```rust
use async_std::prelude::*; // Just for the runtime
use embedded_hal_mock::eh1::spi::{Mock as SpiMock, Transaction as SpiTransaction};
use embedded_hal_mock::eh1::digital::Mock as PinMock;
use embedded_hal_mock::eh1::digital::{State as PinState, Transaction as PinTransaction};
use embedded_hal_mock::eh1::delay::NoopDelay as Delay;
#[async_std::main]
async fn main() {
let spi = SpiMock::new(&[]);
let mut pin = PinMock::new(&[PinTransaction::set(PinState::High)]);
let spidev =
embedded_hal_bus::spi::ExclusiveDevice::new_no_delay(spi, pin.clone()).unwrap();let mut icm = icm426xx::ICM42688::new(spidev);
let mut icm = icm.initialize(Delay).await.unwrap();
let mut bank = icm.ll().bank::<{ icm426xx::register_bank::BANK0 }>();// print WHO_AM_I register
let who_am_i = bank.who_am_i().async_read().await;
loop {
let fifo_count = icm.read_fifo_count().await;
let mut fifo_buffer = [0u32; 128];
let num_read = icm.read_fifo(&mut fifo_buffer).await.unwrap();
}
}
```## LICENSE
MIT OR Apache-2.0