Kleidos API Search

In development. It changes without notice.

Topic

Motion Sensor Drivers

The BMI270 and MPU6886 motion sensors, and a stand-in for the boards with none.

Sensor Boards
Bmi270 Core2 v1.3, M5Cardputer ADV, M5StickS3
Mpu6886 M5StickC Plus 1.1, M5StickC Plus2
NullImu CoreInk, CoreS3 SE, LILYGO T-Deck, M5StickC Plus SE

Both drivers talk to the chip's registers directly. The BMI270 is given the configuration image its maker publishes at each start. Where the supply stays on through a sleep, the sensor is put to sleep first.

See also
Motion & Shake-to-Lock

Files

file src/drivers/imu/bmi270.h
Bosch BMI270 accelerometer/gyroscope IMU driver.
file src/drivers/imu/bmi270_codec.h
Pure encode/decode helpers behind the BMI270 driver's register sequences.
file src/drivers/imu/bmi270_config.h
The configuration image the BMI270 driver uploads, as pinned data.
file src/drivers/imu/bmi270_regs.h
BMI270 register addresses, bit masks, values and timings the driver uses.
file src/drivers/imu/i_imu.h
Chip-level inertial-measurement-unit (accel/gyro) driver contract.
file src/drivers/imu/imu_factory.h
WHO_AM_I probe factory for the inertial-measurement-unit driver.
file src/drivers/imu/imu_selftest.h
Pure decision helpers + shared constants for the kleidos::drivers::imu::IImu self-test.
file src/drivers/imu/mpu6886.h
Driver for MPU6886-compatible accelerometer/gyroscope IMUs.
file src/drivers/imu/mpu6886_regs.h
MPU-6886 register addresses, bit masks, values and timings the driver uses.
file src/drivers/imu/null_imu.h
No-op IMU driver for the boards without an inertial sensor.

Classes

class kleidos::drivers::imu::Bmi270
Bosch BMI270 6-axis IMU driver (8 g accel, 2000 dps gyro). Runs the accelerometer only; the gyroscope stays off (PWR_CTRL) until setGyroEnabled powers it up. More about kleidos::drivers::imu::Bmi270
struct kleidos::drivers::imu::bmi270::InitAddr
The two INIT_ADDR bytes a burst starting at one byte offset needs. More about kleidos::drivers::imu::bmi270::InitAddr
struct kleidos::drivers::imu::bmi270::ConfigurationEvidence
What a chip that may have kept its configuration reports about itself. More about kleidos::drivers::imu::bmi270::ConfigurationEvidence
struct kleidos::drivers::imu::bmi270::AnyMotionConfig
An any-motion configuration in physical units. More about kleidos::drivers::imu::bmi270::AnyMotionConfig
struct kleidos::drivers::imu::bmi270::ConfigImage
One configuration image the chip can run once it is uploaded. More about kleidos::drivers::imu::bmi270::ConfigImage
class kleidos::drivers::imu::IImu
Chip-level accelerometer/gyroscope driver interface. More about kleidos::drivers::imu::IImu
class kleidos::drivers::imu::Mpu6886
MPU6886-compatible 6-axis IMU driver (also accepts MPU6050/MPU9250 IDs). Runs the accelerometer only; the gyroscope stays in standby (PWR_MGMT_2) until setGyroEnabled powers it up. More about kleidos::drivers::imu::Mpu6886
class kleidos::drivers::imu::NullImu
No-op IMU used on the boards that have no inertial sensor. More about kleidos::drivers::imu::NullImu

Enumerations

enum class kleidos::drivers::imu::ImuFamily : uint8_t { kleidos::drivers::imu::ImuFamily::None , kleidos::drivers::imu::ImuFamily::Mpu6886 , kleidos::drivers::imu::ImuFamily::Bmi270 , kleidos::drivers::imu::ImuFamily::Qmi8658 }
IMU family selected by an identity probe. More about kleidos::drivers::imu::ImuFamily

Functions

const ConfigImage &kleidos::drivers::imu::bmi270::baseConfigImage ()
Bosch's base 8 KiB image (BMI270_SensorAPI tag v2.113.0).
constexpr ImuFamilykleidos::drivers::imu::classifyImu (bool reg00Ok, uint8_t reg00, bool regMpuOk, uint8_t regMpu)
Classify an IMU from its identity-register reads (pure, no I2C).
constexpr boolkleidos::drivers::imu::mpuProbeNeeded (bool reg00Ok, uint8_t reg00)
Whether the probe must still read register 0x75 for the MPU6886 family once register 0x00 has been read.
IImu *kleidos::drivers::imu::createImu (uint8_t address)
Resolve and return the fitted IMU driver.
constexpr boolkleidos::drivers::imu::selfTestWriteVerified (uint8_t readback, uint8_t pattern, uint8_t mask)
Whether a register write-readback proves the I2C WRITE path.
constexpr boolkleidos::drivers::imu::selfTestMagnitudePlausible (float magG)
Whether an acceleration magnitude shows gravity is present.

Variables

constexpr uint8_tkleidos::drivers::imu::kRegIdentityReg00
Register holding the WHO_AM_I / chip-id for the BMI270 and QMI8658.
constexpr uint8_tkleidos::drivers::imu::kRegIdentityMpu
Register holding the WHO_AM_I for the MPU6886 family.
constexpr uint8_tkleidos::drivers::imu::kChipIdBmi270
BMI270 chip-id (register 0x00).
constexpr uint8_tkleidos::drivers::imu::kWhoAmIQmi8658
QMI8658 WHO_AM_I (register 0x00).
constexpr uint8_tkleidos::drivers::imu::kWhoAmIMpu6886
MPU6886 WHO_AM_I (register 0x75).
constexpr uint8_tkleidos::drivers::imu::kWhoAmIMpu6050
MPU6050 WHO_AM_I — accepted by the MPU6886-compatible driver.
constexpr uint8_tkleidos::drivers::imu::kWhoAmIMpu9250
MPU9250 WHO_AM_I — accepted by the MPU6886-compatible driver.
constexpr floatkleidos::drivers::imu::kSelfTestMagMinG
Lower bound of the plausible-gravity window for the accel data-path check (g).
constexpr floatkleidos::drivers::imu::kSelfTestMagMaxG
Upper bound of the plausible-gravity window for the accel data-path check (g).

Status decoding (§5.2.27, §5.2.33)

enum class kleidos::drivers::imu::bmi270::InternalStatus : uint8_t { kleidos::drivers::imu::bmi270::InternalStatus::NotInit, kleidos::drivers::imu::bmi270::InternalStatus::InitOk, kleidos::drivers::imu::bmi270::InternalStatus::InitErr, kleidos::drivers::imu::bmi270::InternalStatus::DrvErr, kleidos::drivers::imu::bmi270::InternalStatus::SnsStop, kleidos::drivers::imu::bmi270::InternalStatus::NvmError, kleidos::drivers::imu::bmi270::InternalStatus::StartUpError, kleidos::drivers::imu::bmi270::InternalStatus::CompatError }
INTERNAL_STATUS.message: the configuration engine's state. More about kleidos::drivers::imu::bmi270::InternalStatus
constexpr std::array< const char *, 8 >kleidos::drivers::imu::bmi270::kInternalStatusNames
Names of the INTERNAL_STATUS messages, indexed by their code.
constexpr InternalStatuskleidos::drivers::imu::bmi270::internalStatusMessage (uint8_t raw)
The message field of an INTERNAL_STATUS read.
constexpr const char *kleidos::drivers::imu::bmi270::internalStatusName (InternalStatus status)
A name for an INTERNAL_STATUS message, for logs.
constexpr uint8_tkleidos::drivers::imu::bmi270::eventErrorCode (uint8_t raw)
EVENT.error_code: a persistent ACC_CONF / GYR_CONF error.
constexpr boolkleidos::drivers::imu::bmi270::eventPorDetected (uint8_t raw)
EVENT.por_detected: the chip was powered up or soft-reset since the register was last read.

Configuration and power registers (§5.2.41 to §5.2.44, §5.2.84, §5.2.85)

constexpr uint8_tkleidos::drivers::imu::bmi270::kAccConfLowPower
constexpr uint8_tkleidos::drivers::imu::bmi270::kAccConfPerformance
constexpr std::array< uint8_t, 4 >kleidos::drivers::imu::bmi270::kSensorConfig
constexpr uint8_tkleidos::drivers::imu::bmi270::accConf (uint8_t odr, uint8_t bwp, bool performance)
ACC_CONF: output data rate, bandwidth parameter and filter mode.
constexpr uint8_tkleidos::drivers::imu::bmi270::gyrConf (uint8_t odr, uint8_t bwp, bool lowNoise, bool performance)
GYR_CONF: output data rate, bandwidth and the two performance modes.
constexpr uint8_tkleidos::drivers::imu::bmi270::pwrCtrl (bool accel, bool gyro)
PWR_CTRL with the accelerometer and gyroscope enables (temperature and auxiliary off).
constexpr uint8_tkleidos::drivers::imu::bmi270::pwrConf (bool advancedPowerSave)
PWR_CONF with advanced power save on or off.
constexpr uint32_tkleidos::drivers::imu::bmi270::burstMicros (size_t dataBytes, uint32_t frequencyHz)
Time one register burst holds the bus, START to STOP.
constexpr size_tkleidos::drivers::imu::bmi270::uploadBurstBytes (uint32_t frequencyHz, uint32_t budgetUs, size_t longestBytes)
Longest INIT_DATA burst the bus's clock allows.

Any-motion feature words (§4.8.2, FEATURES page 1)

constexpr AnyMotionConfigkleidos::drivers::imu::bmi270::kAnyMotionChipDefault
The chip's own reset configuration: 83 mg (0xAA) for 100 ms (5 samples), every axis.
constexpr AnyMotionConfigkleidos::drivers::imu::bmi270::kAnyMotionShakeGate
constexpr uint16_tkleidos::drivers::imu::bmi270::kAnyMotionThresholdMax
Largest ANYMO_2.threshold (11 bits).
constexpr uint16_tkleidos::drivers::imu::bmi270::kAnyMotionDurationMax
Largest ANYMO_1.duration (13 bits).
constexpr uint32_tkleidos::drivers::imu::bmi270::kAnyMotionLsbPerG
ANYMO_2.threshold: 1 g spans 2048 LSB.
constexpr uint32_tkleidos::drivers::imu::bmi270::kAnyMotionSampleMs
ANYMO_1.duration counts 50 Hz samples.
constexpr uint16_tkleidos::drivers::imu::bmi270::anyMotionThresholdLsb (uint32_t mg)
ANYMO_2.threshold for a slope of mg milli-g, rounded and clamped.
constexpr uint16_tkleidos::drivers::imu::bmi270::anyMotionDurationSamples (uint32_t ms)
ANYMO_1.duration for ms milliseconds, in 20 ms samples, rounded and clamped.
constexpr std::array< uint8_t, 4 >kleidos::drivers::imu::bmi270::encodeAnyMotion (const AnyMotionConfig &config, bool enable)
The four FEATURES bytes from 0x3C on (page 1): ANYMO_1 then ANYMO_2, each little-endian.

BMI270 register addresses (§5.2)

constexpr uint8_tkleidos::drivers::imu::bmi270::kRegChipId
CHIP_ID: 0x24 on every BMI270.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegErrReg
ERR_REG: fatal_err, internal_err and friends.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegAccelData
DATA_8: first of the 12 sample bytes.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegEvent
EVENT: por_detected, error_code; clears on read.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegIntStatus0
INT_STATUS_0: feature interrupt flags; clears on read.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInternalStatus
INTERNAL_STATUS: the upload's verdict.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegFeatPage
FEAT_PAGE: page FEATURES shows.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegAnyMotion
FEATURES[12]: page 1 ANYMO_1, then ANYMO_2.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegAccConf
ACC_CONF, followed by ACC_RANGE, GYR_CONF, GYR_RANGE.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInt1IoCtrl
INT1_IO_CTRL: INT1 electrical setup.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInt2IoCtrl
INT2_IO_CTRL: unrouted; the self-test's scratch.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegIntLatch
INT_LATCH.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInt1MapFeat
INT1_MAP_FEAT: feature outputs on INT1.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInitCtrl
INIT_CTRL: prepare / complete the upload.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInitAddr0
INIT_ADDR_0, followed by INIT_ADDR_1.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInitData
INIT_DATA: configuration-memory data port.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegInternalError
INTERNAL_ERROR: feature-engine faults.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegErrRegMsk
ERR_REG_MSK, first of ERR_REG_MSK..INT_MAP_DATA.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegGyrCrtConf
GYR_CRT_CONF, followed by NVM_CONF and IF_CONF.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegAccSelfTest
ACC_SELF_TEST: excitation that deflects samples.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegNvConf
NV_CONF, followed by OFFSET_0..OFFSET_6.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegPwrConf
PWR_CONF: advanced power save.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegPwrCtrl
PWR_CTRL: sensor enables.
constexpr uint8_tkleidos::drivers::imu::bmi270::kRegCmd
CMD: write-only command register.

BMI270 register values and bit masks

constexpr uint8_tkleidos::drivers::imu::bmi270::kChipId
CHIP_ID of a BMI270.
constexpr uint8_tkleidos::drivers::imu::bmi270::kCmdSoftReset
CMD: soft reset (§4.17).
constexpr uint8_tkleidos::drivers::imu::bmi270::kInitCtrlPrepare
INIT_CTRL: prepare the upload.
constexpr uint8_tkleidos::drivers::imu::bmi270::kInitCtrlComplete
INIT_CTRL: complete it (once per reset).
constexpr uint8_tkleidos::drivers::imu::bmi270::kPwrCtrlGyrEn
PWR_CTRL.gyr_en.
constexpr uint8_tkleidos::drivers::imu::bmi270::kPwrCtrlAccEn
PWR_CTRL.acc_en.
constexpr uint8_tkleidos::drivers::imu::bmi270::kPwrConfAdvPowerSave
PWR_CONF.adv_power_save.
constexpr uint8_tkleidos::drivers::imu::bmi270::kPwrConfFifoSelfWakeUp
PWR_CONF.fifo_self_wake_up (reset 1).
constexpr uint8_tkleidos::drivers::imu::bmi270::kInternalStatusMessageMask
INTERNAL_STATUS.message.
constexpr uint8_tkleidos::drivers::imu::bmi270::kInternalStatusAxesRemap
INTERNAL_STATUS.axes_remap_error.
constexpr uint8_tkleidos::drivers::imu::bmi270::kInternalStatusOdr50Hz
constexpr uint8_tkleidos::drivers::imu::bmi270::kInternalStatusOdrHigh
constexpr uint8_tkleidos::drivers::imu::bmi270::kErrRegFatalOrInternal
ERR_REG.fatal_err and internal_err.
constexpr uint8_tkleidos::drivers::imu::bmi270::kInternalErrorFlags
int_err_1, int_err_2, feat_eng_disabled.
constexpr uint8_tkleidos::drivers::imu::bmi270::kEventPorDetected
EVENT.por_detected.
constexpr uint8_tkleidos::drivers::imu::bmi270::kEventErrorCodeShift
EVENT.error_code, bits 4..2.
constexpr uint8_tkleidos::drivers::imu::bmi270::kEventErrorCodeMask
EVENT.error_code, right-aligned.
constexpr uint8_tkleidos::drivers::imu::bmi270::kFeaturePageReset
FEAT_PAGE reset value (§5.2.39).
constexpr uint8_tkleidos::drivers::imu::bmi270::kFeaturePageAnyMotion
FEAT_PAGE holding ANYMO_1/ANYMO_2.
constexpr uint8_tkleidos::drivers::imu::bmi270::kMapFeatAnyMotion
INTx_MAP_FEAT.any_motion_out.
constexpr uint8_tkleidos::drivers::imu::bmi270::kAnyMotionOutConf
ANYMO_2.out_conf: bit 6 of INT_STATUS_0.
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntStatus0AnyMotion
INT_STATUS_0.any_motion_out.
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntIoLevelHigh
INTx_IO_CTRL.lvl: 1 = active high.
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntIoOpenDrain
INTx_IO_CTRL.od: 1 = open drain.
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntIoOutputEn
INTx_IO_CTRL.output_en.
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntIoInputEn
constexpr uint8_tkleidos::drivers::imu::bmi270::kIntLatchNone
constexpr uint8_tkleidos::drivers::imu::bmi270::kInt1IoCtrlMotionWake
constexpr uint8_tkleidos::drivers::imu::bmi270::kInt1IoCtrlOff
INT1 back to its reset value: output and input disabled.

BMI270: the sensor configuration the driver programs (§5.2.41 to §5.2.44)

constexpr uint8_tkleidos::drivers::imu::bmi270::kOdr50Hz
acc_odr: 50 Hz.
constexpr uint8_tkleidos::drivers::imu::bmi270::kOdr100Hz
acc_odr / gyr_odr: 100 Hz.
constexpr uint8_tkleidos::drivers::imu::bmi270::kBwpAvg2
acc_bwp osr2_avg2: two samples averaged.
constexpr uint8_tkleidos::drivers::imu::bmi270::kBwpNormal
acc_bwp norm_avg4 / gyr_bwp norm.
constexpr uint8_tkleidos::drivers::imu::bmi270::kAccRange8g
ACC_RANGE: ±8 g.
constexpr uint8_tkleidos::drivers::imu::bmi270::kGyrRange2000
GYR_RANGE: ±2000 dps, OIS ±250 dps.
constexpr floatkleidos::drivers::imu::bmi270::kAccelFullScaleG
±8 g over the int16 range.
constexpr floatkleidos::drivers::imu::bmi270::kGyroFullScaleDps
±2000 dps over the int16 range.

BMI270: what a fresh bring-up leaves in the configuration registers (§5.2)

A chip that kept its configuration through a deep sleep is checked against these before the upload is skipped: reset values plus the sensor configuration the driver programs, so a difference in any register compared here (the any-motion interrupt left armed, a debug-console write) falls back to a full bring-up. Not compared, so a difference there lasts through a resumed wake until the next upload: the FEATURES words of every page (only FEAT_PAGE itself is checked, and must read 0), the configuration memory behind INIT_ADDR / INIT_DATA (reading it back would take as long as the upload), INIT_CTRL (0x59), which the resume does not rewrite either, the NVM-backed AUX_IF_TRIM (0x68) and DRV (0x6C), which sit outside every compared block, and the NVM-backed offset values masked out of kFreshCompensationFrom70Mask. The firmware writes the FEATURES words only through any-motion, whose disable puts page 1's reset words back, and the configuration memory and INIT_CTRL only during an upload; a debug-console write can change any of them.

constexpr std::array< uint8_t, 16 >kleidos::drivers::imu::bmi270::kFreshConfigFrom40
constexpr std::array< uint8_t, 16 >kleidos::drivers::imu::bmi270::kFreshConfigFrom40Mask
constexpr std::array< uint8_t, 7 >kleidos::drivers::imu::bmi270::kFreshInterruptsFrom52
ERR_REG_MSK (0x52) to INT_MAP_DATA (0x58): reset values, every interrupt off.
constexpr std::array< uint8_t, 3 >kleidos::drivers::imu::bmi270::kFreshInterfaceFrom69
constexpr std::array< uint8_t, 3 >kleidos::drivers::imu::bmi270::kFreshInterfaceFrom69Mask
constexpr std::array< uint8_t, 8 >kleidos::drivers::imu::bmi270::kFreshCompensationFrom70
constexpr std::array< uint8_t, 8 >kleidos::drivers::imu::bmi270::kFreshCompensationFrom70Mask
constexpr size_tkleidos::drivers::imu::bmi270::kLongestFreshBlock
The longest block compared in one read.

BMI270 timings

constexpr uint32_tkleidos::drivers::imu::bmi270::kSoftResetSettleMs
constexpr uint32_tkleidos::drivers::imu::bmi270::kPowerSaveGapUs
constexpr uint32_tkleidos::drivers::imu::bmi270::kLowPowerSamplePeriodMs
constexpr uint32_tkleidos::drivers::imu::bmi270::kPerformanceSamplePeriodMs
Time between two samples while the gyroscope runs (100 Hz, performance mode).
constexpr uint32_tkleidos::drivers::imu::bmi270::kFirstSampleMs
constexpr uint32_tkleidos::drivers::imu::bmi270::kInitStatusFirstWaitMs
constexpr uint32_tkleidos::drivers::imu::bmi270::kInitStatusPollMs
Interval between later looks.
constexpr uint32_tkleidos::drivers::imu::bmi270::kInitStatusBudgetMs

BMI270 configuration upload

constexpr size_tkleidos::drivers::imu::bmi270::kMaxImageBytes
Largest image the chip can take: INIT_ADDR is a 12-bit word address.
constexpr uint32_tkleidos::drivers::imu::bmi270::kI2cFrequencyHz
constexpr size_tkleidos::drivers::imu::bmi270::kUploadChunkBytes
constexpr uint32_tkleidos::drivers::imu::bmi270::kI2cBitsPerByte
Bits one byte takes on the wire: eight of data and the acknowledge.
constexpr uint32_tkleidos::drivers::imu::bmi270::kUploadBurstBudgetUs

MPU6886 register addresses (§7)

constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegSampleRateDiv
SMPLRT_DIV: output rate 1 kHz / (1 + value).
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegConfig
CONFIG: FIFO mode, FSYNC, gyroscope DLPF.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegGyroConfig
GYRO_CONFIG: self-test, full scale, FCHOICE_B.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegAccelConfig
ACCEL_CONFIG: self-test and full scale.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegAccelConfig2
ACCEL_CONFIG2: low-power averaging and the DLPF.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegWomThresholdX
ACCEL_WOM_X_THE, then the Y and Z ones.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegFifoEnable
FIFO_EN: which sensors feed the FIFO.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegIntPinConfig
INT_PIN_CFG: the INT pin's electrical setup.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegIntEnable
INT_ENABLE: interrupt sources on the pin.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegIntStatus
INT_STATUS: source flags; clears on read.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegAccelOut
ACCEL_XOUT_H: first of the 14 sample bytes.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegAccelIntelCtrl
ACCEL_INTEL_CTRL: wake-on-motion logic.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegUserControl
USER_CTRL: FIFO enable and resets.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegPowerMgmt1
PWR_MGMT_1: reset, sleep, cycle, clock.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegPowerMgmt2
PWR_MGMT_2: per-axis standby.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kRegWhoAmI
WHO_AM_I: 0x19 on an MPU-6886.

MPU6886 identity (§8.43)

constexpr uint8_tkleidos::drivers::imu::mpu6886::kDeviceIdMpu6886
WHO_AM_I of an MPU-6886.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kDeviceIdMpu6050
WHO_AM_I of an MPU-6050.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kDeviceIdMpu9250
WHO_AM_I of an MPU-9250.

MPU6886 register values and bit masks

constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerReset
PWR_MGMT_1.DEVICE_RESET.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerSleep
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerCycle
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerClockAuto
PWR_MGMT_1.CLKSEL 1: the clock the chip picks itself, which §9.6 requires.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerAccelLowPower
PWR_MGMT_1 for the accelerometer alone: cycle mode on the auto clock.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerLowNoise
PWR_MGMT_1 with the gyroscope running: continuous (low-noise) sampling.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerGyroStandby
constexpr uint8_tkleidos::drivers::imu::mpu6886::kPowerAllAxesOn
PWR_MGMT_2 with no standby bit set: every accelerometer and gyroscope axis on.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kAccelRange8g
ACCEL_CONFIG.ACCEL_FS_SEL: ±8 g.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kGyroRange2000Dps
GYRO_CONFIG.FS_SEL: ±2000 dps.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kConfigDlpf
constexpr uint8_tkleidos::drivers::imu::mpu6886::kAccelConfig2Average4
constexpr uint8_tkleidos::drivers::imu::mpu6886::kSampleRateDiv50Hz
SMPLRT_DIV for 50 Hz, the rate shake-to-lock reads at: 1 kHz / (1 + 19).
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntPinActiveLowOpenDrain
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntPinLatch
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntPinMotion
INT_PIN_CFG while wake-on-motion is armed.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntWomAllAxes
INT_ENABLE / INT_STATUS: wake-on-motion on X, Y and Z (bits 7..5).
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntNone
INT_ENABLE: no source on the pin.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntelOutputLimit
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntelMotionOn
constexpr uint8_tkleidos::drivers::imu::mpu6886::kIntelMotionOff
ACCEL_INTEL_CTRL with the logic off.
constexpr uint8_tkleidos::drivers::imu::mpu6886::kWomThreshold
constexpr std::array< uint8_t, 3 >kleidos::drivers::imu::mpu6886::kWomThresholds
The three threshold registers' values, in register order.
constexpr floatkleidos::drivers::imu::mpu6886::kAccelScaleG
g per LSB at ±8 g.
constexpr floatkleidos::drivers::imu::mpu6886::kGyroScaleDps
dps per LSB at ±2000 dps.

MPU6886 timings and the bus

constexpr uint32_tkleidos::drivers::imu::mpu6886::kResetDelayMs
Wait after DEVICE_RESET before the first register write.
constexpr uint32_tkleidos::drivers::imu::mpu6886::kSamplePeriodMs
constexpr uint32_tkleidos::drivers::imu::mpu6886::kFirstSampleMs
constexpr uint32_tkleidos::drivers::imu::mpu6886::kI2cFrequencyHz
Bus clock the driver runs the chip at: I2C fast mode, the chip's maximum.

Configuration upload (§4.4, §5.2.65, §5.2.66)

constexpr InitAddrkleidos::drivers::imu::bmi270::initAddrForOffset (size_t byteOffset)
INIT_ADDR for a burst that starts byteOffset bytes into the image.
constexpr boolkleidos::drivers::imu::bmi270::imageSizeValid (size_t bytes)
Whether an image of bytes bytes can be uploaded at all.
constexpr size_tkleidos::drivers::imu::bmi270::chunkCount (size_t imageBytes, size_t chunkBytes)
Number of bursts an image of imageBytes takes at chunkBytes each.
constexpr size_tkleidos::drivers::imu::bmi270::chunkLength (size_t imageBytes, size_t chunkBytes, size_t index)
Length of burst index of an image of imageBytes.

Keeping the configuration across a deep sleep (§4.4, §5.2.2, §5.2.27, §5.2.33, §5.2.68)

constexpr const char *kleidos::drivers::imu::bmi270::configurationLostReason (const ConfigurationEvidence &evidence)
Why a chip cannot be trusted to have kept its configuration.

Samples (§4.6.1, §5.2.12 to §5.2.23)

constexpr int16_tkleidos::drivers::imu::bmi270::decodeLe16 (uint8_t low, uint8_t high)
One signed 16-bit quantity from its little-endian register pair.
constexpr floatkleidos::drivers::imu::bmi270::accelG (int16_t raw)
An accelerometer reading in g at the driver's ±8 g range.
constexpr floatkleidos::drivers::imu::bmi270::gyroDps (int16_t raw)
A gyroscope reading in deg/s at the driver's ±2000 dps range.

Back to the top

Enumeration Type Documentation

ImuFamily #

enum class kleidos::drivers::imu::ImuFamily : uint8_t

IMU family selected by an identity probe.

Enumerator
None 

No supported chip responded.

Mpu6886 

MPU6886-compatible (also MPU6050 / MPU9250).

Bmi270 

Bosch BMI270.

Qmi8658 

QST QMI8658 (recognized; no driver).

InternalStatus #

enum class kleidos::drivers::imu::bmi270::InternalStatus : uint8_t

INTERNAL_STATUS.message: the configuration engine's state.

Enumerator
NotInit 

Not initialized: no upload completed yet.

InitOk 

The upload was accepted; the chip is ready.

InitErr 

The upload was rejected.

DrvErr 

Invalid driver.

SnsStop 

Sensor stopped.

NvmError 

Internal NVM access error.

StartUpError 

NVM access and initialization error.

CompatError 

Compatibility error.

Back to the top

Function Documentation

accConf() #

uint8_t kleidos::drivers::imu::bmi270::accConf(uint8_t odr, uint8_t bwp, bool performance)
constexpr

ACC_CONF: output data rate, bandwidth parameter and filter mode.

Parameters
NameDirectionMeaning
odrinacc_odr code (bits 3..0).
bwpinacc_bwp code (bits 6..4).
performanceinacc_filter_perf (bit 7): true = performance mode.
Returns
The register value.

accelG() #

float kleidos::drivers::imu::bmi270::accelG(int16_t raw)
constexpr

An accelerometer reading in g at the driver's ±8 g range.

Parameters
NameDirectionMeaning
rawinThe register value.
Returns
Acceleration in g (4096 LSB per g).

anyMotionDurationSamples() #

uint16_t kleidos::drivers::imu::bmi270::anyMotionDurationSamples(uint32_t ms)
constexpr

ANYMO_1.duration for ms milliseconds, in 20 ms samples, rounded and clamped.

Parameters
NameDirectionMeaning
msinDuration in ms.
Returns
The 13-bit field value.

anyMotionThresholdLsb() #

uint16_t kleidos::drivers::imu::bmi270::anyMotionThresholdLsb(uint32_t mg)
constexpr

ANYMO_2.threshold for a slope of mg milli-g, rounded and clamped.

Parameters
NameDirectionMeaning
mginThreshold in mg.
Returns
The 11-bit field value.

baseConfigImage() #

const ConfigImage & kleidos::drivers::imu::bmi270::baseConfigImage()

Bosch's base 8 KiB image (BMI270_SensorAPI tag v2.113.0).

Raw accelerometer and gyroscope plus the feature engine. Defined in the generated translation unit, which compiles only for a board with a BMI270.

Returns
The pinned image; it lives for the whole program.

burstMicros() #

uint32_t kleidos::drivers::imu::bmi270::burstMicros(size_t dataBytes, uint32_t frequencyHz)
constexpr

Time one register burst holds the bus, START to STOP.

Parameters
NameDirectionMeaning
dataBytesinBytes after the register address.
frequencyHzinBus clock in Hz.
Returns
Microseconds for the address byte, the register byte and the data, nine bits each.

chunkCount() #

size_t kleidos::drivers::imu::bmi270::chunkCount(size_t imageBytes, size_t chunkBytes)
constexpr

Number of bursts an image of imageBytes takes at chunkBytes each.

Parameters
NameDirectionMeaning
imageBytesinImage length.
chunkBytesinBurst length; even and non-zero.
Returns
The burst count; the last burst may be shorter.

chunkLength() #

size_t kleidos::drivers::imu::bmi270::chunkLength(size_t imageBytes, size_t chunkBytes, size_t index)
constexpr

Length of burst index of an image of imageBytes.

Parameters
NameDirectionMeaning
imageBytesinImage length.
chunkBytesinBurst length; even and non-zero.
indexinBurst number, from 0.
Returns
chunkBytes for every burst but the last, which takes what is left; 0 past the end.

classifyImu() #

ImuFamily kleidos::drivers::imu::classifyImu(bool reg00Ok, uint8_t reg00, bool regMpuOk, uint8_t regMpu)
constexpr

Classify an IMU from its identity-register reads (pure, no I2C).

Register 0x00 disambiguates the BMI270 (0x24) from the QMI8658 (0x05); register 0x75 identifies the MPU6886 family. A caller reads only the register(s) relevant to the families compiled into the build and passes their success flags, so an unread register can never false-match.

Parameters
NameDirectionMeaning
reg00OkinWhether the register 0x00 read succeeded.
reg00inValue read from register 0x00 (ignored if reg00Ok is false).
regMpuOkinWhether the register 0x75 read succeeded.
regMpuinValue read from register 0x75 (ignored if regMpuOk is false).
Returns
The detected ImuFamily, or ImuFamily::None if nothing matched.

configurationLostReason() #

const char * kleidos::drivers::imu::bmi270::configurationLostReason(const ConfigurationEvidence & evidence)
constexpr

Why a chip cannot be trusted to have kept its configuration.

The chip must say init_ok (a soft reset or a rail cut puts it back to not_init), no power-on event and no configuration error since the last read, and no error flag raised: anything else re-runs the whole upload. A feature page left away from 0 or a self-test excitation left on are what a debug-console write could leave behind and a fresh bring-up would have cleared.

Parameters
NameDirectionMeaning
evidenceinThe register values read from the chip.
Returns
A short lowercase reason, or nullptr when the configuration is kept.

createImu() #

IImu * kleidos::drivers::imu::createImu(uint8_t address)

Resolve and return the fitted IMU driver.

Probes address on the internal I2C bus for the IMU families compiled into this build, then returns the matching driver (constructed but not yet initialized — the caller runs IImu::init). On no match, an unsupported chip (QMI8658), a probe failure, or a board with no IMU family compiled in, returns the shared kleidos::drivers::imu::NullImu.

Parameters
NameDirectionMeaning
addressin7-bit I2C address of the IMU (typically 0x68).
Returns
A driver owned by function-local static storage (never delete, never nullptr).

decodeLe16() #

int16_t kleidos::drivers::imu::bmi270::decodeLe16(uint8_t low, uint8_t high)
constexpr

One signed 16-bit quantity from its little-endian register pair.

Parameters
NameDirectionMeaning
lowinThe byte at the lower address.
highinThe byte above it.
Returns
The two's-complement value.

encodeAnyMotion() #

std::array< uint8_t, 4 > kleidos::drivers::imu::bmi270::encodeAnyMotion(const AnyMotionConfig & config, bool enable)
constexpr

The four FEATURES bytes from 0x3C on (page 1): ANYMO_1 then ANYMO_2, each little-endian.

A whole-word write, as the feature engine requires (§4.8.1): it starts at an even address and ends at an odd one. out_conf stays 7, so the output lands on bit 6 of INT_STATUS_0 and INTx_MAP_FEAT.

Parameters
NameDirectionMeaning
configinThe configuration.
enableinANYMO_2.enable.
Returns
The bytes to write at kRegAnyMotion.

eventErrorCode() #

uint8_t kleidos::drivers::imu::bmi270::eventErrorCode(uint8_t raw)
constexpr

EVENT.error_code: a persistent ACC_CONF / GYR_CONF error.

Parameters
NameDirectionMeaning
rawinThe register byte.
Returns
0 for none, 1 ACC_CONF, 2 GYR_CONF, 3 both.

eventPorDetected() #

bool kleidos::drivers::imu::bmi270::eventPorDetected(uint8_t raw)
constexpr

EVENT.por_detected: the chip was powered up or soft-reset since the register was last read.

Parameters
NameDirectionMeaning
rawinThe register byte.
Returns
The flag.

gyrConf() #

uint8_t kleidos::drivers::imu::bmi270::gyrConf(uint8_t odr, uint8_t bwp, bool lowNoise, bool performance)
constexpr

GYR_CONF: output data rate, bandwidth and the two performance modes.

Parameters
NameDirectionMeaning
odringyr_odr code (bits 3..0).
bwpingyr_bwp code (bits 5..4).
lowNoiseingyr_noise_perf (bit 6).
performanceingyr_filter_perf (bit 7).
Returns
The register value.

gyroDps() #

float kleidos::drivers::imu::bmi270::gyroDps(int16_t raw)
constexpr

A gyroscope reading in deg/s at the driver's ±2000 dps range.

Parameters
NameDirectionMeaning
rawinThe register value.
Returns
Angular rate in deg/s.

imageSizeValid() #

bool kleidos::drivers::imu::bmi270::imageSizeValid(size_t bytes)
constexpr

Whether an image of bytes bytes can be uploaded at all.

Parameters
NameDirectionMeaning
bytesinImage length.
Return values
ValueMeaning
trueNon-empty, a whole number of words, and within the 12-bit word space.
falseAnything else; the driver uploads nothing.

initAddrForOffset() #

InitAddr kleidos::drivers::imu::bmi270::initAddrForOffset(size_t byteOffset)
constexpr

INIT_ADDR for a burst that starts byteOffset bytes into the image.

The configuration memory is addressed in 16-bit words, so the address is the offset halved, split over the two registers.

Parameters
NameDirectionMeaning
byteOffsetinEven offset into the image, below kMaxImageBytes.
Returns
The bytes to write at INIT_ADDR_0 and INIT_ADDR_1, in that order.

internalStatusMessage() #

InternalStatus kleidos::drivers::imu::bmi270::internalStatusMessage(uint8_t raw)
constexpr

The message field of an INTERNAL_STATUS read.

Parameters
NameDirectionMeaning
rawinThe register byte.
Returns
Its message; a reserved code (8..15) comes back as that number.

internalStatusName() #

const char * kleidos::drivers::imu::bmi270::internalStatusName(InternalStatus status)
constexpr

A name for an INTERNAL_STATUS message, for logs.

Parameters
NameDirectionMeaning
statusinThe decoded message.
Returns
A short lowercase name; "reserved" for a code the datasheet leaves open.

mpuProbeNeeded() #

bool kleidos::drivers::imu::mpuProbeNeeded(bool reg00Ok, uint8_t reg00)
constexpr

Whether the probe must still read register 0x75 for the MPU6886 family once register 0x00 has been read.

Not when register 0x00 already names a chip: the classification would ignore 0x75 anyway, and a BMI270 suspended through a deep sleep needs 400 µs of bus idle before a new transfer (datasheet Table 20), which a read right behind the first would not give it.

Parameters
NameDirectionMeaning
reg00OkinWhether the register 0x00 read succeeded.
reg00inValue read from register 0x00.
Return values
ValueMeaning
trueRegister 0x00 named no chip; read 0x75.
falseRegister 0x00 identified the chip; skip 0x75.

pwrConf() #

uint8_t kleidos::drivers::imu::bmi270::pwrConf(bool advancedPowerSave)
constexpr

PWR_CONF with advanced power save on or off.

fifo_self_wake_up keeps its reset value and fast power-up stays off, so the suspended value is the register's reset value, 0x03.

Parameters
NameDirectionMeaning
advancedPowerSaveinadv_power_save.
Returns
The register value.

pwrCtrl() #

uint8_t kleidos::drivers::imu::bmi270::pwrCtrl(bool accel, bool gyro)
constexpr

PWR_CTRL with the accelerometer and gyroscope enables (temperature and auxiliary off).

Parameters
NameDirectionMeaning
accelinacc_en.
gyroingyr_en.
Returns
The register value.

selfTestMagnitudePlausible() #

bool kleidos::drivers::imu::selfTestMagnitudePlausible(float magG)
constexpr

Whether an acceleration magnitude shows gravity is present.

Parameters
NameDirectionMeaning
magGinAcceleration magnitude in g.
Return values
ValueMeaning
truemagG sits within [kSelfTestMagMinG, kSelfTestMagMaxG].
falseThe reading is implausibly small or large (no valid sample).

selfTestWriteVerified() #

bool kleidos::drivers::imu::selfTestWriteVerified(uint8_t readback, uint8_t pattern, uint8_t mask)
constexpr

Whether a register write-readback proves the I2C WRITE path.

Compares only the writable field bits selected by mask; reserved bits (which read back as 0) are ignored, so a full-register mask of 0xFF collapses to exact equality.

Parameters
NameDirectionMeaning
readbackinValue read back after writing pattern.
patterninTest pattern written to the register.
maskinWritable-field bitmask for the register.
Return values
ValueMeaning
trueThe writable bits of readback match pattern.
falseThe write did not take effect on the writable bits.

uploadBurstBytes() #

size_t kleidos::drivers::imu::bmi270::uploadBurstBytes(uint32_t frequencyHz, uint32_t budgetUs, size_t longestBytes)
constexpr

Longest INIT_DATA burst the bus's clock allows.

The burst length follows the clock the chip is actually run at: a bus that grants the driver's rate takes longestBytes, and one that keeps a slower rate takes shorter bursts, so no burst holds the bus past budgetUs whatever the clock (256 bytes at 100 kHz would hold it 23 ms, longer than the 20 ms another task's transfer waits).

Parameters
NameDirectionMeaning
frequencyHzinClock the chip's transfers run at, Hz.
budgetUsinLongest a burst may hold the bus, µs.
longestBytesinLongest burst wanted; even and non-zero.
Returns
The largest even burst length, at most longestBytes, that burstMicros puts within budgetUs; one word where no burst fits (the upload still has to be made).

Back to the top

Variable Documentation

kAccConfLowPower #

uint8_t kleidos::drivers::imu::bmi270::kAccConfLowPower
inlineconstexpr

ACC_CONF while only the accelerometer runs: 50 Hz, two samples averaged, filter performance off, which with PWR_CONF.adv_power_save is the chip's low-power mode (§4.5 Table 6, the configuration of §3's low-power example). 50 Hz is the lowest rate the feature engine's any-motion takes (§4.8).

kAccConfPerformance #

uint8_t kleidos::drivers::imu::bmi270::kAccConfPerformance
inlineconstexpr

ACC_CONF while the gyroscope runs too: 100 Hz, normal filter, performance mode, the pair of the gyroscope's own configuration.

kAccelConfig2Average4 #

uint8_t kleidos::drivers::imu::mpu6886::kAccelConfig2Average4
inlineconstexpr

ACCEL_CONFIG2 for the low-power mode's 4-sample average: DEC2_CFG 0, ACCEL_FCHOICE_B 0, A_DLPF_CFG 7 (Table 18's "4x" column; 420 Hz in the low-noise mode the gyroscope's run uses).

kAnyMotionShakeGate #

AnyMotionConfig kleidos::drivers::imu::bmi270::kAnyMotionShakeGate
inlineconstexpr

What the driver arms: a slope of 250 mg between samples on any axis, held for two samples (40 ms). A shake that reaches the gesture's 2 g crosses it in its first tens of milliseconds; a board resting on a desk someone types at does not.

kConfigDlpf #

uint8_t kleidos::drivers::imu::mpu6886::kConfigDlpf
inlineconstexpr

CONFIG.DLPF_CFG 1: gyroscope 176 Hz.

kFirstSampleMs [1/2] #

uint32_t kleidos::drivers::imu::bmi270::kFirstSampleMs
inlineconstexpr

From the accelerometer being enabled to its first sample in the data registers: the 2 ms start-up time (Table 2) and one 50 Hz period, with margin.

kFirstSampleMs [2/2] #

uint32_t kleidos::drivers::imu::mpu6886::kFirstSampleMs
inlineconstexpr

From the accelerometer being switched on (a reset, or leaving sleep) to its first sample in the output registers: one period, with margin.

kFreshCompensationFrom70 #

std::array<uint8_t, 8> kleidos::drivers::imu::bmi270::kFreshCompensationFrom70
inlineconstexpr

NV_CONF (0x70) to OFFSET_6 (0x77): the I2C watchdog and every offset or gain compensation off, as on a chip as shipped.

kFreshCompensationFrom70Mask #

std::array<uint8_t, 8> kleidos::drivers::imu::bmi270::kFreshCompensationFrom70Mask
inlineconstexpr

Mask for kFreshCompensationFrom70, which keeps NV_CONF's i2c_wdt_sel, i2c_wdt_en and acc_off_en, and OFFSET_6's gyr_off_en and gyr_gain_en. The offset values themselves are NVM-backed, so a soft reset reloads them from the chip's own NVM, which the driver cannot know; with every compensation off they change no sample, so they are left out, as are the other NVM-backed registers, AUX_IF_TRIM (0x68, the unused auxiliary bus's pull-up) and DRV (0x6C, the pad drive the check's own reads have just gone through).

kFreshConfigFrom40 #

std::array<uint8_t, 16> kleidos::drivers::imu::bmi270::kFreshConfigFrom40
inlineconstexpr

ACC_CONF (0x40) to AUX_WR_DATA (0x4F): the driver's sensor configuration, then the auxiliary-interface and FIFO reset values.

kFreshConfigFrom40Mask #

std::array<uint8_t, 16> kleidos::drivers::imu::bmi270::kFreshConfigFrom40Mask
inlineconstexpr

Mask for kFreshConfigFrom40, which leaves out SATURATION (0x4A), a live per-axis flag.

kFreshInterfaceFrom69 #

std::array<uint8_t, 3> kleidos::drivers::imu::bmi270::kFreshInterfaceFrom69
inlineconstexpr

GYR_CRT_CONF (0x69), NVM_CONF (0x6A), IF_CONF (0x6B): reset values, so no gyroscope retrimming, no NVM programming, no OIS or auxiliary interface.

kFreshInterfaceFrom69Mask #

std::array<uint8_t, 3> kleidos::drivers::imu::bmi270::kFreshInterfaceFrom69Mask
inlineconstexpr

Mask for kFreshInterfaceFrom69, which keeps the defined fields only (crt_running and rdy_for_dl; nvm_prog_en; spi3, spi3_ois, ois_en and aux_en).

kI2cFrequencyHz #

uint32_t kleidos::drivers::imu::bmi270::kI2cFrequencyHz
inlineconstexpr

Bus clock the driver runs the chip at: I2C fast mode (Table 20), which every other chip on the internal bus of the three BMI270 boards is rated for. The chip itself takes fast mode plus (1 MHz).

kInitStatusBudgetMs #

uint32_t kleidos::drivers::imu::bmi270::kInitStatusBudgetMs
inlineconstexpr

Nominal waits before giving up on init_ok: well past the datasheet's 20 ms, as the 140 ms other hosts allow. They make 14 looks (the first wait, then 13 polls), and each wait is asked one tick longer so it never ends early, so the real bound is about 164 ms of waiting plus the 14 reads.

kInitStatusFirstWaitMs #

uint32_t kleidos::drivers::imu::bmi270::kInitStatusFirstWaitMs
inlineconstexpr

First look at INTERNAL_STATUS after INIT_CTRL = 1: the datasheet gives "at most 20 ms" for the upload to be accepted (§4.4).

kInt1IoCtrlMotionWake #

uint8_t kleidos::drivers::imu::bmi270::kInt1IoCtrlMotionWake
inlineconstexpr

INT1 as the M5StickS3's M5PM1 wakes on it (a falling edge on its GPIO4): output enabled, active low, push-pull, so the line needs no pull-up to idle high.

kIntelMotionOn #

uint8_t kleidos::drivers::imu::mpu6886::kIntelMotionOn
inlineconstexpr

ACCEL_INTEL_CTRL with the wake-on-motion logic on: ACCEL_INTEL_EN, ACCEL_INTEL_MODE (compare each sample with the one before) and OUTPUT_LIMIT; WOM_TH_MODE 0, so any one axis over its threshold raises the interrupt.

kIntelOutputLimit #

uint8_t kleidos::drivers::imu::mpu6886::kIntelOutputLimit
inlineconstexpr

ACCEL_INTEL_CTRL.OUTPUT_LIMIT: set after every power-up so the outputs are not limited to 0x7F7F (§8.36).

kInternalStatusOdr50Hz #

uint8_t kleidos::drivers::imu::bmi270::kInternalStatusOdr50Hz
inlineconstexpr

INTERNAL_STATUS.odr_50hz_error.

kInternalStatusOdrHigh #

uint8_t kleidos::drivers::imu::bmi270::kInternalStatusOdrHigh
inlineconstexpr

INTERNAL_STATUS bit 7, reserved in the datasheet (§5.2.33); Bosch's own API names it an "ODR high" error. On silicon it reads 1 once any-motion is armed while the accelerometer runs in low-power mode below 200 Hz, and stays until the next reset. Any-motion answers the same steps with it set as without on every board it was tried on, so the driver reports it and acts on nothing.

kIntIoInputEn #

uint8_t kleidos::drivers::imu::bmi270::kIntIoInputEn
inlineconstexpr

INTx_IO_CTRL.input_en.

kIntLatchNone #

uint8_t kleidos::drivers::imu::bmi270::kIntLatchNone
inlineconstexpr

INT_LATCH.int_latch: non-latched, the reset value and what an edge-triggered wake needs (§4.9.1).

kIntPinActiveLowOpenDrain #

uint8_t kleidos::drivers::imu::mpu6886::kIntPinActiveLowOpenDrain
inlineconstexpr

INT_PIN_CFG: INT_LEVEL (active low) and INT_OPEN (open drain), so the pin only ever pulls low on a line other open-drain outputs share.

kIntPinLatch #

uint8_t kleidos::drivers::imu::mpu6886::kIntPinLatch
inlineconstexpr

INT_PIN_CFG.LATCH_INT_EN: the pin holds its level until INT_STATUS is read (unlatched it pulses for 50 µs, too short for a level wake).

kLowPowerSamplePeriodMs #

uint32_t kleidos::drivers::imu::bmi270::kLowPowerSamplePeriodMs
inlineconstexpr

Time between two accelerometer samples in the low-power setup the driver programs (50 Hz, §4.6.5): reading the data registers more often returns the same sample again.

kPowerCycle #

uint8_t kleidos::drivers::imu::mpu6886::kPowerCycle
inlineconstexpr

PWR_MGMT_1.CYCLE: between samples the chip sleeps and wakes for one accelerometer sample at the SMPLRT_DIV rate (accelerometer low-power mode).

kPowerGyroStandby #

uint8_t kleidos::drivers::imu::mpu6886::kPowerGyroStandby
inlineconstexpr

PWR_MGMT_2 with STBY_XG | STBY_YG | STBY_ZG set: the three gyroscope axes in standby, the three accelerometer axes running. With the gyroscope down the clock auto-select falls back to the internal oscillator (§9.8).

kPowerSaveGapUs #

uint32_t kleidos::drivers::imu::bmi270::kPowerSaveGapUs
inlineconstexpr

Bus idle after every access while PWR_CONF.adv_power_save is set: 450 µs after a write (tIDLE_wacc_sum) and 400 µs before a new transfer (tBUF, Table 20). One figure covers both.

kPowerSleep #

uint8_t kleidos::drivers::imu::mpu6886::kPowerSleep
inlineconstexpr

PWR_MGMT_1.SLEEP: the 6 µA full-chip sleep.

kSamplePeriodMs #

uint32_t kleidos::drivers::imu::mpu6886::kSamplePeriodMs
inlineconstexpr

Time between two samples at the kSampleRateDiv50Hz rate; reading the output registers more often returns the same sample again.

kSensorConfig #

std::array<uint8_t, 4> kleidos::drivers::imu::bmi270::kSensorConfig
inlineconstexpr

The four bytes from ACC_CONF on that the driver programs, in register order: accelerometer 50 Hz in low-power mode, ±8 g; gyroscope 100 Hz, normal filter, low noise and performance mode, ±2000 dps (it stays off until asked for).

kSoftResetSettleMs #

uint32_t kleidos::drivers::imu::bmi270::kSoftResetSettleMs
inlineconstexpr

Settle after a soft reset before the interface may be used: the power-on time tPO (Table 1), which §4.17 applies to a soft reset too.

kUploadBurstBudgetUs #

uint32_t kleidos::drivers::imu::bmi270::kUploadBurstBudgetUs
inlineconstexpr

Longest a burst may hold the bus, in µs: half the 20 ms another task's transfer waits for it (bus::internal_i2c::kDefaultTimeoutMs).

kUploadChunkBytes #

size_t kleidos::drivers::imu::bmi270::kUploadChunkBytes
inlineconstexpr

Bytes per INIT_DATA burst. The chip takes the whole image in one (§4.4); the bound is the bus, which a burst holds from START to STOP while every other task's transfer waits behind it for at most its own timeout: 256 bytes are 5.8 ms at 400 kHz. Each burst needs an even length (word addresses). This is the length at kI2cFrequencyHz; on a bus that keeps a slower clock the driver sends what uploadBurstBytes() fits in kUploadBurstBudgetUs.

kWomThreshold #

uint8_t kleidos::drivers::imu::mpu6886::kWomThreshold
inlineconstexpr

Wake-on-motion threshold, the same on X, Y and Z: 60 LSB. The specification gives no weight for the LSB; the family's other parts count 4 mg, which makes this 240 mg, the size of the BMI270's gate.

Back to the top