From ae079c1fc5d990ba55714d4b3a51b19f96edaec4 Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期四, 24 四月 2025 16:01:43 +0800
Subject: [PATCH] 改为中断来低电平触发发送当前扫描数据,3s内扫描不到的会退出,串口来55 AA 75 70 64 61 74 65,进入升级模式

---
 01_SDK/modules/hal/panchip/panplat/pan1070/bsp/peripheral/src/pan_dmac.c |   51 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/peripheral/src/pan_dmac.c b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/peripheral/src/pan_dmac.c
index ca11780..3459875 100644
--- a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/peripheral/src/pan_dmac.c
+++ b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/peripheral/src/pan_dmac.c
@@ -41,7 +41,7 @@
 /*
   * @brief	   :clear interrupt mask to make sure intterupt enable
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
   * @param in  :where FlgIdx is interrupt type,It could be:
   *                  DMAC_FLAG_INDEX_TFR    
   *                  DMAC_FLAG_INDEX_BLK    
@@ -62,7 +62,7 @@
 /*
   * @brief	   :mask interrupt,interrupt is useless
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
   * @param in  :where FlgIdx is interrupt type,It could be:
   *                  DMAC_FLAG_INDEX_TFR    
   *                  DMAC_FLAG_INDEX_BLK    
@@ -82,8 +82,8 @@
 /*
   * @brief	   :set dma channel config,include control register and config register
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2
-  * @param in  :where Config is the config of dma channel:    
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
+  * @param in  :where Config is the config of dma channel
   * @retval    :none
 */
 void DMAC_SetChannelConfig(DMA_T * dma,uint32_t ChIdx,DMAC_ChannelConfigTypeDef *Config)
@@ -97,8 +97,8 @@
 /*
   * @brief	   :get dma channel config,include control register and config register
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2
-  * @param in  :where Config is the config of dma channel:    
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
+  * @param in  :where Config is the config of dma channel
   * @retval    :none
 */
 void DMAC_GetChannelConfig(DMA_T * dma,uint32_t ChIdx,DMAC_ChannelConfigTypeDef *Config)
@@ -112,10 +112,10 @@
 /*
   * @brief	   :start dma channel to transmit
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2
-  * @param in  :where Src is the address of source data:    
-  * @param in  :where Dst is the address of destination data:      
-  * @param in  :where Len is the block size number:      
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
+  * @param in  :where Src is the address of source data
+  * @param in  :where Dst is the address of destination data
+  * @param in  :where Len is the block size number
   * @retval    :none
 */
 void DMAC_StartChannel(DMA_T * dma,uint32_t ChIdx,void* Src,void* Dst,uint32_t Len)
@@ -129,16 +129,45 @@
     /*DMA channel enable,start to transfer*/
     dma->CH_EN_REG_L |= (0x101ul << ChIdx);
 }
+
+/*
+  * @brief     :continue dma channel with last configuration
+  * @param in  :where dma is the base address of dma peripheral
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
+  * @param in  :where Len is the block size number
+  * @retval    :none
+*/
+void DMAC_ContinueChannel(DMA_T * dma,uint32_t ChIdx, uint32_t Len)
+{
+    /* Set the number of block size, block_size = data_len / DataWidth */
+    if(Len) dma->CH[ChIdx].CTL_H = (dma->CH[ChIdx].CTL_H & (~0xffful)) | Len;
+
+    /* DMA channel enable, start to transfer */
+    dma->CH_EN_REG_L |= (0x101ul << ChIdx);
+}
+
 /*
   * @brief	   :stop dma channel
   * @param in  :where dma is the base address of dma peripheral
-  * @param in  :where ChIdx is the dma channel number.It could be 0,1,2  
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
   * @retval    :none
 */
 void DMAC_StopChannel(DMA_T * dma,uint32_t ChIdx)
 {
     dma->CH_EN_REG_L = (dma->CH_EN_REG_L & (~(0x1ul << ChIdx))) | (0x100ul << ChIdx);
 }
+
+/*
+  * @brief     :Get data block count which already transferred by dma
+  * @param in  :where dma is the base address of dma peripheral
+  * @param in  :where ChIdx is the dma channel number.It could be 0,1
+  * @retval    :Transferred data count
+*/
+uint32_t DMAC_GetXferredBlockCount(DMA_T * dma, uint32_t ChIdx)
+{
+    return (dma->CH[ChIdx].CTL_H & 0x3fful);
+}
+
 /*
   * @brief	   :Acquire dma free channel
   * @param in  :where dma is the base address of dma peripheral      

--
Gitblit v1.9.3