| Crates.io | bmi323-rs |
| lib.rs | bmi323-rs |
| version | 0.1.1 |
| created_at | 2025-10-05 06:29:10.497143+00 |
| updated_at | 2025-10-05 06:59:58.661373+00 |
| description | Async, no_std driver for the Bosch BMI323 6-axis IMU sensor |
| homepage | |
| repository | https://github.com/dempfi/bmi323 |
| max_upload_size | |
| id | 1868685 |
| size | 106,761 |
A no_std, async Rust driver for the Bosch BMI323 6-axis IMU sensor using embedded-hal-async I2C traits.
embedded-hal-asyncuse bmi323::{Bmi323, accel::AccelConfig, gyro::GyroConfig};
// Create the driver
let mut imu = Bmi323::new(i2c, delay);
// Initialize
imu.soft_reset().await?;
let chip_id = imu.get_id().await?;
// Configure accelerometer
let accel_config = AccelConfig::default();
imu.set_accel_conf(accel_config).await?;
// Read accelerometer data
let accel_data = imu.get_accel_data().await?; // Returns Vector3d<f32> in g
println!("Accel: x={}, y={}, z={}", accel_data.x, accel_data.y, accel_data.z);
// Configure gyroscope
let gyro_config = GyroConfig::default();
imu.set_gyro_conf(gyro_config).await?;
// Read gyroscope data
let gyro_data = imu.get_gyro_data().await?; // Returns Vector3d<f32> in dps
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 bmi323::feature::tap::*;
let tap_config = TapConfig::default();
imu.set_tap_config(tap_config).await?;
// Configure step counter
use bmi323::feature::step::*;
let step_config = StepCounterConfig::default();
imu.set_step_counter_config(step_config).await?;
use bmi323::fifo::FifoConfig;
let fifo_config = FifoConfig {
acc_en: true,
gyr_en: true,
stop_on_full: false,
..Default::default()
};
imu.set_fifo_config(fifo_config).await?;
imu.set_fifo_watermark(512).await?;
// Read FIFO data
let mut buffer = [0u8; 1024];
let bytes_read = imu.read_fifo_bytes(&mut buffer).await?;
use bmi323::interrupt::*;
// Configure interrupt pins
let int1 = IntConfig {
level: IntLevel::ActiveHigh,
output: IntOutputMode::PushPull,
enable: true,
};
imu.set_int_config(true, int1, IntConfig::default()).await?;
// Map features to interrupt pins
let int_map = IntMap {
any_motion: IntPin::Int1,
tap: IntPin::Int1,
..Default::default()
};
imu.set_int_map(int_map).await?;
defmt: Enable defmt logging support for debuggingevents: Enable interrupt event processing with internal queueThis driver supports the BMI323 IMU via I2C. The BMI323 features:
Licensed under either of:
at your option.
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.