BMI323 Rust Driver
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.
Features
- Support for both I2C and SPI interfaces
- Configurable accelerometer and gyroscope settings
- Reading raw and scaled sensor data
- Error handling and device initialization
Usage
Add this to your Cargo.toml:
[dependencies]
bmi323 = "0.1.0"
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() {
let i2c = let delay =
let mut imu = Bmi323::new_with_i2c(i2c, 0x68, delay);
imu.init().unwrap();
let accel_config = AccelConfig::builder()
.odr(OutputDataRate::Odr100hz)
.range(AccelerometerRange::G8)
.build();
imu.set_accel_config(accel_config).unwrap();
let gyro_config = GyroConfig::builder()
.odr(OutputDataRate::Odr100hz)
.range(GyroscopeRange::DPS2000)
.build();
imu.set_gyro_config(gyro_config).unwrap();
loop {
let accel_data = imu.read_accel_data_scaled().unwrap();
println!("Acceleration: x={}, y={}, z={}", accel_data.x, accel_data.y, accel_data.z);
let gyro_data = imu.read_gyro_data_scaled().unwrap();
println!("Angular velocity: x={}, y={}, z={}", gyro_data.x, gyro_data.y, gyro_data.z);
}
}
License
This project is licensed under Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
References