From 0c3653b1fd7151001143451d4aa95dbf15ee8506 Mon Sep 17 00:00:00 2001 From: Armando Date: Tue, 24 Nov 2020 15:49:38 +0800 Subject: [PATCH] spi_master: fix master HD mode cannot correctly receive data issue when using DMA. Issue Description: If master is in HD mode, if it sends data without receiving data, it will still enable the RX DMA because of old version ESP32 silicon issue. And because there is no correctly linked RX DMA descriptor, an ``inlink_dscr_error`` intr will be seen, which will influence the following RX transactions. Solution: Trigge this workaround only in FD mode. TODO: Add a test to check if this workaround related issue does exit. If so, reporting to Digital Team is also needed. --- components/hal/spi_hal_iram.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/hal/spi_hal_iram.c b/components/hal/spi_hal_iram.c index 91ae71c36b..821c26e543 100644 --- a/components/hal/spi_hal_iram.c +++ b/components/hal/spi_hal_iram.c @@ -151,13 +151,16 @@ void spi_hal_prepare_data(spi_hal_context_t *hal, const spi_hal_dev_config_t *de spi_dma_ll_rx_start(hal->dma_in, hal->dma_config.dmadesc_rx); } - } else { + } +#if CONFIG_IDF_TARGET_ESP32 + else { //DMA temporary workaround: let RX DMA work somehow to avoid the issue in ESP32 v0/v1 silicon - if (hal->dma_enabled) { + if (hal->dma_enabled && !dev->half_duplex) { spi_ll_dma_rx_enable(hal->hw, 1); spi_dma_ll_rx_start(hal->dma_in, 0); } } +#endif if (trans->send_buffer) { if (!hal->dma_enabled) {