Expand description
Async #![no_std] driver for the
QMI8658C 6-axis IMU
(accelerometer + gyroscope + temperature) from QST Corporation.
This crate provides a lightweight, embedded-hal-async based driver for the
QMI8658 6-axis IMU. It intentionally avoids any core-ports dependencies so
it can be reused in adapter or BSP layers.
§Quick start (I2C)
use ph_qmi8658::{Config, I2cConfig, Qmi8658Address, Qmi8658I2c};
let config = Config::new();
let i2c_config = I2cConfig::new(Qmi8658Address::Primary.addr());
let mut imu: Qmi8658I2c<I2C> =
Qmi8658I2c::with_i2c_config(i2c, None, None, config, i2c_config);
imu.init(delay).await?;§FIFO
FIFO parsing helpers are available for burst-mode reads. See FifoFrameIterator.
§CTRL9 handshake
By default CTRL8.bit7 = 0 and CmdDone is routed to INT1/STATUS1.bit0.
Set InterruptConfig::with_ctrl9_handshake_statusint(true)
to route CmdDone to STATUSINT.bit7. The driver polls the correct source automatically.
§Sync sample locking
Enable with set_sync_sample(true); use read_sync_sample(delay) to follow
the STATUSINT data-lock flow and data-read delay.
For I2C/I3C, disable AHB clock gating via
set_ahb_clock_gating_with_delay(delay, false) while sync sample is active.
§Not yet supported
- External magnetometer integration (mag raw types and FIFO mag frame parsing are included for future support).
- AttitudeEngine configuration and Motion-on-Demand.
- Motion detection engines (tap/any/no/sig motion, pedometer) — these are QMI8658A-only and are not applicable to the QMI8658C.
§Scaling helpers
Use accel_lsb_per_g, gyro_lsb_per_dps, and temperature_lsb_per_celsius
(or the milli-unit ratios accel_mg_per_lsb / gyro_mdps_per_lsb) to
convert raw counts to physical units without floating-point math.
§Fixed-point conversions
Enable the fixed feature to access fixed-point helpers that convert raw
readings into g, dps, and degrees C using I32F32 integer math.
Macros§
- qmi8658_
init_ sequence - Initialize a QMI8658 instance with a common configuration sequence.
Structs§
- Accel
Config - Combined accelerometer configuration (range + ODR).
- Accel
Fixed - Fixed-point accelerometer sample in g.
- Accel
Raw - Raw accelerometer sample.
- Config
- QMI8658 configuration settings.
- Fifo
Config - FIFO configuration (watermark + mode + size).
- Fifo
Frame - One decoded FIFO frame.
- Fifo
Frame Format - FIFO frame format derived from enabled sensors.
- Fifo
Frame Iterator - Iterator over FIFO frames.
- Fifo
Readout - Result of a FIFO readout.
- Fifo
Status - FIFO status decoded from FIFO_STATUS and FIFO_SMPL_CNT.
- Gyro
Config - Combined gyroscope configuration (range + ODR).
- Gyro
Fixed - Fixed-point gyroscope sample in dps.
- GyroRaw
- Raw gyroscope sample.
- I2cConfig
- I2C interface configuration (address + serial settings).
- I2cInterface
- I2C register interface.
- Interrupt
Config - Interrupt routing and feature enable configuration (CTRL8).
- Interrupt
Status - Decoded interrupt and status flags.
- MagRaw
- Raw magnetometer sample.
- Qmi8658
- QMI8658 6-axis IMU driver.
- RawBlock
- Raw block of sensor data sampled at a single timestamp.
- Sample
- Timestamped sample wrapper.
- Scale
Factor - Ratio representing a scale factor without floating-point math.
- Self
Test Axis - Self-test axis readings.
- Self
Test Report - Self-test report with raw data and pass/fail evaluation.
- SpiConfig
- SPI interface configuration (experimental).
- SpiInterface
- SPI register interface (experimental).
- Temperature
Fixed - Fixed-point temperature sample in deg C.
- Temperature
Raw - Raw temperature sample.
- Timestamp
- Sample timestamp (24-bit counter).
- WomConfig
- Wake on Motion configuration.
Enums§
- Accel
Output Data Rate - Accelerometer output data rate selection.
- Accel
Range - Accelerometer full-scale range selection.
- Error
- Error type for QMI8658 operations.
- Fifo
Mode - FIFO operating mode.
- Fifo
Size - FIFO size selection (samples per enabled sensor).
- Gyro
Output Data Rate - Gyroscope output data rate selection.
- Gyro
Range - Gyroscope full-scale range selection.
- Interrupt
Pin - Interrupt pin selection (device pins).
- Interrupt
Wait Error - Error returned when waiting on an interrupt pin.
- LowPass
Filter Mode - Low-pass filter bandwidth selection (percent of ODR).
- Operating
Mode - Operating modes from Table 34 / Figure 11 of the datasheet.
- Qmi8658
Address - QMI8658 I2C addresses.
- Self
Test Error - Self-test error wrapper (driver errors + interrupt wait errors).
- WomInterrupt
Level - Initial interrupt level for Wake on Motion.
Functions§
- accel_
lsb_ per_ g - Returns the accelerometer sensitivity in LSB/g.
- accel_
mg_ per_ lsb - Returns the accelerometer scale in milli-g per LSB as a ratio.
- accel_
sample_ to_ g - Converts a timestamped accelerometer sample to g.
- accel_
to_ g - Converts accelerometer raw counts to g.
- gyro_
lsb_ per_ dps - Returns the gyroscope sensitivity in LSB/dps.
- gyro_
mdps_ per_ lsb - Returns the gyroscope scale in milli-deg/s per LSB as a ratio.
- gyro_
sample_ to_ dps - Converts a timestamped gyroscope sample to dps.
- gyro_
to_ dps - Converts gyroscope raw counts to dps.
- temperature_
celsius - Converts temperature raw counts to degrees Celsius.
- temperature_
lsb_ per_ celsius - Returns the temperature sensitivity in LSB per degree Celsius.
- temperature_
mdegc_ per_ lsb - Returns the temperature scale in milli-deg C per LSB as a ratio.
- temperature_
sample_ celsius - Converts a timestamped temperature sample to degrees Celsius.
Type Aliases§
- Fixed
- Fixed-point number type used for sensor conversions (I32F32).
- Qmi8658
I2c - I2C type alias for the QMI8658 driver.
- Qmi8658
Spi - SPI type alias for the QMI8658 driver (experimental).