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