Bosch BMI323 IMU
A no_std, async Rust driver for the Bosch BMI323 6-axis IMU sensor using embedded-hal-async I2C traits.
Features
- 🚀 Async I2C via
embedded-hal-async - 📦 no_std compatible
- 🎯 Type-safe configuration with strongly-typed enums and bitfields
- 🔧 Comprehensive API for accelerometer, gyroscope, and advanced features
- 📊 FIFO support with configurable watermarks
- 🔔 Interrupt handling with flexible mapping
- 🎨 Feature engine for motion detection, tap, step counting, orientation, and more
- 📝 Optional defmt logging support
Quick Start
use ;
// Create the driver
let mut imu = new;
// Initialize
imu.soft_reset.await?;
let chip_id = imu.get_id.await?;
// Configure accelerometer
let accel_config = default;
imu.set_accel_conf.await?;
// Read accelerometer data
let accel_data = imu.get_accel_data.await?; // Returns Vector3d<f32> in g
println!;
// Configure gyroscope
let gyro_config = default;
imu.set_gyro_conf.await?;
// Read gyroscope data
let gyro_data = imu.get_gyro_data.await?; // Returns Vector3d<f32> in dps
Advanced Features
Feature Engine
The BMI323 includes an on-chip feature engine for advanced motion detection:
// Enable the feature engine
imu.enable_feature_engine.await?;
// Configure tap detection
use *;
let tap_config = default;
imu.set_tap_config.await?;
// Configure step counter
use *;
let step_config = default;
imu.set_step_counter_config.await?;
FIFO
use FifoConfig;
let fifo_config = FifoConfig ;
imu.set_fifo_config.await?;
imu.set_fifo_watermark.await?;
// Read FIFO data
let mut buffer = ;
let bytes_read = imu.read_fifo_bytes.await?;
Interrupts
use *;
// Configure interrupt pins
let int1 = IntConfig ;
imu.set_int_config.await?;
// Map features to interrupt pins
let int_map = IntMap ;
imu.set_int_map.await?;
Cargo Features
defmt: Enable defmt logging support for debuggingevents: Enable interrupt event processing with internal queue
Hardware Support
This driver supports the BMI323 IMU via I2C. The BMI323 features:
- 16-bit accelerometer with ±2g to ±16g ranges
- 16-bit gyroscope with ±125°/s to ±2000°/s ranges
- Programmable output data rates from 0.78 Hz to 6.4 kHz
- 2KB FIFO buffer
- Advanced motion features (tap, step, orientation, tilt, etc.)
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.