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

[incubator-nuttx] 01/02: risc-v/esp32c3: Add burst transfer support for GDMA

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

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

commit 132ffdd28d3e1f77ef8d08282f6f1aff8b67c578
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Tue May 11 13:37:58 2021 -0300

    risc-v/esp32c3: Add burst transfer support for GDMA
---
 arch/risc-v/src/esp32c3/esp32c3_dma.c | 29 +++++++++++++++++++++++------
 arch/risc-v/src/esp32c3/esp32c3_dma.h |  4 +++-
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/esp32c3_dma.c b/arch/risc-v/src/esp32c3/esp32c3_dma.c
index 384c6de..4d744e4 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_dma.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_dma.c
@@ -81,9 +81,10 @@ static sem_t g_dma_exc_sem = SEM_INITIALIZER(1);
  *   Request DMA channel and config it with given parameters.
  *
  * Input Parameters:
- *   periph  - Peripheral for which the DMA channel request was made
- *   tx_prio - Interrupt priority
- *   rx_prio - Interrupt flags
+ *   periph   - Peripheral for which the DMA channel request was made
+ *   tx_prio  - Interrupt priority
+ *   rx_prio  - Interrupt flags
+ *   burst_en - Enable burst transmission
  *
  * Returned Value:
  *   DMA channel number (>=0) if success or -1 if fail.
@@ -92,7 +93,8 @@ static sem_t g_dma_exc_sem = SEM_INITIALIZER(1);
 
 int32_t esp32c3_dma_request(enum esp32c3_dma_periph_e periph,
                             uint32_t tx_prio,
-                            uint32_t rx_prio)
+                            uint32_t rx_prio,
+                            bool burst_en)
 {
   int chan;
 
@@ -145,12 +147,27 @@ int32_t esp32c3_dma_request(enum esp32c3_dma_periph_e periph,
 
       CLR_BITS(DMA_IN_CONF0_CH0_REG, chan, DMA_MEM_TRANS_EN_CH0_M);
 
-      /* Connect DMA TX/RX channel to a given peripheral */
+      /* Connect DMA TX/RX channels to a given peripheral */
 
       SET_REG(DMA_OUT_PERI_SEL_CH0_REG, chan, periph);
       SET_REG(DMA_IN_PERI_SEL_CH0_REG, chan, periph);
     }
 
+  if (burst_en)
+    {
+      /* Enable DMA TX/RX channels burst sending data */
+
+      SET_BITS(DMA_IN_CONF0_CH0_REG, chan, DMA_OUT_DATA_BURST_EN_CH0_M);
+      SET_BITS(DMA_IN_CONF0_CH0_REG, chan, DMA_IN_DATA_BURST_EN_CH0_M);
+
+      /* Enable DMA TX/RX channels burst reading descriptor link */
+
+      SET_BITS(DMA_IN_CONF0_CH0_REG, chan, DMA_OUTDSCR_BURST_EN_CH0_M);
+      SET_BITS(DMA_IN_CONF0_CH0_REG, chan, DMA_INDSCR_BURST_EN_CH0_M);
+    }
+
+  /* Set priority for DMA TX/RX channels */
+
   SET_REG(DMA_OUT_PRI_CH0_REG, chan, tx_prio);
   SET_REG(DMA_IN_PRI_CH0_REG, chan, rx_prio);
 
@@ -435,7 +452,7 @@ void esp32c3_dma_main(int argc, char *argv[])
 
   esp32c3_dma_init();
 
-  chan = esp32c3_dma_request(ESP32C3_DMA_PERIPH_MEM, 1, 1);
+  chan = esp32c3_dma_request(ESP32C3_DMA_PERIPH_MEM, 1, 1, false);
   if (chan < 0)
     {
       syslog(LOG_ERR, "Request DMA channel error\n");
diff --git a/arch/risc-v/src/esp32c3/esp32c3_dma.h b/arch/risc-v/src/esp32c3/esp32c3_dma.h
index 5dbb72c..ada371d 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_dma.h
+++ b/arch/risc-v/src/esp32c3/esp32c3_dma.h
@@ -26,6 +26,7 @@
 #define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_DMA_H
 
 #include <nuttx/config.h>
+#include <stdbool.h>
 #include <stdint.h>
 
 #ifndef __ASSEMBLY__
@@ -122,7 +123,8 @@ struct esp32c3_dmadesc_s
 
 int32_t esp32c3_dma_request(enum esp32c3_dma_periph_e periph,
                             uint32_t tx_prio,
-                            uint32_t rx_prio);
+                            uint32_t rx_prio,
+                            bool burst_en);
 
 /****************************************************************************
  * Name: esp32c3_dma_setup