Crates.io | bmi323 |
lib.rs | bmi323 |
version | 0.1.0 |
source | src |
created_at | 2024-07-06 18:23:56.376472 |
updated_at | 2024-07-06 18:23:56.376472 |
description | Platform agnostic Rust driver for the BMI323 IMU. |
homepage | https://github.com/wyatt-mattas/bmi323-rs/ |
repository | https://github.com/wyatt-mattas/bmi323-rs/ |
max_upload_size | |
id | 1294275 |
size | 34,582 |
This is a Rust driver for the Bosch BMI323 Inertial Measurement Unit (IMU). The BMI323 is a highly integrated, low power IMU that provides precise acceleration and angular rate measurements.
Add this to your Cargo.toml
:
[dependencies]
bmi323 = "0.1.0" # Replace with the actual version
Here's a basic example of how to use the driver:
use bmi323::{Bmi323, AccelConfig, GyroConfig, OutputDataRate, AccelerometerRange, GyroscopeRange};
use embedded_hal::blocking::i2c::I2c;
fn main() {
// Initialize your I2C or SPI interface
let i2c = // ... initialize your I2C interface
let delay = // ... initialize your delay provider
// Create a new BMI323 instance
let mut imu = Bmi323::new_with_i2c(i2c, 0x68, delay);
// Initialize the device
imu.init().unwrap();
// Configure accelerometer
let accel_config = AccelConfig::builder()
.odr(OutputDataRate::Odr100hz)
.range(AccelerometerRange::G8)
.build();
imu.set_accel_config(accel_config).unwrap();
// Configure gyroscope
let gyro_config = GyroConfig::builder()
.odr(OutputDataRate::Odr100hz)
.range(GyroscopeRange::DPS2000)
.build();
imu.set_gyro_config(gyro_config).unwrap();
loop {
// Read accelerometer data
let accel_data = imu.read_accel_data_scaled().unwrap();
println!("Acceleration: x={}, y={}, z={}", accel_data.x, accel_data.y, accel_data.z);
// Read gyroscope data
let gyro_data = imu.read_gyro_data_scaled().unwrap();
println!("Angular velocity: x={}, y={}, z={}", gyro_data.x, gyro_data.y, gyro_data.z);
}
}
This project is licensed under Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
Contributions are welcome! Please feel free to submit a Pull Request.