Skip to main content

Crate ph_qmi8658

Crate ph_qmi8658 

Source
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§

AccelConfig
Combined accelerometer configuration (range + ODR).
AccelFixed
Fixed-point accelerometer sample in g.
AccelRaw
Raw accelerometer sample.
Config
QMI8658 configuration settings.
FifoConfig
FIFO configuration (watermark + mode + size).
FifoFrame
One decoded FIFO frame.
FifoFrameFormat
FIFO frame format derived from enabled sensors.
FifoFrameIterator
Iterator over FIFO frames.
FifoReadout
Result of a FIFO readout.
FifoStatus
FIFO status decoded from FIFO_STATUS and FIFO_SMPL_CNT.
GyroConfig
Combined gyroscope configuration (range + ODR).
GyroFixed
Fixed-point gyroscope sample in dps.
GyroRaw
Raw gyroscope sample.
I2cConfig
I2C interface configuration (address + serial settings).
I2cInterface
I2C register interface.
InterruptConfig
Interrupt routing and feature enable configuration (CTRL8).
InterruptStatus
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.
ScaleFactor
Ratio representing a scale factor without floating-point math.
SelfTestAxis
Self-test axis readings.
SelfTestReport
Self-test report with raw data and pass/fail evaluation.
SpiConfig
SPI interface configuration (experimental).
SpiInterface
SPI register interface (experimental).
TemperatureFixed
Fixed-point temperature sample in deg C.
TemperatureRaw
Raw temperature sample.
Timestamp
Sample timestamp (24-bit counter).
WomConfig
Wake on Motion configuration.

Enums§

AccelOutputDataRate
Accelerometer output data rate selection.
AccelRange
Accelerometer full-scale range selection.
Error
Error type for QMI8658 operations.
FifoMode
FIFO operating mode.
FifoSize
FIFO size selection (samples per enabled sensor).
GyroOutputDataRate
Gyroscope output data rate selection.
GyroRange
Gyroscope full-scale range selection.
InterruptPin
Interrupt pin selection (device pins).
InterruptWaitError
Error returned when waiting on an interrupt pin.
LowPassFilterMode
Low-pass filter bandwidth selection (percent of ODR).
OperatingMode
Operating modes from Table 34 / Figure 11 of the datasheet.
Qmi8658Address
QMI8658 I2C addresses.
SelfTestError
Self-test error wrapper (driver errors + interrupt wait errors).
WomInterruptLevel
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).
Qmi8658I2c
I2C type alias for the QMI8658 driver.
Qmi8658Spi
SPI type alias for the QMI8658 driver (experimental).