ph-qmi8658 Driver
Async driver for the QMI8658 6-axis IMU sensor built on embedded-hal-async.
This README describes the flows that are implemented in the current code. For
architecture and data flow details, see ARCHITECTURE.md in this directory. If
you change driver behavior or flow sequencing, update both documents to keep
them aligned with the code.
All examples below assume an async context, an I2C bus, and a DelayNs
implementation. Use the Common Setup snippet once, then follow the flow
examples.
Common Setup
use ;
use DelayNs;
use I2c;
async
Initialization
// Known address
imu.init.await?;
// Probe multiple addresses
let address = imu.init_with_addresses.await?;
let _ = address;
Initialization notes:
- If
initorinit_with_addressesreturnsError::NotReady, delay briefly and retry.
Initialization Macro
use ;
let config = new;
let irq = new.with_ctrl9_handshake_statusint;
let address = qmi8658_init_sequence!?;
let _ = address;
Configuration
use ;
let accel = new;
let config = new.with_accel_config.without_gyro;
imu.set_config;
imu.apply_config.await?;
Interrupt Routing + Status
use ;
let irq = new
.with_ctrl9_handshake_statusint
.with_motion_pin;
imu.apply_interrupt_config.await?;
let status = imu.read_interrupt_status.await?;
let _ = status;
Raw Data Reads
let block = imu.read_raw_block.await?;
let accel = imu.read_accel_raw.await?;
let gyro = imu.read_gyro_raw.await?;
let temp = imu.read_temperature_raw.await?;
let ts = imu.read_timestamp.await?;
let _ = ;
FIFO Burst Read + Decode
use ;
let fifo = new;
imu.apply_fifo_config.await?;
imu.reset_fifo_with_delay.await?;
let mut buffer = ;
let readout = imu.read_fifo_burst.await?;
let format = imu.fifo_frame_format;
for frame in new
FIFO Manual Read Sequence
let mut buffer = ;
imu.request_fifo_read.await?;
imu.wait_ctrl9_done.await?;
imu.enable_fifo_read_mode.await?;
let timestamp = imu.read_fifo_data.await?;
imu.finish_fifo_read.await?;
let _ = timestamp;
Sync Sample (Data-Lock)
// For I2C/I3C, disable AHB clock gating while sync sample is active.
imu.set_ahb_clock_gating_with_delay.await?;
imu.set_sync_sample.await?;
let sample = imu.read_sync_sample.await?;
let _ = sample;
imu.set_sync_sample.await?;
imu.set_ahb_clock_gating_with_delay.await?;
Wake on Motion (WoM)
use ;
let accel = new;
imu.set_config;
imu.apply_config.await?;
let wom = new;
imu.enable_wom.await?;
// ... wait for motion / handle interrupt ...
imu.disable_wom.await?;
Self-Test & Calibration
let accel_report = imu.run_accel_self_test.await?;
let gyro_report = imu.run_gyro_self_test.await?;
let axes = imu.read_self_test_axes.await?;
imu.apply_accel_host_delta_offset_with_delay.await?;
imu.apply_gyro_host_delta_offset_with_delay.await?;
let bias = imu.copy_gyro_bias_and_read.await?;
imu.run_on_demand_calibration.await?;
let _ = ;
Operating Modes
use OperatingMode;
let delay_ns = imu.set_mode.await?;
if delay_ns > 0
imu.set_mode_with_delay.await?;
Target Matrix (CLI Builds)
- ESP32 (xtensa):
xtensa-esp32-none-elf - ESP32-S2 (xtensa):
xtensa-esp32s2-none-elf - ESP32-S3 (xtensa):
xtensa-esp32s3-none-elf - ESP32-C2/C3/C6/H2 (riscv32):
riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf - ARM Cortex-M (common):
thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,thumbv8m.base-none-eabi,thumbv8m.main-none-eabi,thumbv8m.main-none-eabihf
Notes:
- Xtensa targets require the Espressif
esptoolchain. - ARM targets use the standard Rust toolchains.
Features
defmt: defmt formatting supportfixed: fixed-point conversions for raw data
Testing Notes
- The driver has unit test coverage across config validation, data decoding, FIFO parsing, and interrupt/status decoding.
- Gaps remain in end-to-end validation and transport-layer behavior; hardware integration
relies on
apps/qa-runner. - Expanding unit test coverage is not in the current scope of this release plan.
Release Checklist
See RELEASE_CHECKLIST.md in this directory.