diff --git a/drivers/spi/spi_mcux_lpspi.c b/drivers/spi/spi_mcux_lpspi.c index 39535e6808f..11deabce1d3 100644 --- a/drivers/spi/spi_mcux_lpspi.c +++ b/drivers/spi/spi_mcux_lpspi.c @@ -483,7 +483,9 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi return ret; } +#ifdef CONFIG_SOC_SERIES_MCXN base->TCR |= LPSPI_TCR_CONT_MASK; +#endif /* DMA is fast enough watermarks are not required */ LPSPI_SetFifoWatermarks(base, 0U, 0U); @@ -500,9 +502,11 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi goto out; } +#ifdef CONFIG_SOC_SERIES_MCXN while (!(LPSPI_GetStatusFlags(base) & kLPSPI_TxDataRequestFlag)) { /* wait until previous tx finished */ } +#endif /* Enable DMA Requests */ LPSPI_EnableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable); @@ -513,6 +517,12 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi goto out; } +#ifndef CONFIG_SOC_SERIES_MCXN + while ((LPSPI_GetStatusFlags(base) & kLPSPI_ModuleBusyFlag)) { + /* wait until module is idle */ + } +#endif + /* Disable DMA */ LPSPI_DisableDMA(base, kLPSPI_TxDmaEnable | kLPSPI_RxDmaEnable);