PAN1080 Peripheral API
Modules | Data Structures | Macros | Typedefs | Functions
Dma Interface

Dma Interface. More...

Collaboration diagram for Dma Interface:

Modules

 Dma transfer type
 Dma transfer type definition.
 
 Dma burst lenth
 Dma burst lenth definition.
 
 Dma memory address state
 Dma memory address state definition.
 
 Dma data width select
 Dma data width select definition.
 
 Dma channel function
 Dma channel function definition.
 
 Dma handshake polarity
 Dma handshake polarity definition.
 
 Dma handshake control
 Dma handshake control definition.
 
 Dma channel priority
 Dma channel priority definition.
 
 Dma interrupt status
 Dma interrupt status definition.
 
 Dma interrupt mask
 Dma interrupt mask definition.
 

Data Structures

struct  __DMAC_ChannelConfigTypeDef
 Structure with dma channel config feature. More...
 
struct  DMAC_ChannelConfigTypeDef
 Structure with dma channel detail config. More...
 

Macros

#define DMAC_CHANNEL_NUMBER   (3)
 
#define DMA_INVLID_CHANNEL   (~0ul)
 
#define DMAC_FlowControl_DMA   (0)
 
#define DMAC_FlowControl_Peripheral   (1)
 
#define DMAC_LockLevel_Tfr_Complete   (0)
 
#define DMAC_LockLevel_Block_Complete   (1)
 
#define DMAC_LockLevel_Transaction_Complete   (2)
 
#define DMAC_CHANNELALL_MASK   (~((~0ul)<<DMAC_CHANNEL_NUMBER))
 
#define DMAC_ChannelMask(idx)   (1ul<<(idx))
 :Set interrupt mask of one dma channel More...
 

Typedefs

typedef struct __DMAC_ChannelConfigTypeDef __DMAC_ChannelConfigTypeDef
 Structure with dma channel config feature. More...
 
typedef struct DMAC_ChannelConfigTypeDef DMAC_ChannelConfigTypeDef
 Structure with dma channel detail config. More...
 

Functions

__STATIC_INLINE uint32_t DMAC_IsChannelValid (DMA_T *dma, uint32_t ChIdx)
 Adjust dma channel is busy or not. More...
 
__STATIC_INLINE uint32_t DMAC_CombinedIntStatus (DMA_T *dma, uint32_t FlgMsk)
 Adjust interrupt occured or not. More...
 
__STATIC_INLINE uint32_t DMAC_StatusFlag (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Adjust interrupt raw flag set or not. More...
 
__STATIC_INLINE uint32_t DMAC_IntFlag (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Adjust interrupt event occured or not after masking. More...
 
__STATIC_INLINE uint32_t DMAC_IntFlagMsk (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Adjust interrupt mask set or not. More...
 
__STATIC_INLINE void DMAC_ClrIntFlag (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Adjust interrupt mask cleared or not. More...
 
void DMAC_Init (DMA_T *dma)
 Enable dma. More...
 
void DMAC_DeInit (DMA_T *dma)
 Disable dma & mask all dma interrupt. More...
 
void DMAC_ClrIntFlagMsk (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Clear interrupt mask to make sure intterupt enable. More...
 
void DMAC_SetIntFlagMsk (DMA_T *dma, uint32_t ChIdx, uint32_t FlgIdx)
 Mask interrupt,interrupt is useless. More...
 
void DMAC_SetChannelConfig (DMA_T *dma, uint32_t ChIdx, DMAC_ChannelConfigTypeDef *Config)
 Set dma channel config,include control register and config register. More...
 
void DMAC_GetChannelConfig (DMA_T *dma, uint32_t ChIdx, DMAC_ChannelConfigTypeDef *Config)
 Get dma channel config,include control register and config register. More...
 
void DMAC_StartChannel (DMA_T *dma, uint32_t ChIdx, void *Src, void *Dst, uint32_t Len)
 Start dma channel to transmit. More...
 
void DMAC_StopChannel (DMA_T *dma, uint32_t ChIdx)
 Stop dma channel. More...
 
uint32_t DMAC_AcquireChannel (DMA_T *dma)
 Acquire dma free channel. More...
 
void DMAC_ReleaseChannel (DMA_T *dma, uint32_t ChIdx)
 Release dma channel. More...
 

Detailed Description

Dma Interface.

Macro Definition Documentation

◆ DMA_INVLID_CHANNEL

#define DMA_INVLID_CHANNEL   (~0ul)

return value after acquire no dma channel

◆ DMAC_CHANNEL_NUMBER

#define DMAC_CHANNEL_NUMBER   (3)

Number of available dma channels

◆ DMAC_CHANNELALL_MASK

#define DMAC_CHANNELALL_MASK   (~((~0ul)<<DMAC_CHANNEL_NUMBER))

Set interrupt mask of all dma channel

◆ DMAC_ChannelMask

#define DMAC_ChannelMask (   idx)    (1ul<<(idx))

:Set interrupt mask of one dma channel

Parameters
:Whereidx is the dma channel number.It could be 0,1,2
Returns
:None

◆ DMAC_FlowControl_DMA

#define DMAC_FlowControl_DMA   (0)

Flow controlled by dma

◆ DMAC_FlowControl_Peripheral

#define DMAC_FlowControl_Peripheral   (1)

Flow controlled by peripheral

◆ DMAC_LockLevel_Block_Complete

#define DMAC_LockLevel_Block_Complete   (1)

Over complete DMA block transfer

◆ DMAC_LockLevel_Tfr_Complete

#define DMAC_LockLevel_Tfr_Complete   (0)

Over complete DMA transfer

◆ DMAC_LockLevel_Transaction_Complete

#define DMAC_LockLevel_Transaction_Complete   (2)

Over complete DMA transaction

Typedef Documentation

◆ __DMAC_ChannelConfigTypeDef

Structure with dma channel config feature.

Parameters
CTL_LLow 32 bit of dma channel control register.
CTL_HHigh 32 bit of dma channel control register.
CFG_LLow 32 bit of dma channel config register.
CFG_HHigh 32 bit of dma channel config register.

◆ DMAC_ChannelConfigTypeDef

Structure with dma channel detail config.

Parameters
IntEnableInterrupt enable bit.
DataWidthDstDestination data width. Dma data width select
DataWidthSrcSource data width. Dma data width select
AddrChangeDstDestination address change. Dma memory address state
AddrChangeSrcSource address change. Dma memory address state
BurstLenDstDestination burst transaction length. Dma burst lenth
BurstLenSrcSource burst transaction length. Dma burst lenth
GatherEnSrcSource gather enable bit.
ScatterEnDstDestination scatter enable bit.
__Rev0reversed bit.
TransferTypeTransfer Type. Dma transfer type
FlowControlFlow Control DMAC_FlowControl_Peripheral, DMAC_FlowControl_DMA
__Rev1reversed bit.
BlockSizeBlock size number ,block_size = data_len / DataWidth.
DoneDone flag.
__Rev2reversed bit.
__Rev3reversed bit.
ChannelPriorityChannel priority,it can be 0~7,the priority 7 is the highest.
ChannelSuspendChannel Suspend,transfer is not complete ,set this bit can stop transmit.
FifoEmptyIndicates if there is data left in the channel FIFO
HandshakeDstDestination Handshake select:software or hardware
HandshakeSrcSource Handshake select:software or hardware
LockBusWhen active, the AHB bus master signal hlock is asserted for the duration specified in CFGx.LOCK_B_L.
LockChannelWhen the channel is granted control of the master bus interface and if the CFGx.LOCK_CH bit is asserted,then no other channels are granted control of the master bus interface for the duration specified in CFGx.LOCK_CH_L
LockBusLevelIndicates the duration over which CFGx.LOCK_B bit applies.
LockChannelLevelIndicates the duration over which CFGx.LOCK_CH bit applies.
HandshakePolarityDstDestination Handshaking Interface Polarity:0-high, 1-low.
HandshakePolaritySrcSource Handshaking Interface Polarity:0-high, 1-low.
__Rev4reversed bit.
AutoReloadSrcAutomatic Source Reload.
AutoReloadDstAutomatic Destination Reload.
FlowControlModeDetermines when source transaction requests are serviced when the Destination Peripheral is the flow controller.
FifoModeDetermines how much space or data needs to be available in the FIFO.
ProtectControlUsed to drive the AHB HPROT[3:1] bus.
__Rev5reversed bit.
PeripheralSrcAssigns a hardware handshaking interface to the source of channel x if the CFGx.HS_SEL_SRC field is 0
PeripheralDstAssigns a hardware handshaking interface to the destination of channel x if the CFGx.HS_SEL_DST field is 0
__Rev6reversed bit.

Function Documentation

◆ DMAC_AcquireChannel()

uint32_t DMAC_AcquireChannel ( DMA_T *  dma)

Acquire dma free channel.

Parameters
dmaWhere dma is the base address of dma peripheral
Returns
None

◆ DMAC_ClrIntFlag()

__STATIC_INLINE void DMAC_ClrIntFlag ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Adjust interrupt mask cleared or not.

Parameters
dmawhere dma is the base address of dma peripheral
ChIdxwhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxwhere FlgIdx is interrupt type,It could be:Dma interrupt status
Returns
None

◆ DMAC_ClrIntFlagMsk()

void DMAC_ClrIntFlagMsk ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Clear interrupt mask to make sure intterupt enable.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxWhere FlgIdx is interrupt type,It could be: DMAC_FLAG_INDEX_TFR
DMAC_FLAG_INDEX_BLK
DMAC_FLAG_INDEX_SRCTFR DMAC_FLAG_INDEX_DSTTFR DMAC_FLAG_INDEX_ERR
Returns
None

◆ DMAC_CombinedIntStatus()

__STATIC_INLINE uint32_t DMAC_CombinedIntStatus ( DMA_T *  dma,
uint32_t  FlgMsk 
)

Adjust interrupt occured or not.

Parameters
dmaWhere dma is the base address of dma peripheral
FlgMskWhere flgMsk is combined interrupt status ,it could be: DMAC_FLAG_MASK_TFR
DMAC_FLAG_MASK_BLK
DMAC_FLAG_MASK_SRCTFR DMAC_FLAG_MASK_DSTTFR DMAC_FLAG_MASK_ERR
DMAC_FLAG_MASK_ALL
Return values
0dma interrupt did not occurred
1dma interrupt occurred

◆ DMAC_DeInit()

void DMAC_DeInit ( DMA_T *  dma)

Disable dma & mask all dma interrupt.

Parameters
dmaWhere dma is the base address of dma peripheral
Returns
None

◆ DMAC_GetChannelConfig()

void DMAC_GetChannelConfig ( DMA_T *  dma,
uint32_t  ChIdx,
DMAC_ChannelConfigTypeDef Config 
)

Get dma channel config,include control register and config register.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
ConfigWhere Config is the config of dma channel. DMAC_ChannelConfigTypeDef
Returns
None

◆ DMAC_Init()

void DMAC_Init ( DMA_T *  dma)

Enable dma.

Parameters
dmaWhere dma is the base address of dma peripheral
Returns
None

◆ DMAC_IntFlag()

__STATIC_INLINE uint32_t DMAC_IntFlag ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Adjust interrupt event occured or not after masking.

Parameters
dmawhere dma is the base address of dma peripheral
ChIdxwhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxwhere FlgIdx is interrupt type,It could be:Dma interrupt status
Returns
None

◆ DMAC_IntFlagMsk()

__STATIC_INLINE uint32_t DMAC_IntFlagMsk ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Adjust interrupt mask set or not.

Parameters
dmawhere dma is the base address of dma peripheral
ChIdxwhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxwhere FlgIdx is interrupt type,It could be:Dma interrupt status
Returns
None

◆ DMAC_IsChannelValid()

__STATIC_INLINE uint32_t DMAC_IsChannelValid ( DMA_T *  dma,
uint32_t  ChIdx 
)

Adjust dma channel is busy or not.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere chidx is the dma channel number.It could be 0,1,2
Return values
0dma channel invalid
1dma channel valid

◆ DMAC_ReleaseChannel()

void DMAC_ReleaseChannel ( DMA_T *  dma,
uint32_t  ChIdx 
)

Release dma channel.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
Returns
None

◆ DMAC_SetChannelConfig()

void DMAC_SetChannelConfig ( DMA_T *  dma,
uint32_t  ChIdx,
DMAC_ChannelConfigTypeDef Config 
)

Set dma channel config,include control register and config register.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
ConfigWhere Config is the config of dma channel. DMAC_ChannelConfigTypeDef
Returns
None

◆ DMAC_SetIntFlagMsk()

void DMAC_SetIntFlagMsk ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Mask interrupt,interrupt is useless.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxWhere FlgIdx is interrupt type,It could be: DMAC_FLAG_INDEX_TFR
DMAC_FLAG_INDEX_BLK
DMAC_FLAG_INDEX_SRCTFR DMAC_FLAG_INDEX_DSTTFR DMAC_FLAG_INDEX_ERR
Returns
None

◆ DMAC_StartChannel()

void DMAC_StartChannel ( DMA_T *  dma,
uint32_t  ChIdx,
void *  Src,
void *  Dst,
uint32_t  Len 
)

Start dma channel to transmit.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
SrcWhere Src is the address of source data:
DstWhere Dst is the address of destination data:
LenWhere Len is the block size number:
Returns
None

◆ DMAC_StatusFlag()

__STATIC_INLINE uint32_t DMAC_StatusFlag ( DMA_T *  dma,
uint32_t  ChIdx,
uint32_t  FlgIdx 
)

Adjust interrupt raw flag set or not.

Parameters
dmawhere dma is the base address of dma peripheral
ChIdxwhere ChIdx is the dma channel number.It could be 0,1,2
FlgIdxwhere FlgIdx is interrupt type,It could be:Dma interrupt status
Returns
None

◆ DMAC_StopChannel()

void DMAC_StopChannel ( DMA_T *  dma,
uint32_t  ChIdx 
)

Stop dma channel.

Parameters
dmaWhere dma is the base address of dma peripheral
ChIdxWhere ChIdx is the dma channel number.It could be 0,1,2
Returns
None