ports/stm32: Extend STM32H5 DMA use. #17587
Open
+6
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Attempting to configure SPI3 and SPI4 for the STM32H5 used to fail with a linker error, something like:
[snip] ...undefined reference to `dma_SPI_4_TX'
An example of valid configuration that was failing:
This patch resolves that, ensuring that appropriate DMA channels are assigned to those SPI resources.
Testing
Tested SPI3 and SPI4 against a SPI peripheral (MAX14915). Also validated correct pin behaviour under a DSO.
I haven't tested if power use is higher due to more channels being employed.
Trade-offs and Alternatives
This patch does use more DMA channels. The H5 has two DMA resources, each with 8 channels. Two are needed for a bidirectional SPI channel (one each for Rx and Tx) so a whole DMA resource - 8 channels - are used to cover SPI1-4. An additional 2x channels of the second DMA resource may also be used if DAC is used.
Currently the DMA channels are statically assigned in MicroPython; an alternative would be to provide an abstraction for DMA channels and allow them to be assigned more dynamically. However, that would be a more complex implementation and difficult to provide a cross-port design.