Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/esp32_spi: Add check to see if the TX_FIFO is empty #15904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions arch/xtensa/src/esp32/esp32_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions arch/xtensa/src/esp32/hardware/esp32_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down