mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
arch/esp32_spi: Add check to see if the TX_FIFO is empty
to avoid sending empty data Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
This commit is contained in:
@@ -849,6 +849,7 @@ static void esp32_spi_dma_exchange(struct esp32_spi_priv_s *priv,
|
||||
const uintptr_t spi_miso_dlen_reg = SPI_MISO_DLEN_REG(id);
|
||||
const uintptr_t spi_user_reg = SPI_USER_REG(id);
|
||||
const uintptr_t spi_cmd_reg = SPI_CMD_REG(id);
|
||||
const uintptr_t spi_dma_rstatus = SPI_DMA_RSTATUS_REG(id);
|
||||
|
||||
DEBUGASSERT((txbuffer != NULL) || (rxbuffer != NULL));
|
||||
|
||||
@@ -940,6 +941,16 @@ static void esp32_spi_dma_exchange(struct esp32_spi_priv_s *priv,
|
||||
esp32_spi_reset_regbits(spi_user_reg, SPI_USR_MISO_M);
|
||||
}
|
||||
|
||||
if (priv->config->flags & ESP32_SPI_IO_W)
|
||||
{
|
||||
/* Wait until SPI TX FIFO is not empty */
|
||||
|
||||
while ((getreg32(spi_dma_rstatus) & SPI_DMA_TX_FIFO_EMPTY) != 0)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
esp32_spi_set_regbits(spi_cmd_reg, SPI_USR_M);
|
||||
|
||||
esp32_spi_sem_waitdone(priv);
|
||||
|
||||
@@ -2782,6 +2782,8 @@
|
||||
#define SPI_DMA_RSTATUS_OFFSET (0x148)
|
||||
#define SPI_DMA_RSTATUS_REG(i) (REG_SPI_BASE(i) + SPI_DMA_RSTATUS_OFFSET)
|
||||
|
||||
#define SPI_DMA_TX_FIFO_EMPTY (BIT(31))
|
||||
|
||||
/* SPI_DMA_OUT_STATUS : RO ;bitpos:[31:0] ;default: 32'b0 ; */
|
||||
|
||||
/* Description: spi dma read data from memory status. */
|
||||
|
||||
Reference in New Issue
Block a user