mirror of
https://github.com/apache/nuttx.git
synced 2026-08-18 02:38:18 +00: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:
parent
ded5a6aae5
commit
e1ffc1075d
2 changed files with 13 additions and 0 deletions
|
|
@ -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. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue