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

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

commit f286a63223924ca863add512b430644aaa9c8748
Author: Eren Terzioglu <eren.terzio...@espressif.com>
AuthorDate: Thu Jan 30 11:02:42 2025 +0100

    esp32[c3|c6|h2]: Add DMA function to have more capabilites
    Add DMA function to increase DMA peripheral capabilities
    
    Signed-off-by: Eren Terzioglu <eren.terzio...@espressif.com>
---
 arch/risc-v/src/common/espressif/esp_dma.c | 146 +++++++++++++++++++++++++++++
 arch/risc-v/src/common/espressif/esp_dma.h |  88 +++++++++++++++++
 2 files changed, 234 insertions(+)

diff --git a/arch/risc-v/src/common/espressif/esp_dma.c 
b/arch/risc-v/src/common/espressif/esp_dma.c
index 233b717c25..c501ef853b 100644
--- a/arch/risc-v/src/common/espressif/esp_dma.c
+++ b/arch/risc-v/src/common/espressif/esp_dma.c
@@ -282,6 +282,125 @@ void esp_dma_load(struct esp_dmadesc_s *dmadesc, int 
chan, bool tx)
     }
 }
 
+/****************************************************************************
+ * Name: esp_dma_enable_interrupt
+ *
+ * Description:
+ *   Enable/Disable DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *   mask - Interrupt mask to change
+ *   en   - true: enable; false: disable
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_enable_interrupt(int chan, bool tx, uint32_t mask, bool en)
+{
+  if (tx)
+    {
+      gdma_ll_tx_enable_interrupt(ctx.dev, chan, mask, en);
+    }
+  else
+    {
+      gdma_ll_rx_enable_interrupt(ctx.dev, chan, mask, en);
+    }
+}
+
+/****************************************************************************
+ * Name: esp_dma_get_interrupt
+ *
+ * Description:
+ *   Gets DMA interrupt status.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   Interrupt status value.
+ *
+ ****************************************************************************/
+
+int esp_dma_get_interrupt(int chan, bool tx)
+{
+  uint32_t intr_status = 0;
+
+  if (tx)
+    {
+      intr_status = gdma_ll_tx_get_interrupt_status(ctx.dev, chan);
+    }
+  else
+    {
+      intr_status = gdma_ll_rx_get_interrupt_status(ctx.dev, chan);
+    }
+
+  return intr_status;
+}
+
+/****************************************************************************
+ * Name: esp_dma_clear_interrupt
+ *
+ * Description:
+ *   Clear DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *   mask - Interrupt mask to change
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_clear_interrupt(int chan, bool tx, uint32_t mask)
+{
+  if (tx)
+    {
+      gdma_ll_tx_clear_interrupt_status(ctx.dev, chan, mask);
+    }
+  else
+    {
+      gdma_ll_rx_clear_interrupt_status(ctx.dev, chan, mask);
+    }
+}
+
+/****************************************************************************
+ * Name: esp_dma_get_desc_addr
+ *
+ * Description:
+ *   Gets desc addr of DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   Desc addr.
+ *
+ ****************************************************************************/
+
+int esp_dma_get_desc_addr(int chan, bool tx)
+{
+  uint32_t desc_addr = 0;
+
+  if (tx)
+    {
+      desc_addr = gdma_ll_tx_get_eof_desc_addr(ctx.dev, chan);
+    }
+  else
+    {
+      desc_addr = gdma_ll_rx_get_success_eof_desc_addr(ctx.dev, chan);
+    }
+
+  return desc_addr;
+}
+
 /****************************************************************************
  * Name: esp_dma_enable
  *
@@ -363,6 +482,33 @@ void esp_dma_wait_idle(int chan, bool tx)
     }
 }
 
+/****************************************************************************
+ * Name: esp_dma_reset_channel
+ *
+ * Description:
+ *   Resets dma channel.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_reset_channel(int chan, bool tx)
+{
+  if (tx)
+    {
+      gdma_ll_tx_reset_channel(ctx.dev, chan);
+    }
+  else
+    {
+      gdma_ll_rx_reset_channel(ctx.dev, chan);
+    }
+}
+
 /****************************************************************************
  * Name: esp_dma_init
  *
diff --git a/arch/risc-v/src/common/espressif/esp_dma.h 
b/arch/risc-v/src/common/espressif/esp_dma.h
index d1b43156eb..57b2ded6b7 100644
--- a/arch/risc-v/src/common/espressif/esp_dma.h
+++ b/arch/risc-v/src/common/espressif/esp_dma.h
@@ -150,6 +150,77 @@ uint32_t esp_dma_setup(int chan, bool tx,
 
 void esp_dma_load(struct esp_dmadesc_s *dmadesc, int chan, bool tx);
 
+/****************************************************************************
+ * Name: esp_dma_enable_interrupt
+ *
+ * Description:
+ *   Enable DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *   mask - Interrupt mask to change
+ *   en   - true: enable; false: disable
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_enable_interrupt(int chan, bool tx, uint32_t mask, bool en);
+
+/****************************************************************************
+ * Name: esp_dma_get_interrupt
+ *
+ * Description:
+ *   Gets DMA interrupt status.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   Interrupt status value.
+ *
+ ****************************************************************************/
+
+int esp_dma_get_interrupt(int chan, bool tx);
+
+/****************************************************************************
+ * Name: esp_dma_clear_interrupt
+ *
+ * Description:
+ *   Clear DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *   mask - Interrupt mask to change
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_clear_interrupt(int chan, bool tx, uint32_t mask);
+
+/****************************************************************************
+ * Name: esp_dma_get_desc_addr
+ *
+ * Description:
+ *   Gets desc addr of DMA interrupt.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   Desc addr.
+ *
+ ****************************************************************************/
+
+int esp_dma_get_desc_addr(int chan, bool tx);
+
 /****************************************************************************
  * Name: esp_dma_enable
  *
@@ -201,6 +272,23 @@ void esp_dma_disable(int chan, bool tx);
 
 void esp_dma_wait_idle(int chan, bool tx);
 
+/****************************************************************************
+ * Name: esp_dma_reset_channel
+ *
+ * Description:
+ *   Resets dma channel.
+ *
+ * Input Parameters:
+ *   chan - DMA channel
+ *   tx   - true: TX mode; false: RX mode
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+void esp_dma_reset_channel(int chan, bool tx);
+
 /****************************************************************************
  * Name: esp_dma_init
  *

Reply via email to