DMA Manager provides a series of functions to manage the DMAMUX instances and channels.
Function groups
DMAMGR Initialization and De-initialization
This function group initializes and deinitializes the DMA Manager.
DMAMGR Operation
This function group requests/releases the DMAMUX channel and configures the channel request source.
Typical use case
DMAMGR static channel allocattion
uint8_t channel;
DMAMGR_Init(&dmamanager_handle, EXAMPLE_DMA_BASEADDR, DMA_CHANNEL_NUMBER, startChannel);
channel = kDMAMGR_STATIC_ALLOCATE;
DMAMGR dynamic channel allocation
uint8_t channel;
DMAMGR_Init(&dmamanager_handle, EXAMPLE_DMA_BASEADDR, DMA_CHANNEL_NUMBER, startChannel);
struct dmamanager_handle_t |
- Note
- The contents of this structure are private and subject to change.
This dma manager handle structure is used to store the parameters transfered by users.And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory.
Data Fields |
void * | dma_base |
| Peripheral DMA instance. More...
|
|
uint32_t | channelNum |
| Channel numbers for the DMA instance which need to be managed by dma manager. More...
|
|
uint32_t | startChannel |
| The start channel that can be managed by dma manager,users need to transfer it with a certain number or NULL. More...
|
|
bool | s_DMAMGR_Channels [64] |
| The s_DMAMGR_Channels is used to store dma manager state. More...
|
|
uint32_t | DmamuxInstanceStart |
| The DmamuxInstance is used to calculate the DMAMUX Instance according to the DMA Instance. More...
|
|
uint32_t | multiple |
| The multiple is used to calculate the multiple between DMAMUX count and DMA count. More...
|
|
void* dmamanager_handle_t::dma_base |
uint32_t dmamanager_handle_t::channelNum |
uint32_t dmamanager_handle_t::startChannel |
bool dmamanager_handle_t::s_DMAMGR_Channels[64] |
uint32_t dmamanager_handle_t::DmamuxInstanceStart |
uint32_t dmamanager_handle_t::multiple |
#define DMAMGR_DYNAMIC_ALLOCATE 0xFFU |
Enumerator |
---|
kStatus_DMAMGR_ChannelOccupied |
Channel has been occupied.
|
kStatus_DMAMGR_ChannelNotUsed |
Channel has not been used.
|
kStatus_DMAMGR_NoFreeChannel |
All channels have been occupied.
|
void DMAMGR_Init |
( |
dmamanager_handle_t * |
dmamanager_handle, |
|
|
DMA_Type * |
dma_base, |
|
|
uint32_t |
channelNum, |
|
|
uint32_t |
startChannel |
|
) |
| |
This function initializes the DMA manager, ungates the DMAMUX clocks, and initializes the eDMA or DMA peripherals.
- Parameters
-
dmamanager_handle | DMA manager handle pointer, this structure is maintained by dma manager internal,users only need to transfer the structure to the function. And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory. |
dma_base | Peripheral DMA instance base pointer. |
dmamux_base | Peripheral DMAMUX instance base pointer. |
channelNum | Channel numbers for the DMA instance which need to be managed by dma manager. |
startChannel | The start channel that can be managed by dma manager. |
This function deinitializes the DMA manager, disables the DMAMUX channels, gates the DMAMUX clocks, and deinitializes the eDMA or DMA peripherals.
- Parameters
-
dmamanager_handle | DMA manager handle pointer, this structure is maintained by dma manager internal,users only need to transfer the structure to the function. And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory. |
status_t DMAMGR_RequestChannel |
( |
dmamanager_handle_t * |
dmamanager_handle, |
|
|
uint32_t |
requestSource, |
|
|
uint32_t |
channel, |
|
|
void * |
handle |
|
) |
| |
This function requests a DMA channel which is not occupied. The two channels to allocate the mechanism are dynamic and static channels. For the dynamic allocation mechanism (channe = DMAMGR_DYNAMIC_ALLOCATE), DMAMGR allocates a DMA channel according to the given request source and startChannel and then configures it. For static allocation mechanism, DMAMGR configures the given channel according to the given request source and channel number.
- Parameters
-
dmamanager_handle | DMA manager handle pointer, this structure is maintained by dma manager internal,users only need to transfer the structure to the function. And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory. |
requestSource | DMA channel request source number. See the soc.h, see the enum dma_request_source_t |
channel | The channel number users want to occupy. If using the dynamic channel allocate mechanism, set the channel equal to DMAMGR_DYNAMIC_ALLOCATE. |
handle | DMA or eDMA handle pointer. |
- Return values
-
kStatus_Success | In a dynamic/static channel allocation mechanism, allocate the DMAMUX channel successfully. |
kStatus_DMAMGR_NoFreeChannel | In a dynamic channel allocation mechanism, all DMAMUX channels are occupied. |
kStatus_DMAMGR_ChannelOccupied | In a static channel allocation mechanism, the given channel is occupied. |
This function releases an occupied DMA channel.
- Parameters
-
dmamanager_handle | DMA manager handle pointer, this structure is maintained by dma manager internal,users only need to transfer the structure to the function. And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory. |
handle | DMA or eDMA handle pointer. |
- Return values
-
kStatus_Success | Releases the given channel successfully. |
kStatus_DMAMGR_ChannelNotUsed | The given channel to be released had not been used before. |
This function get a DMA channel status. Return 0 indicates the channel has not been used, return 1 indicates the channel has been occupied.
- Parameters
-
dmamanager_handle | DMA manager handle pointer, this structure is maintained by dma manager internal,users only need to transfer the structure to the function. And users shall not free the memory before calling DMAMGR_Deinit, also shall not modify the contents of the memory. |
channel | The channel number that users want get its status. |