feat(firmware): BNO055 NDOF IMU driver on I2C1 (Issue #135) #150

Merged
sl-jetson merged 1 commits from sl-firmware/issue-135-bno055 into main 2026-03-02 09:51:25 -05:00
Collaborator

Issue #135 — BNO055 IMU Driver

Summary

  • I2C1 driver, auto-detects at 0x28/0x29 alongside MPU6000
  • NDOF fusion mode (9DOF): Euler pitch/roll/yaw, gyro pitch rate, linear accel X, gravity Z
  • Falls back from MPU6000 to BNO055 seamlessly at init time
  • Calibration offset save/restore via STM32 RTC backup registers (BKP0R–BKP6R); bno055_is_ready() true immediately on restore
  • Auto-saves offsets once sys+acc+gyr each reach level 3 (one-shot per session)
  • Temperature compensation: handled in BNO055 silicon; bno055_temperature() exposed for telemetry
  • USB JSON stream adds bno_cs (calib status byte) and bno_t (temperature °C) when active
  • BNO055 read deferred inside balance gate (I2C ~3ms); loop runs ~250Hz vs 1kHz MPU6000
  • 43 pytest tests — all passing

Files

  • include/bno055.h — new
  • src/bno055.c — new
  • include/config.h — BNO055_BKP_MAGIC
  • src/main.c — integration: imu_calibrated() macro, BNO055 init in I2C probe block, read in balance gate, JSON telemetry
  • test/test_bno055_data.py — new, 43 tests

Closes #135

## Issue #135 — BNO055 IMU Driver ### Summary - I2C1 driver, auto-detects at 0x28/0x29 alongside MPU6000 - NDOF fusion mode (9DOF): Euler pitch/roll/yaw, gyro pitch rate, linear accel X, gravity Z - Falls back from MPU6000 to BNO055 seamlessly at init time - Calibration offset save/restore via STM32 RTC backup registers (BKP0R–BKP6R); `bno055_is_ready()` true immediately on restore - Auto-saves offsets once sys+acc+gyr each reach level 3 (one-shot per session) - Temperature compensation: handled in BNO055 silicon; `bno055_temperature()` exposed for telemetry - USB JSON stream adds `bno_cs` (calib status byte) and `bno_t` (temperature °C) when active - BNO055 read deferred inside balance gate (I2C ~3ms); loop runs ~250Hz vs 1kHz MPU6000 - 43 pytest tests — all passing ### Files - `include/bno055.h` — new - `src/bno055.c` — new - `include/config.h` — BNO055_BKP_MAGIC - `src/main.c` — integration: imu_calibrated() macro, BNO055 init in I2C probe block, read in balance gate, JSON telemetry - `test/test_bno055_data.py` — new, 43 tests Closes #135
sl-webui added 1 commit 2026-03-02 09:41:04 -05:00
Auto-detected alongside MPU6000. Acts as balance primary when MPU6000
fails, or provides NDOF-fused yaw/pitch when both sensors are present.

- include/bno055.h: full API — bno055_init/read/is_ready/calib_status/
  temperature/save_offsets/restore_offsets
- src/bno055.c: I2C1 driver; probes 0x28/0x29, resets via SYS_TRIGGER,
  enters NDOF mode; 2-burst 12-byte reads (gyro+euler, LIA+gravity);
  Euler/gyro/accel scaling (÷16, ÷16, ÷100); auto-saves offsets to
  RTC backup regs BKP0R–BKP6R on first full cal; restores on boot
  (bno055_is_ready() returns true immediately); temperature updated 1Hz
- include/config.h: BNO055_BKP_MAGIC = 0xB055CA10
- src/main.c: bno055_init() in I2C probe block (before IWDG); imu_calibrated()
  macro dispatches mpu6000_is_calibrated() vs bno055_is_ready();
  BNO055 read deferred inside balance gate to avoid stalling main loop;
  USB JSON reports bno_cs (calib status) and bno_t (temperature)
- test/test_bno055_data.py: 43 pytest tests (43/43 pass) — calib status
  bit extraction, Euler/gyro/accel scaling, burst parsing, offset
  round-trip packing, temperature signed-byte encoding

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit f5d8180776 into main 2026-03-02 09:51:25 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#150
No description provided.