STM32 I2C bus — manages the HAL handle and device collection.
One bus instance per I2C peripheral (I2C1, I2C2, etc.). Devices are created via CreateDevice() and accessed via GetDevice().
Transfers are serialized with PlatformMutex (same contract as StmSpi). Direct HAL probes (IsDeviceReady) must take LockBus or risk racing Mem_Read/Master_Transmit on the same handle.
- Note
- STM32H7 soft-I2C bring-up contract (parity with
StmSpi):
- Do not call
HAL_I2C_IsDeviceReady from Initialize — on STM32H7 it can latch ISR.TXIS while State==READY and poison the next Mem_Read (command byte flushed into TXDR, never on the wire).
- Prefer
Master_Transmit + Master_Receive (or WriteRead) over Mem_Read when the slave pointer auto-increments (PCA/PCAL).
- When caller buffers may sit in external FMC SDRAM, stage small RX/TX through D1 AXI scratch before HAL calls (byte loads from that memory class are unreliable on some FMC setups).
- Flush sticky TXIS/TXE before a new transfer (
FlushTxdr).