diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 2e6deef21d..ce54be14dd 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -121,7 +121,7 @@ static int spi_stm32_dma_tx_load(const struct device *dev, const uint8_t *buf, } } - blk_cfg->dest_address = (uint32_t)LL_SPI_DMA_GetRegAddr(cfg->spi); + blk_cfg->dest_address = ll_func_dma_get_reg_addr(cfg->spi, SPI_STM32_DMA_TX); /* fifo mode NOT USED there */ if (data->dma_tx.dst_addr_increment) { blk_cfg->dest_addr_adj = DMA_ADDR_ADJ_INCREMENT; @@ -180,7 +180,7 @@ static int spi_stm32_dma_rx_load(const struct device *dev, uint8_t *buf, } } - blk_cfg->source_address = (uint32_t)LL_SPI_DMA_GetRegAddr(cfg->spi); + blk_cfg->source_address = ll_func_dma_get_reg_addr(cfg->spi, SPI_STM32_DMA_RX); if (data->dma_rx.src_addr_increment) { blk_cfg->source_addr_adj = DMA_ADDR_ADJ_INCREMENT; } else { diff --git a/drivers/spi/spi_ll_stm32.h b/drivers/spi/spi_ll_stm32.h index 2c340edee8..7d8206ee33 100644 --- a/drivers/spi/spi_ll_stm32.h +++ b/drivers/spi/spi_ll_stm32.h @@ -31,6 +31,9 @@ struct spi_stm32_config { #define SPI_STM32_DMA_DONE_FLAG \ (SPI_STM32_DMA_RX_DONE_FLAG | SPI_STM32_DMA_TX_DONE_FLAG) +#define SPI_STM32_DMA_TX 0x01 +#define SPI_STM32_DMA_RX 0x02 + struct stream { const struct device *dma_dev; uint32_t channel; /* stores the channel for dma or mux */ @@ -54,6 +57,21 @@ struct spi_stm32_data { }; #ifdef CONFIG_SPI_STM32_DMA +static inline uint32_t ll_func_dma_get_reg_addr(SPI_TypeDef *spi, uint32_t location) +{ +#if defined(CONFIG_SOC_SERIES_STM32H7X) + if (location == SPI_STM32_DMA_TX) { + /* use direct register location until the LL_SPI_DMA_GetTxRegAddr exists */ + return (uint32_t)&(spi->TXDR); + } + /* use direct register location until the LL_SPI_DMA_GetRxRegAddr exists */ + return (uint32_t)&(spi->RXDR); +#else + ARG_UNUSED(location); + return (uint32_t)LL_SPI_DMA_GetRegAddr(spi); +#endif /* CONFIG_SOC_SERIES_STM32H7X */ +} + /* checks that DMA Tx packet is fully transmitted over the SPI */ static inline uint32_t ll_func_spi_dma_busy(SPI_TypeDef *spi) {