drivers: spi: stm32 driver with dma checking spi busy status flag
Defines a function to control the spi busy state during DMA transfer. After the DMA Tx, the spi might still have some data to Transmit. The driver must wait for the SPI Tx before sending the next packet. This is not required for the Rx part as the DMA Rx is already done. Some mcus like stm32H7 have a TX complete bit, other must wait for the TXE and BSY line. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
0ec7af9c17
commit
081e2d5a54
|
@ -756,12 +756,8 @@ static int transceive_dma(const struct device *dev,
|
|||
}
|
||||
#endif
|
||||
|
||||
/* wait until TX buffer is really empty */
|
||||
while (ll_func_tx_is_empty(spi) == 0) {
|
||||
}
|
||||
|
||||
/* wait until hardware is really ready */
|
||||
while (ll_func_spi_is_busy(spi) == 1) {
|
||||
/* wait until spi is no more busy (spi TX fifo is really empty) */
|
||||
while (ll_func_spi_dma_busy(spi) == 0) {
|
||||
}
|
||||
|
||||
LL_SPI_DisableDMAReq_TX(spi);
|
||||
|
|
|
@ -53,6 +53,20 @@ struct spi_stm32_data {
|
|||
#endif
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPI_STM32_DMA
|
||||
/* checks that DMA Tx packet is fully transmitted over the SPI */
|
||||
static inline uint32_t ll_func_spi_dma_busy(SPI_TypeDef *spi)
|
||||
{
|
||||
#ifdef LL_SPI_SR_TXC
|
||||
return LL_SPI_IsActiveFlag_TXC(spi);
|
||||
#else
|
||||
/* the SPI Tx empty and busy flags are needed */
|
||||
return (LL_SPI_IsActiveFlag_TXE(spi) &&
|
||||
!LL_SPI_IsActiveFlag_BSY(spi));
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_SPI_STM32_DMA */
|
||||
|
||||
static inline uint32_t ll_func_tx_is_empty(SPI_TypeDef *spi)
|
||||
{
|
||||
#if defined(CONFIG_SOC_SERIES_STM32MP1X) || \
|
||||
|
@ -154,8 +168,7 @@ static inline uint32_t ll_func_spi_is_busy(SPI_TypeDef *spi)
|
|||
#if defined(CONFIG_SOC_SERIES_STM32MP1X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32H7X) || \
|
||||
defined(CONFIG_SOC_SERIES_STM32U5X)
|
||||
return (!LL_SPI_IsActiveFlag_MODF(spi) &&
|
||||
!LL_SPI_IsActiveFlag_TXC(spi));
|
||||
return LL_SPI_IsActiveFlag_EOT(spi);
|
||||
#else
|
||||
return LL_SPI_IsActiveFlag_BSY(spi);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue