| | |
| | | /* |
| | | * @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 |
| | |
| | | /* |
| | | * @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 |
| | |
| | | /* |
| | | * @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) |
| | |
| | | /* |
| | | * @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) |
| | |
| | | /* |
| | | * @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) |
| | |
| | | /*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 |