You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/03/21 07:17:10 UTC

[incubator-nuttx] 02/02: xtensa/esp32: Fix interrupt flag configuration for DMA transfers

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e4efa9dfa7c9286e8fc4e07a36c2b7eca99e63d6
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Sat Mar 20 22:37:09 2021 -0300

    xtensa/esp32: Fix interrupt flag configuration for DMA transfers
    
    Previously SPI interrupts were enabled on DMA initialization. But since
    the addition of SPI Mixed mode it created a side-effect, breaking
    polling transfers. So now interrupts are enabled before the DMA
    transactions and disabled once they are finished.
    Furthermore, the transaction done flag is also cleared before a new
    transaction starts.
---
 arch/xtensa/src/esp32/esp32_spi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/src/esp32/esp32_spi.c b/arch/xtensa/src/esp32/esp32_spi.c
index 26f7eca..2ad5792 100644
--- a/arch/xtensa/src/esp32/esp32_spi.c
+++ b/arch/xtensa/src/esp32/esp32_spi.c
@@ -889,6 +889,9 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
       tp = rp;
     }
 
+  esp32_spi_reset_regbits(priv, SPI_SLAVE_OFFSET, SPI_TRANS_DONE_M);
+  esp32_spi_set_regbits(priv, SPI_SLAVE_OFFSET, SPI_INT_EN_M);
+
   while (bytes)
     {
       esp32_spi_set_reg(priv, SPI_DMA_IN_LINK_OFFSET, 0);
@@ -943,6 +946,8 @@ static void esp32_spi_dma_exchange(FAR struct esp32_spi_priv_s *priv,
       rp += n;
     }
 
+  esp32_spi_reset_regbits(priv, SPI_SLAVE_OFFSET, SPI_INT_EN_M);
+
 #ifdef CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP
   if (esp32_ptr_extram(rxbuffer))
     {
@@ -1303,8 +1308,6 @@ static void esp32_spi_init(FAR struct spi_dev_s *dev)
       esp32_spi_set_reg(priv, SPI_DMA_CONF_OFFSET, SPI_OUT_DATA_BURST_EN_M |
                                                    SPI_INDSCR_BURST_EN_M |
                                                    SPI_OUTDSCR_BURST_EN_M);
-
-      esp32_spi_set_regbits(priv, SPI_SLAVE_OFFSET, SPI_INT_EN_M);
     }
 
   esp32_spi_setfrequency(dev, config->clk_freq);