This section describes the programming interface of the DMA Peripheral driver. The DMA driver requests, configures, and uses the DMA hardware. It supports module initialization and DMA channel configuration.
|
DMA_Type *const | g_dmaBase [DMA_INSTANCE_COUNT] |
| Array for eDMA module register base address. More...
|
|
DMAMUX_Type *const | g_dmamuxBase [DMAMUX_INSTANCE_COUNT] |
| Array for DMAMUX module register base address. More...
|
|
const IRQn_Type | g_dmaIrqId [DMA_INSTANCE_COUNT][FSL_FEATURE_DMA_DMAMUX_CHANNELS] |
| Two-dimensional array for eDMA channel interrupt vector number. More...
|
|
|
dma_status_t | DMA_DRV_Init (dma_state_t *state) |
| Initializes the DMA. More...
|
|
dma_status_t | DMA_DRV_Deinit (void) |
| De-initializes the DMA. More...
|
|
dma_status_t | DMA_DRV_SetDestTransferSize (dma_channel_t *chn, uint32_t transferSize) |
| Updates the DMA destination transfer size. More...
|
|
dma_status_t | DMA_DRV_SetSourceTransferSize (dma_channel_t *chn, uint32_t transferSize) |
| Updates the DMA source transfer size. More...
|
|
dma_status_t | DMA_DRV_RegisterCallback (dma_channel_t *chn, dma_callback_t callback, void *para) |
| Registers the callback function and a parameter. More...
|
|
uint32_t | DMA_DRV_GetUnfinishedBytes (dma_channel_t *chn) |
| Gets the number of unfinished bytes. More...
|
|
dma_status_t | DMA_DRV_ClaimChannel (uint32_t channel, dma_request_source_t source, dma_channel_t *chn) |
| Claims a DMA channel. More...
|
|
uint32_t | DMA_DRV_RequestChannel (uint32_t channel, dma_request_source_t source, dma_channel_t *chn) |
| Requests a DMA channel. More...
|
|
dma_status_t | DMA_DRV_FreeChannel (dma_channel_t *chn) |
| Frees DMA channel hardware and software resource. More...
|
|
dma_status_t | DMA_DRV_StartChannel (dma_channel_t *chn) |
| Starts a DMA channel. More...
|
|
dma_status_t | DMA_DRV_StopChannel (dma_channel_t *chn) |
| Stops a DMA channel. More...
|
|
dma_status_t | DMA_DRV_ConfigTransfer (dma_channel_t *chn, dma_transfer_type_t type, uint32_t size, uint32_t sourceAddr, uint32_t destAddr, uint32_t length) |
| Configures a transfer for the DMA. More...
|
|
dma_status_t | DMA_DRV_ConfigChanLink (dma_channel_t *chn, dma_channel_link_config_t *link_config) |
| Configures the channel link feature. More...
|
|
void | DMA_DRV_IRQhandler (uint32_t channel) |
| DMA IRQ handler for both an interrupt and an error. More...
|
|
A prototype for the callback function registered into the DMA driver.
A structure describing the status of the DMA channel. The user can get the status from the channel callback function.
Enumerator |
---|
kDmaIdle |
DMA channel is idle.
|
kDmaNormal |
DMA channel is occupied.
|
kDmaError |
Error occurs in the DMA channel.
|
Enumerator |
---|
kDmaInvalidChannel |
Macros indicating the failure of the channel request.
|
kDmaAnyChannel |
Macros used when requesting a channel.
kEdmaAnyChannel means a request of dynamic channel allocation.
|
- Parameters
-
state | DMA state structure used for the DMA internal logic. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Parameters
-
chn | A handler for the DMA channel |
transferSize | Size of destination at each transfer |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Parameters
-
chn | A handler for the DMA channel |
transferSize | Size of source at each transfer |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
The user registers the callback function and a parameter for a specified DMA channel. When the channel interrupt or a channel error happens, the callback and the parameter are called. The user parameter is also provided to give a channel status.
- Parameters
-
chn | A handler for the DMA channel |
callback | Callback function |
para | A parameter for callback functions |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
Gets the bytes that remain to be transferred.
- Parameters
-
chn | A handler for the DMA channel |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Parameters
-
channel | Channel index which needs to claim. |
source | DMA request source. |
chn | A handler for the DMA channel |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
This function provides two ways to allocate a DMA channel: static and dynamic allocation. To allocate a channel dynamically, set the channel parameter with the value of kDmaAnyChannel. The driver searches all available free channels and assigns the first channel to the user. To allocate the channel statically, set the channel parameter with the value of a specified channel. If the channel is available, the driver assigns the channel. Notes: The user must provide a handler memory for the DMA channel. The driver initializes the handler and configures the handler memory.
- Parameters
-
channel | A DMA channel number. If a channel is assigned with a valid channel number, the DMA driver tries to assign a specified channel. If a channel is assigned with kDmaAnyChannel, the DMA driver searches all available channels and assigns the first channel to the user. |
source | A DMA hardware request. |
chn | Memory pointing to DMA channel. The user must ensure that the handler memory is valid and that it will not be released or changed by any other code before the channel dma_free_channel() operation. |
- Returns
- If the channel allocation is successful, the return value indicates the requested channel. If not, the driver returns a kDmaInvalidChannel value to indicate that the request operation has failed.
This function frees the relevant software and hardware resources. Both the request and the free operations need to be called as a pair.
- Parameters
-
chn | Memory pointing to DMA channel. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
Starts a DMA channel. The driver starts a DMA channel by enabling the DMA request. A software start bit is not used in the DMA Peripheral driver.
- Parameters
-
chn | Memory pointing to the DMA channel. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Parameters
-
chn | Memory pointing to the DMA channel. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
Configures a transfer for the DMA.
- Parameters
-
chn | Memory pointing to the DMA channel. |
type | Transfer type. |
size | Size to be transferred on each DMA write/read. Source/Dest share the same write/read size. |
sourceAddr | Source address. |
destAddr | Destination address. |
length | Bytes to be transferred. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
- Parameters
-
chn | Memory pointing to the DMA channel. |
link_config | Configure of channel link in DMA. |
- Returns
- If successful, returns the kStatus_DMA_Success. Otherwise, it returns an error.
void DMA_DRV_IRQhandler |
( |
uint32_t |
channel | ) |
|
- Parameters
-
channel | DMA channel number. |
DMA_Type* const g_dmaBase[DMA_INSTANCE_COUNT] |
DMAMUX_Type* const g_dmamuxBase[DMAMUX_INSTANCE_COUNT] |
const IRQn_Type g_dmaIrqId[DMA_INSTANCE_COUNT][FSL_FEATURE_DMA_DMAMUX_CHANNELS] |