mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-26 22:56:41 +08:00
The ChibiOS I2Cv4 LLD (used on STM32G0/G4/C0/U0/U3/H5/L4+) uses a single DMA channel per I2C peripheral, shared between TX and RX, configured via STM32_I2C_I2Cx_DMA_CHANNEL. The previous code emitted the separate STM32_I2C_I2Cx_RX/TX_DMA_STREAM defines used by I2Cv2/I2Cv3, which no longer satisfy the I2Cv4 driver. Detect I2Cv4 MCUs from CHIBIOS_PLATFORM_MK, allocate a single DMA channel per I2C peripheral in dma_resolver.py (no _RX/_TX split), and generate HAL_I2Cn_CONFIG entries that feed the single channel into the shared DMA slot with SHARED_DMA_NONE as the partner. Also replace the unconditional STM32_I2C_USE_I2Cn TRUE lines in stm32g4_mcuconf.h with #ifndef-guarded defaults to FALSE, so boards only enable the I2C peripherals their hwdef actually uses. Without this, the I2Cv4 driver demanded DMA channels for every I2C peripheral on every G4 board regardless of pin usage.