Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the eDMA Peripheral driver. The eDMA driver requests, configures, and uses eDMA hardware. It supports module initializations and DMA channel configurations.

eDMA Initialization

To initialize the DMA module, call the EDMA_DRV_Init() function. The user does not need to pass a configuration data structure. This function enables the eDMA module and clock automatically.

eDMA Channel concept

The eDMA module has many channels. Additionally, the EDMA peripheral driver is designed based on a channel concept. All operations should be started by requesting an eDMA channel and ended by freeing an eDMA channel. The user can configure and run operations on the eDMA module by allocating a channel. If a channel is not allocated, a system error may occur.

DMA request concept

A DMA request triggers an eDMA transfer. The DMA request table is available in device configuration chapters in a device reference manual.

eDMA Memory allocation and alignment

The eDMA peripheral driver does not allocate memory dynamically. The user needs to provide the allocated memory pointer for the driver and ensure that the memory is valid. Otherwise, a system error may occur. Prepare three types of memory:

  1. The handler memory: [edma_channel_t]. The driver must store the status data for each channel. The edma_channel_t is designed for this purpose.
  2. The edma_software_tcd_t. The eDMA supports a TCD chain, which provides either the scatter-gather feature or the loop feature. The eDMA module loads the TCDs from memory, where TCDs are stored. The user must provide the memory storing software TCDs and the EDMA_DRV_ConfigScatterGatherTransfer() function or the EDMA_DRV_ConfigLoopTransfer() function to configure the software TCDs. If those functions fail to configure the software TCDs, use the EDMA_DRV_PrepareDescriptorTransfer() function to configure the TCD. Then, call the EDMA_DRV_PushDescriptorToReg() function to push the TCD to registers.
  3. The status memory. To get the status of the TCD chains, provide the status memory, which the driver fills with chain status.
    The start address of the software TCDs must be 32 bytes.

eDMA Call diagram

To use the DMA driver, follow these steps:

  1. Initialize the DMA module: EDMA_DRV_Init().
  2. Request a DMA channel: EDMA_DRV_RequestChannel().
  3. Configure the TCD:
    • Configure the TCD chain in a scatter-gather list. UART transmit/receive is the common case.
    • Configure the TCD chain in a loop way. Audio playback/Record is the common case.
    • Configure software TCD and push it to registers. Use the DSPI case to configure and push the TCD to registers.
  4. Register callback function: EDMA_DRV_InstallCallback.
  5. Start the DMA channel: EDMA_DRV_StartChannel.
  6. [OPTION] Stop the DMA channel: EDMA_DRV_StopChannel.
  7. Free the DMA channel: EDMA_DRV_ReleaseChannel.

This is an example code to initialize and configure the driver by configuring the descriptor:

stcd = (edma_software_tcd_t *)(((uint32_t)status + 32) & ~0x1F);
// Prepare the memory space. //
for ( i = 0; i < kEdmaTestChainLength; i++)
{
// Allocate the memory! //
srcAddr[i] = malloc(kEdmaTestBufferSize);
destAddr[i] = malloc(kEdmaTestBufferSize);
// Check whether the allocation is successfully. //
if (((uint32_t)srcAddr[i] == 0x0U) & ((uint32_t)destAddr[i] == 0x0U))
{
printf("Fali to allocate memory for EDMA test! \r\n");
goto error;
}
// Init the memory buffer. //
for (j = 0; j < kEdmaTestBufferSize; j++)
{
srcAddr[i][j] = j;
destAddr[i][j] = 0;
}
srcSG[i].address = (uint32_t)srcAddr[i];
destSG[i].address = (uint32_t)destAddr[i];
srcSG[i].length = kEdmaTestBufferSize;
destSG[i].length = kEdmaTestBufferSize;
}
if (EDMA_DRV_RequestChannel(channel, kDmaRequestMux0AlwaysOn62, &chan_handler) != channel)
{
printf("Failed to request channel %d !\r\n", channel);
goto error;
}
stcd, &chan_handler, kDmaMemoryToMemory,
0x1U, kEdmaTestWatermarkLevel,
srcSG, destSG,
kEdmaTestChainLength);
EDMA_DRV_InstallCallback(&chan_handler, test_callback, &chan_handler);
EDMA_DRV_StartChannel(&chan_handler);

For an example to configure the loop mode, see the SAI module driver.

eDMA Extend the driver

The user can call the eDMA HAL driver to extend the application capability.

Data Structures

struct  edma_user_config_t
 The user configuration structure for the eDMA driver. More...
 
struct  edma_chn_state_t
 Data structure for the eDMA channel. More...
 
struct  edma_scatter_gather_list_t
 Data structure for configuring a discrete memory transfer. More...
 
struct  edma_state_t
 Runtime state structure for the eDMA driver. More...
 

Macros

#define STCD_SIZE(number)   ((number + 1) * 32)
 Macro for the memory size needed for the software TCD. More...
 
#define VIRTUAL_CHN_TO_EDMA_MODULE_REGBASE(chn)   g_edmaBase[chn/FSL_FEATURE_EDMA_MODULE_CHANNEL]
 Macro to get the eDMA physical module indicator from the virtual channel indicator. More...
 
#define VIRTUAL_CHN_TO_EDMA_CHN(chn)   (chn%FSL_FEATURE_EDMA_MODULE_CHANNEL)
 Macro to get the eDMA physical channel indicator from the virtual channel indicator. More...
 
#define VIRTUAL_CHN_TO_DMAMUX_MODULE_REGBASE(chn)   g_dmamuxBase[chn/FSL_FEATURE_DMAMUX_MODULE_CHANNEL]
 Macro to get the DMAMUX physical module indicator from the virtual channel indicator. More...
 
#define VIRTUAL_CHN_TO_DMAMUX_CHN(chn)   (chn%FSL_FEATURE_DMAMUX_MODULE_CHANNEL)
 Macro to get the DMAMUX physical channel indicator from the virtual channel indicator. More...
 

Typedefs

typedef void(* edma_callback_t )(void *parameter, edma_chn_status_t status)
 Definition for the eDMA channel callback function. More...
 

Enumerations

enum  edma_chn_status_t {
  kEDMAChnNormal = 0U,
  kEDMAChnIdle,
  kEDMAChnError
}
 Channel status for eDMA channel. More...
 
enum  edma_chn_state_type_t {
  kEDMAInvalidChannel = 0xFFU,
  kEDMAAnyChannel = 0xFEU
}
 enum type for channel allocation. More...
 
enum  edma_transfer_type_t {
  kEDMAPeripheralToMemory,
  kEDMAMemoryToPeripheral,
  kEDMAMemoryToMemory
}
 A type for the DMA transfer. More...
 

Variables

DMA_Type *const g_edmaBase []
 Array for the eDMA module register base address. More...
 
DMAMUX_Type *const g_dmamuxBase []
 Array for DMAMUX module register base address. More...
 
const IRQn_Type g_edmaIrqId [DMA_INSTANCE_COUNT][FSL_FEATURE_EDMA_MODULE_CHANNEL]
 Two dimensional array for eDMA channel interrupt vector number. More...
 
const IRQn_Type g_edmaErrIrqId [DMA_INSTANCE_COUNT]
 Array for eDMA module's error interrupt vector number. More...
 

eDMA peripheral driver module level functions

edma_status_t EDMA_DRV_Init (edma_state_t *edmaState, const edma_user_config_t *userConfig)
 Initializes all eDMA modules in an SOC. More...
 
edma_status_t EDMA_DRV_Deinit (void)
 Shuts down all eDMA modules. More...
 

eDMA peripheral driver channel management functions

uint8_t EDMA_DRV_RequestChannel (uint8_t channel, dma_request_source_t source, edma_chn_state_t *chn)
 Requests an eDMA channel dynamically or statically. More...
 
edma_status_t EDMA_DRV_ReleaseChannel (edma_chn_state_t *chn)
 Releases an eDMA channel. More...
 

eDMA peripheral driver transfer setup functions

static edma_status_t EDMA_DRV_PrepareDescriptorTransfer (edma_chn_state_t *chn, edma_software_tcd_t *stcd, edma_transfer_config_t *config, bool enableInt, bool disableDmaRequest)
 Sets the descriptor basic transfer for the descriptor. More...
 
static edma_status_t EDMA_DRV_PrepareDescriptorScatterGather (edma_software_tcd_t *stcd, edma_software_tcd_t *nextStcd)
 Configures the memory address for the next transfer TCD for the software TCD. More...
 
static edma_status_t EDMA_DRV_PrepareDescriptorChannelLink (edma_software_tcd_t *stcd, uint32_t linkChn)
 Configures the major channel link the software TCD. More...
 
static edma_status_t EDMA_DRV_PrepareDescriptorMinorLink (edma_software_tcd_t *stcd, uint32_t linkChn)
 Configures the minor channel link the software TCD. More...
 
static edma_status_t EDMA_DRV_TriggerChannelStart (edma_chn_state_t *chn)
 Triggers the eDMA channel. More...
 
edma_status_t EDMA_DRV_PushDescriptorToReg (edma_chn_state_t *chn, edma_software_tcd_t *stcd)
 Copies the software TCD configuration to the hardware TCD. More...
 
edma_status_t EDMA_DRV_ConfigLoopTransfer (edma_chn_state_t *chn, edma_software_tcd_t *stcd, edma_transfer_type_t type, uint32_t srcAddr, uint32_t destAddr, uint32_t size, uint32_t bytesOnEachRequest, uint32_t totalLength, uint8_t number)
 Configures the DMA transfer in a scatter-gather mode. More...
 
edma_status_t EDMA_DRV_ConfigScatterGatherTransfer (edma_chn_state_t *chn, edma_software_tcd_t *stcd, edma_transfer_type_t type, uint32_t size, uint32_t bytesOnEachRequest, edma_scatter_gather_list_t *srcList, edma_scatter_gather_list_t *destList, uint8_t number)
 Configures the DMA transfer in a scatter-gather mode. More...
 

eDMA Peripheral driver channel operation functions

edma_status_t EDMA_DRV_StartChannel (edma_chn_state_t *chn)
 Starts an eDMA channel. More...
 
edma_status_t EDMA_DRV_StopChannel (edma_chn_state_t *chn)
 Stops the eDMA channel. More...
 

eDMA Peripheral callback and interrupt functions

edma_status_t EDMA_DRV_InstallCallback (edma_chn_state_t *chn, edma_callback_t callback, void *parameter)
 Registers the callback function and the parameter for eDMA channel. More...
 
void EDMA_DRV_IRQHandler (uint8_t channel)
 IRQ Handler for eDMA channel interrupt. More...
 
void EDMA_DRV_ErrorIRQHandler (uint8_t instance)
 ERROR IRQ Handler for eDMA channel interrupt. More...
 

eDMA Peripheral driver miscellaneous functions

static edma_chn_status_t EDMA_DRV_GetChannelStatus (edma_chn_state_t *chn)
 Gets the eDMA channel status. More...
 
static uint32_t EDMA_DRV_GetUnfinishedBytes (edma_chn_state_t *chn)
 Gets the unfinished bytes for the eDMA channel current TCD. More...
 
static uint32_t EDMA_DRV_GetFinishedBytes (edma_chn_state_t *chn)
 Gets the bytes already transferred for the eDMA channel current TCD. More...
 

Data Structure Documentation

struct edma_user_config_t

Use an instance of this structure with the EDMA_DRV_Init() function. This allows the user to configure settings of the EDMA peripheral with a single function call.

Data Fields

edma_channel_arbitration_t chnArbitration
 eDMA channel arbitration.
 
bool notHaltOnError
 Any error causes the HALT bit to set. More...
 

Field Documentation

bool edma_user_config_t::notHaltOnError

Subsequently, all service requests are ignored until the HALT bit is cleared.

struct edma_chn_state_t

Data Fields

uint8_t channel
 Virtual channel indicator. More...
 
edma_callback_t callback
 Callback function pointer for the eDMA channel. More...
 
void * parameter
 Parameter for the callback function pointer. More...
 
volatile edma_chn_status_t status
 eDMA channel status. More...
 

Field Documentation

uint8_t edma_chn_state_t::channel
edma_callback_t edma_chn_state_t::callback

It will be called at the eDMA channel complete and eDMA channel error.

void* edma_chn_state_t::parameter
volatile edma_chn_status_t edma_chn_state_t::status
struct edma_scatter_gather_list_t

Data Fields

uint32_t address
 Address of buffer. More...
 
uint32_t length
 Length of buffer. More...
 

Field Documentation

uint32_t edma_scatter_gather_list_t::address
uint32_t edma_scatter_gather_list_t::length
struct edma_state_t

This structure holds data that is used by the eDMA peripheral driver to manage multi eDMA channels. The user passes the memory for this run-time state structure and the eDMA driver populates the members.

Data Fields

edma_chn_state_t *volatile chn [FSL_FEATURE_EDMA_DMAMUX_CHANNELS]
 Pointer array storing channel state. More...
 

Field Documentation

edma_chn_state_t* volatile edma_state_t::chn[FSL_FEATURE_EDMA_DMAMUX_CHANNELS]

Macro Definition Documentation

#define STCD_SIZE (   number)    ((number + 1) * 32)

Software TCD is aligned to 32 bytes. To make sure the software TCD can meet the eDMA module requirement, allocate memory with extra 32 bytes.

#define VIRTUAL_CHN_TO_EDMA_MODULE_REGBASE (   chn)    g_edmaBase[chn/FSL_FEATURE_EDMA_MODULE_CHANNEL]
#define VIRTUAL_CHN_TO_EDMA_CHN (   chn)    (chn%FSL_FEATURE_EDMA_MODULE_CHANNEL)
#define VIRTUAL_CHN_TO_DMAMUX_MODULE_REGBASE (   chn)    g_dmamuxBase[chn/FSL_FEATURE_DMAMUX_MODULE_CHANNEL]
#define VIRTUAL_CHN_TO_DMAMUX_CHN (   chn)    (chn%FSL_FEATURE_DMAMUX_MODULE_CHANNEL)

Typedef Documentation

typedef void(* edma_callback_t)(void *parameter, edma_chn_status_t status)

Prototype for the callback function registered in the eDMA driver.

Enumeration Type Documentation

A structure describing the eDMA channel status. The user can get the status by callback parameter or by calling EDMA_DRV_getStatus() function.

Enumerator
kEDMAChnNormal 

eDMA channel is occupied.

kEDMAChnIdle 

eDMA channel is idle.

kEDMAChnError 

An error occurs in the eDMA channel.

Enumerator
kEDMAInvalidChannel 

Macros indicate the failure of the channel request.

kEDMAAnyChannel 

Macros used when requesting channel dynamically.

Enumerator
kEDMAPeripheralToMemory 

Transfer from peripheral to memory.

kEDMAMemoryToPeripheral 

Transfer from memory to peripheral.

kEDMAMemoryToMemory 

Transfer from memory to memory.

Function Documentation

edma_status_t EDMA_DRV_Init ( edma_state_t edmaState,
const edma_user_config_t userConfig 
)

This function initializes the run-time state structure to provide the eDMA channel allocation release, protect, and track the state for channels. This function also opens the clock to the eDMA modules, resets the eDMA modules, initializes the module to user-defined settings and default settings. This is an example to set up the edma_state_t and the edma_user_config_t parameters and to call the EDMA_DRV_Init function by passing in these parameters.

edma_state_t state; <- The user simply allocates memory for this structure.
edma_user_config_t userConfig; <- The user fills out members for this structure.
#if (FSL_FEATURE_EDMA_CHANNEL_GROUP_COUNT > 0x1U)
//configuration for 2 lines below only valid for SoCs with more than on group.
userConfig.groupArbitration = kEDMAGroupArbitrationFixedPriority;
userConfig.groupPriority = kEDMAGroup0PriorityHighGroup1PriorityLow;
#endif
userCOnfig.notHaltOnError = false; <- The default setting is false, means eDMA halt on error.
EDMA_DRV_Init(&state, &userConfig);
Parameters
edmaStateThe pointer to the eDMA peripheral driver state structure. The user passes the memory for this run-time state structure and the eDMA peripheral driver populates the members. This run-time state structure keeps track of the eDMA channels status. The memory must be kept valid before calling the EDMA_DRV_DeInit.
userConfigUser configuration structure for eDMA peripheral drivers. The user populates the members of this structure and passes the pointer of this structure into the function.
Returns
An eDMA error codes or kStatus_EDMA_Success.
edma_status_t EDMA_DRV_Deinit ( void  )

This function resets the eDMA modules to reset state, gates the clock, and disables the interrupt to the core.

Returns
An eDMA error codes or kStatus_EDMA_Success.
uint8_t EDMA_DRV_RequestChannel ( uint8_t  channel,
dma_request_source_t  source,
edma_chn_state_t chn 
)

This function allocates the eDMA channel according to the required channel allocation and corresponding to the eDMA hardware request, initializes the channel state memory provided by user and fills out the members. This functions also sets up the hardware request configuration according to the user's requirements.

For Kinetis devices, a hardware request can be mapped to eDMA channels and used for the channel trigger. Some hardware requests can only be mapped to a limited channels. For example, the Kinetis K70FN1M0VMJ15 device eDMA module has 2 eDMA channel groups. The first group consists of the channel 0 - 15. The second group consists of channel 16 - 31. The hardware request UART0-Receive can be only mapped to group 1. Therefore, the hardware request is one of the parameter that the user needs to provide for the channel request. Channel needn't be triggered by the peripheral hardware request. The user can provide the ALWAYSON type hardware request to trigger the channel continuously.

This function provides two ways to allocate an eDMA channel: statically and dynamically. In a static allocation, the user provides the required channel number and eDMA driver tries to allocate the required channel to the user. If the channel is not occupied, the eDMA driver is successfully assigned to the user. If the channel is already occupied, the user gets the return value kEDMAInvalidChn. This is an example to request a channel statically:

uint32_t channelNumber = 14; <- Try to allocate the channel 14
edma_chn_state_t chn; <- The user simply allocates memory for this structure.
if ( kEDMAInvalidChannel == EDMA_DRV_RequestChannel(channel, kDmaRequestMux0AlwaysOn54, chn))
{
printf("request channel %d failed!\n", channel);
}

In a dynamic allocation, any of the free eDMA channels are available for use. eDMA driver assigns the first free channel to the user. This is an example for user to request a channel dynamically :

uint32_t channel; <- Store the allocated channel number.
edma_chn_state_t chn; <- The user simply allocates memory for this structure.
channel = EDMA_DRV_RequestChannel(kEDMAAnyChannel, kDmaRequestMux0AlwaysOn54, chn);
if (channel == kEDMAInvalidChannel)
{
printf("request channel %d failed!\n", channel);
}
else
{
printf("Channel %d is successfully allocated! /n", channel);
}
Parameters
channelRequested channel number. If the channel is assigned with the kEDMAAnyChannel, the eDMA driver allocates the channel dynamically. If the channel is assigned with a valid channel number, the eDMA driver allocates that channel.
sourceeDMA hardware request number.
chnThe pointer to the eDMA channel state structure. The user passes the memory for this run-time state structure. The eDMA peripheral driver populates the members. This run-time state structure keeps tracks of the eDMA channel status. The memory must be kept valid before calling the EDMA_DRV_ReleaseChannel().
Returns
Successfully allocated channel number or the kEDMAInvalidChannel indicating that the request is failed.
edma_status_t EDMA_DRV_ReleaseChannel ( edma_chn_state_t chn)

This function stops the eDMA channel and disables the interrupt of this channel. The channel state structure can be released after this function is called.

Parameters
chnThe pointer to the channel state structure.
Returns
An eDMA error codes or kStatus_EDMA_Success.
static edma_status_t EDMA_DRV_PrepareDescriptorTransfer ( edma_chn_state_t chn,
edma_software_tcd_t stcd,
edma_transfer_config_t config,
bool  enableInt,
bool  disableDmaRequest 
)
inlinestatic

This function sets up the basic transfer for the descriptor. The minor loop setting is not used because the minor loop configuration impacts the global eDMA setting. The source minor loop offset is relevant to the destination minor loop offset. For these reasons, the minor loop offset configuration is treated as an advanced configuration. The user can call the EDMA_HAL_STCDSetMinorLoopOffset() function to configure the minor loop offset feature.

Parameters
channelVirtual channel number.
chnThe pointer to the channel state structure.
stcdThe pointer to the descriptor.
configConfiguration for the basic transfer.
enableIntEnables (true) or Disables (false) interrupt on TCD complete.
disableDmaRequestDisables (true) or Enable (false) DMA request on TCD complete.
Returns
An eDMA error codes or kStatus_EDMA_Success.
static edma_status_t EDMA_DRV_PrepareDescriptorScatterGather ( edma_software_tcd_t stcd,
edma_software_tcd_t nextStcd 
)
inlinestatic

This function enables the scatter/gather feature for the software TCD and configures the next TCD address.This address points to the beginning of a 0-modulo-32 byte region containing the next transfer TCD to be loaded into this channel. The channel reload is performed as the major iteration count completes. The scatter/gather address must be 0-modulo-32-byte. Otherwise, a configuration error is reported.

Parameters
stcdThe pointer to the software TCD, which needs to link to the software TCD. The address needs to be aligned to 32 bytes.
nextStcdThe pointer to the software TCD, which is to be linked to the software TCD. The address needs to be aligned to 32 bytes.
Returns
An eDMA error codes or kStatus_EDMA_Success.
static edma_status_t EDMA_DRV_PrepareDescriptorChannelLink ( edma_software_tcd_t stcd,
uint32_t  linkChn 
)
inlinestatic

If the major link is enabled, after the major loop counter is exhausted, the eDMA engine initiates a channel service request at the channel defined by these six bits by setting that channel start bits.

Parameters
stcdThe pointer to the software TCD. The address need to be aligned to 32 bytes.
linkChnChannel number for major link
Returns
An eDMA error codes or kStatus_EDMA_Success.
static edma_status_t EDMA_DRV_PrepareDescriptorMinorLink ( edma_software_tcd_t stcd,
uint32_t  linkChn 
)
inlinestatic

If the minor link is enabled, after the minor loop counter is exhausted, the eDMA engine initiates a channel service request at the channel defined by these six bits by setting that channel start bits.

Parameters
stcdThe pointer to the software TCD. The address need to be aligned to 32 bytes.
linkChnChannel number for minor link
Returns
An eDMA error codes or kStatus_EDMA_Success.
static edma_status_t EDMA_DRV_TriggerChannelStart ( edma_chn_state_t chn)
inlinestatic
Parameters
chnThe pointer to the channel state structure.
Returns
kStatus_EDMA_Success.
edma_status_t EDMA_DRV_PushDescriptorToReg ( edma_chn_state_t chn,
edma_software_tcd_t stcd 
)
Parameters
chnThe pointer to the channel state structure.
stcdmemory pointing to the software TCD.
Returns
An eDMA error codes or kStatus_EDMA_Success.
edma_status_t EDMA_DRV_ConfigLoopTransfer ( edma_chn_state_t chn,
edma_software_tcd_t stcd,
edma_transfer_type_t  type,
uint32_t  srcAddr,
uint32_t  destAddr,
uint32_t  size,
uint32_t  bytesOnEachRequest,
uint32_t  totalLength,
uint8_t  number 
)

This function configures the descriptors in a loop chain. The user passes a block of memory into this function and the memory is divided into the "period" sub blocks. The DMA driver configures the "period" descriptors. Each descriptor stands for a sub block. The DMA driver transfers data from the first descriptor to the last descriptor. Then, the DMA driver wraps to the first descriptor to continue the loop. The interrupt handler is called every time a descriptor is completed. The user can get a transfer status of a descriptor by calling the edma_get_descriptor_status() function in the interrupt handler or any other task context. At the same time, calling the edma_update_descriptor() function notifies the DMA driver that the content belonging to a descriptor is already updated and the DMA needs to count it as and underflow next time it loops to this descriptor. This is an example that describes how to use this interface in audio playback case:

  1. Use a ping-pong buffer to transfer the data, the size of the each buffer is 1024 bytes.
  2. Each DMA request needs to transfer 8 bytes.
  3. The audio data is 16 bit.
    edma_chn_state_t chn; <--- Simply allocates the structure.
    edma_software_tcd_t stcd[2]; <-- Need 32 bytes aligned, two buffer block, needs 2 TCD.
    uint32_t srcAddr = buffer; <----Start address of the buffer.
    uint32_t destAddr = SAI_TDR; <-----Destination address, usually SAI TDR register.
    EDMA_DRV_ConfigLoopTransfer(&chn, stcd, kEDMAMemoryToPeripheral, srcAddr, destAddr,
    kEDMATransferSize_2Bytes, 8, 2048, 2) ;
    Parameters
    chnThe pointer to the channel state structure.
    stcdMemory pointing to software TCDs. The user must prepare this memory block. The required memory size is equal to a "period" * size of(edma_software_tcd_t). At the same time, the "stcd" must align with 32 bytes. If not, an error occurs in the eDMA driver.
    typeTransfer type.
    srcAddrA source register address or a source memory address.
    destAddrA destination register address or a destination memory address.
    sizeBytes to be transferred on every DMA write/read. Source/Dest share the same write/read size.
    bytesOnEachRequestBytes to be transferred in each DMA request.
    totalLengthTotal bytes to be transferred in a loop cycle. In audio case, it means the total buffer size.
    numberNumber of TCDs, meaning how many parts the transfer data is divided into. For example, if the using ping-pong buffer for transfer, the number should be 2 and each buffer size is totalLength/2.
    Returns
    An error code of kStatus_EDMA_Success
edma_status_t EDMA_DRV_ConfigScatterGatherTransfer ( edma_chn_state_t chn,
edma_software_tcd_t stcd,
edma_transfer_type_t  type,
uint32_t  size,
uint32_t  bytesOnEachRequest,
edma_scatter_gather_list_t srcList,
edma_scatter_gather_list_t destList,
uint8_t  number 
)

This function configures the descriptors into a single-ended chain. The user passes blocks of memory into this function. The interrupt is triggered only when the last memory block is completed. The memory block information is passed with the edma_scatter_gather_list_t data structure, which can tell the memory address and length. The DMA driver configures the descriptor for each memory block, transfers the descriptor from the first one to the last one, and stops.

Parameters
chnThe pointer to the channel state structure.
stcdMemory pointing to software TCDs. The user must prepare this memory block. The required memory size is equal to the "number" * size of(edma_software_tcd_t). At the same time, the "stcd" must align with 32 bytes. If not, an error occurs in the eDMA driver.
typeTransfer type.
sizeBytes to be transferred on each DMA write/read. Source/Dest share the same write/read size.
bytesOnEachRequestBytes to be transferred in each DMA request.
srcListData structure storing the address and length to be transferred for source memory blocks. If the source memory is peripheral, the length is not used.
destListData structure storing the address and length to be transferred for destination memory blocks. If in the memory-to-memory transfer mode, the user must ensure that the length of the destination scatter gather list is equal to the source scatter gather list. If the destination memory is a peripheral register, the length is not used.
numberThe number of TCD memory blocks contained in the scatter gather list.
Returns
An error code of kStatus_EDMA_Success
edma_status_t EDMA_DRV_StartChannel ( edma_chn_state_t chn)

This function enables the eDMA channel DMA request.

Parameters
chnThe pointer to the channel state structure.
Returns
An eDMA error codes or kStatus_EDMA_Success.
edma_status_t EDMA_DRV_StopChannel ( edma_chn_state_t chn)

This function disables the eDMA channel DMA request.

Parameters
chnThe pointer to the channel state structure.
Returns
An eDMA error codes or kStatus_EDMA_Success.
edma_status_t EDMA_DRV_InstallCallback ( edma_chn_state_t chn,
edma_callback_t  callback,
void *  parameter 
)

This function registers the callback function and the parameter into the eDMA channel state structure. The callback function is called when the channel is complete or a channel error occurs. The eDMA driver passes the channel status to this callback function to indicate whether it is caused by the channel complete event or the channel error event.

To un-register the callback function, set the callback function to "NULL" and call this function.

Parameters
chnThe pointer to the channel state structure.
callbackThe pointer to the callback function.
parameterThe pointer to the callback function's parameter.
Returns
An eDMA error codes or kStatus_EDMA_Success.
void EDMA_DRV_IRQHandler ( uint8_t  channel)

This function is provided as the default flow for eDMA channel interrupt. This function clears the status and calls the callback functions. The user can add this function into the hardware interrupt entry and implement a custom interrupt action function.

Parameters
channelVirtual channel number.
void EDMA_DRV_ErrorIRQHandler ( uint8_t  instance)

This function is provided as the default action for eDMA module error interrupt. This function clears status, stops the error on a eDMA channel, and calls the eDMA channel callback function if the error eDMA channel is already requested. The user can add this function into the eDMA error interrupt entry and implement a custom interrupt action function.

Parameters
instanceeDMA module indicator.
static edma_chn_status_t EDMA_DRV_GetChannelStatus ( edma_chn_state_t chn)
inlinestatic
Parameters
chnThe pointer to the channel state structure.
Returns
Channel status.
static uint32_t EDMA_DRV_GetUnfinishedBytes ( edma_chn_state_t chn)
inlinestatic

This function checks the TCD (Task Control Descriptor) status for a specified eDMA channel and returns the bytes that have not finished. This function can only be used for one TCD scenario.

Parameters
chnThe pointer to the channel state structure.
Returns
Bytes already transferred for the current TCD.
static uint32_t EDMA_DRV_GetFinishedBytes ( edma_chn_state_t chn)
inlinestatic

This function checks the TCD (Task Control Descriptor) status for a specified eDMA channel and returns the bytes that remain to the user. This function can only be used for one TCD scenario.

Parameters
chnThe pointer to the channel state structure.
Returns
Bytes already transferred for the current TCD.

Variable Documentation

DMA_Type* const g_edmaBase[]
DMAMUX_Type* const g_dmamuxBase[]
const IRQn_Type g_edmaIrqId[DMA_INSTANCE_COUNT][FSL_FEATURE_EDMA_MODULE_CHANNEL]
const IRQn_Type g_edmaErrIrqId[DMA_INSTANCE_COUNT]