STM32: SPIv1: integration with DMAv1 with MUX

This commit is contained in:
Andrey Gusakov 2023-10-29 16:58:50 +03:00
parent 95a93b98dc
commit b1510d74cd
2 changed files with 30 additions and 0 deletions

View File

@ -329,6 +329,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI1(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI1_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI1_TX);
#endif
}
#endif
#if STM32_SPI_USE_SPI2
@ -344,6 +348,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI2(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI2_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI2_TX);
#endif
}
#endif
#if STM32_SPI_USE_SPI3
@ -359,6 +367,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI3(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI3_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI3_TX);
#endif
}
#endif
#if STM32_SPI_USE_SPI4
@ -374,6 +386,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI4(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI4_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI4_TX);
#endif
}
#endif
#if STM32_SPI_USE_SPI5
@ -389,6 +405,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI5(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI5_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI5_TX);
#endif
}
#endif
#if STM32_SPI_USE_SPI6
@ -404,6 +424,10 @@ void spi_lld_start(SPIDriver *spip) {
(void *)spip);
osalDbgAssert(spip->dmatx != NULL, "unable to allocate stream");
rccEnableSPI6(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(spip->dmarx, STM32_DMAMUX1_SPI6_RX);
dmaSetRequestSource(spip->dmatx, STM32_DMAMUX1_SPI6_TX);
#endif
}
#endif

View File

@ -335,6 +335,10 @@
#error "SPI6 DMA streams not defined"
#endif
#if STM32_DMA_SUPPORTS_DMAMUX
#else /* !STM32_DMA_SUPPORTS_DMAMUX */
/* Check on the validity of the assigned DMA channels.*/
#if STM32_SPI_USE_SPI1 && \
!STM32_DMA_IS_VALID_ID(STM32_SPI_SPI1_RX_DMA_STREAM, STM32_SPI1_RX_DMA_MSK)
@ -397,6 +401,8 @@
#endif
#endif /* STM32_ADVANCED_DMA */
#endif /* !STM32_DMA_SUPPORTS_DMAMUX */
#if !defined(STM32_DMA_REQUIRED)
#define STM32_DMA_REQUIRED
#endif