I2C
In STM32CubeMX, the matching I2C DMA channels and interrupts should be configured.
From the current generator’s perspective, this page mainly covers two generated parameters: the shared buffer size and the DMA enable threshold.
Example
The last constructor argument is the minimum transfer size required before DMA is enabled.
STM32I2C i2c1(&hi2c1, i2c1_buf, 3);
Configuration File
After code generation, the following I2C section appears in User/libxr_config.yaml:
I2C:
i2c1:
buffer_size: 32
dma_section: ''
dma_enable_min_size: 3
buffer_size: shared I2C transfer / receive buffer sizedma_section: linker section for the generated buffer declarationdma_enable_min_size: minimum transfer byte count to enable DMA
Current generation details:
- the generator emits one shared buffer per I2C instance, for example
i2c1_buf; dma_enable_min_sizeis currently emitted directly as the last argument ofSTM32I2C(..., dma_enable_min_size);dma_sectiononly affects where the buffer declaration is placed, and does not change theSTM32I2Cconstructor shape itself.