STM32 SPI: Add support for asynchronous DMA transfer#103396
Open
gautierg-st wants to merge 2 commits intozephyrproject-rtos:mainfrom
Open
STM32 SPI: Add support for asynchronous DMA transfer#103396gautierg-st wants to merge 2 commits intozephyrproject-rtos:mainfrom
gautierg-st wants to merge 2 commits intozephyrproject-rtos:mainfrom
Conversation
e6555f0 to
dc13c51
Compare
dc13c51 to
a7ea6de
Compare
Contributor
Author
|
Rebased to fix conflicts |
a7ea6de to
0e073dd
Compare
Contributor
Author
|
Rebased to fix conflicts again. |
erwango
previously approved these changes
Feb 17, 2026
drivers/spi/spi_stm32.c
Outdated
| CONFIG_SPI_STM32_BUSY_FLAG_TIMEOUT, | ||
| k_yield()); | ||
| #else | ||
| /* wait until spi is no more busy (spi TX fifo is really empty) */ |
Contributor
There was a problem hiding this comment.
this says spi TX fifo is really empty but this is spi_stm32_dma_rx_done()?
drivers/spi/spi_stm32.c
Outdated
Comment on lines
1709
to
1711
| #ifndef CONFIG_SPI_ASYNC | ||
| ARG_UNUSED(dma_dev); | ||
| #endif /* !CONFIG_SPI_ASYNC */ |
Contributor
There was a problem hiding this comment.
Nit: don't bother #ifdef-ing this, it's fine to have an ARG_UNUSED() when the thing actually is used
Comment on lines
383
to
402
| #ifdef CONFIG_SPI_STM32_ERRATA_BUSY | ||
| WAIT_FOR(!ll_spi_dma_busy(spi), | ||
| CONFIG_SPI_STM32_BUSY_FLAG_TIMEOUT, | ||
| k_yield()); | ||
| #else | ||
| /* wait until spi is no more busy (spi TX fifo is really empty) */ | ||
| while (ll_spi_dma_busy(spi) && LL_SPI_IsEnabled(spi)) { | ||
| #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) | ||
| uint32_t width = SPI_WORD_SIZE_GET(data->ctx.config->operation); | ||
| /* The TXC flag is not raised at the end of 9, 17 or 25 | ||
| * bit transfer, so disable the SPI in these cases to avoid being stuck. | ||
| */ | ||
| if (!cfg->fifo_enabled && | ||
| ((width == 9U) || (width == 17U) || (width == 25U))) { | ||
| k_usleep(1000); | ||
| ll_disable_spi(spi); | ||
| } | ||
| #endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) */ | ||
| } | ||
| #endif /* CONFIG_SPI_STM32_ERRATA_BUSY */ |
Contributor
There was a problem hiding this comment.
Already present in old code, but nevertheless:
- adding a
(void)in front ofWAIT_FORwould make it clearer that timeout is acceptable - as far as I can tell, this runs in ISR context? so
k_usleep()is not allowed
Contributor
Author
There was a problem hiding this comment.
(void) added and k_usleep removed.
Add DMA support for asynchronous SPI transfer for STM32. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Remove CONFIG_SPI_ASYNC=n from the conf file for STM32 DMA. Since CONFIG_SPI_ASYNC is set in prj.conf, this change enabled ASYNC for STM32 SPI DMA test. Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
0e073dd to
e054f76
Compare
|
JarmouniA
reviewed
Feb 27, 2026
tests/drivers/spi/spi_loopback/overlay-stm32-spi-dma-dt-nocache-mem.conf
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



This PR adds the support of asynchronous DMA transfer for STM32 SPI.
It is largely inspired by #73855.