Skip to content

Gen7FW: I2C drivers for onboard temp sensor + TI voltage rail monitor (datasheet-verified via host harness) - #46

Merged
datacrystals merged 3 commits into
hostsim-flesh-outfrom
gen7-hw-drivers
Sep 11, 2026
Merged

datacrystals merged 3 commits into
hostsim-flesh-outfrom
gen7-hw-drivers

Conversation

@datacrystals

Copy link
Copy Markdown
Contributor

Stacked on the simulator PR. New Gen7 hardware support that the .ioc had configured but the firmware never initialized:

  • I2C4/I2C5 init — MX_I2C4_Init (PD12/PF15, VOLTAGE_MONITOR) and MX_I2C5_Init (PF0/PF1, ONBOARD_TEMP_SENSE), timing 0x60404E72 from the .ioc, with a comment that a CubeMX regen must not duplicate.
  • OnboardTempSensor — TMP102/TMP1075/PCT2075-family pointer-register sensor: probe, 12-bit and 13-bit-EM decode, onb_temp shell command, telemetry/alert wiring.
  • RailMonitor — auto-detects INA226 / INA228 / INA3221 via ID-register patterns over a capability table, CAL/SHUNT_CAL math, per-channel poll, rails shell command, i2cscan probe utility.

No hardware was available, so this went through an extra datasheet audit instead. Four review agents cross-checked the drivers against the actual TI/NXP/ST datasheets (SBOS547C, SLYS021A, SBOS576C, PCT2075 rev 10.1, DS13313) and caught real bugs before bench ever saw them:

  • TMP1075 config POR 0x00FF would have falsely latched the EM bit and reported 2x the real temperature (fixed: skip EM unless positively ID'd as TMP102-generic).
  • INA228 power register decoded with the 20-bit shift used for VBUS/CURRENT but it's full 24-bit (would have under-reported power 16x).
  • INA226/INA3221 die-ID exact-match rejected legitimate revision-nibble variants (US-fab INA226 = 0x2261); now masked.
  • Warm-boot hazards: INA228 CONFIG forced to ADCRANGE=0 by RMW, INA3221 CH_EN+MODE RMW, INA226 reads the OVF math-overflow flag at the rails instead of trusting a wrapped sample, and rejected probes still record raw IDs for diagnosis.

Host-side proof without hardware: Images/Gen7FW/MainProcessor/tests/host/ is a plain-g++ harness (no dependencies) with accuracy-modelled mock devices — TMP1075 (real-0x00FF POR), TMP102 (pointer-masked), INA226 (real CAL transfer function), INA228 (rev-1 ID, 24-bit power), INA3221 (channel-enable gating), plus exact bus-transaction-sequence assertions. 297/297 checks pass locally.

The firmware cross-build through the real pipeline (Images/Gen7FW/build-main-rte.sh foc_demo.json Release, arm-none-eabi) links clean; the .rte-gen7/generated mirror is updated to match.

When the boards show up on the bench: docs/I2C_HW_Bringup.md has the exact power-up + first-scope-check + i2cscan sequence with expected IDs.

…il monitor (INA226/228/3221 autodetect) drivers, i2cscan/rails/onb_temp shell cmds, host test harness 123/123
… RMW, INA3221 CH_EN+MODE RMW, INA226 OVF rail check, rejected-probe ID recording, TMP1075 EM latch); host harness upgraded to realistic silicon models + adversarial suites (297 checks)
@datacrystals
datacrystals merged commit c928461 into hostsim-flesh-out Sep 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant