MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
EDMA: Enhanced Direct Memory Access Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 EDMA Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current eDMA driver version is 2.0.0.
 

Data Structures

struct  edma_channel_Preemption_config_t
 eDMA channel priority configuration, useful to the fixed priority arbitration type More...
 
struct  edma_channel_transfer_config_t
 edma channel transfer configuration More...
 
struct  edma_channel_tcd_t
 eDMA software Transfer control descriptor structure. More...
 
struct  edma_config_t
 edma configuration structure More...
 
struct  edma_handle_t
 eDMA transfer handle structure More...
 

Macros

#define EDMA_ENTER_CRITICAL_SECTION()
 edma transactional tcd pool resource protection lock definition Application should overwrite below two macros if multi task trying to access the same channel.
 
#define DMA_DCHPRI_INDEX(channel)   (((channel) & ~0x03U) | (3U - ((channel)&0x03U)))
 Compute the offset unit from DCHPRI3.
 

Typedefs

typedef void(* edma_transfer_callback_t )(edma_handle_t *psHandle, void *pUserData, bool bTransferDone, uint32_t u32Tcds)
 Define callback function for eDMA. More...
 

Enumerations

enum  _edma_transfer_status {
  kStatus_EDMA_ChannelQueueFull = MAKE_STATUS(kStatusGroup_EDMA, 0),
  kStatus_EDMA_ChannelBusy = MAKE_STATUS(kStatusGroup_EDMA, 1)
}
 _edma_transfer_status eDMA transfer status More...
 
enum  edma_channel_transfer_type_t {
  kEDMA_ChannelTransferMemoryToMemory = 0x0U,
  kEDMA_ChannelTransferPeripheralToMemory,
  kEDMA_ChannelTransferMemoryToPeripheral,
  kEDMA_ChannelTransferPeripheralToPeripheral
}
 eDMA transfer type More...
 
enum  _edma_channel_interrupt_enable {
  kEDMA_ChannelErrorInterruptEnable = 1U,
  kEDMA_ChannelMajorLoopCompleteInterruptEnable,
  kEDMA_ChannelMajorLoopHalfCompleteInterruptEnable,
  kEDMA_ChannelAllInterruptEnable
}
 eDMA interrupt source More...
 
enum  _edma_channel_status_flags {
  kEDMA_ChannelStatusErrorFlag = 0x1U,
  kEDMA_ChannelStatusMajorLoopCompleteFlag,
  kEDMA_ChannelStatusMajorLoopHalfCompleteFlag = 0x4U
}
 _edma_channel_status_flags eDMA channel status flags. More...
 
enum  _edma_error_status_flags {
  kEDMA_ChannelDestinationBusErrorFlag = DMA_ES_DBE_MASK,
  kEDMA_ChannelSourceBusErrorFlag = DMA_ES_SBE_MASK,
  kEDMA_ChannelScatterGatherErrorFlag,
  kEDMA_ChannelNbytesErrorFlag = DMA_ES_NCE_MASK,
  kEDMA_ChannelDestinationOffsetErrorFlag,
  kEDMA_ChannelDestinationAddressErrorFlag,
  kEDMA_ChannelSourceOffsetErrorFlag = DMA_ES_SOE_MASK,
  kEDMA_ChannelSourceAddressErrorFlag = DMA_ES_SAE_MASK,
  kEDMA_ChannelErrorChannelFlag = DMA_ES_ERRCHN_MASK,
  kEDMA_ChannelPriorityErrorFlag = DMA_ES_CPE_MASK,
  kEDMA_ChannelTransferCanceledFlag = DMA_ES_ECX_MASK,
  kEDMA_ChannelValidFlag = (int)DMA_ES_VLD_MASK
}
 _edma_error_status_flags eDMA channel detail error status flags. More...
 
enum  edma_arbitration_type_t {
  kEDMA_ArbitrationFixedPriority = 0x0U,
  kEDMA_ArbitrationRoundRobin
}
 eDMA arbitration type More...
 
enum  edma_channel_t {
  kEDMA_Channel0 = 0U,
  kEDMA_Channel1 = 1U,
  kEDMA_Channel2 = 2U,
  kEDMA_Channel3 = 3U
}
 edma channel index More...
 
enum  edma_channel_transfer_width_t {
  kEDMA_ChannelTransferWidth8Bits = 0U,
  kEDMA_ChannelTransferWidth16Bits = 1U,
  kEDMA_ChannelTransferWidth32Bits = 2U,
  kEDMA_ChannelTransferWidth128Bits = 0x4U
}
 eDMA transfer width configuration More...
 
enum  edma_channel_modulo_t {
  kEDMA_ChannelModuloDisable = 0x0U,
  kEDMA_ChannelModulo2bytes,
  kEDMA_ChannelModulo4bytes,
  kEDMA_ChannelModulo8bytes,
  kEDMA_ChannelModulo16bytes,
  kEDMA_ChannelModulo32bytes,
  kEDMA_ChannelModulo64bytes,
  kEDMA_ChannelModulo128bytes,
  kEDMA_ChannelModulo256bytes,
  kEDMA_ChannelModulo512bytes,
  kEDMA_ChannelModulo1Kbytes,
  kEDMA_ChannelModulo2Kbytes,
  kEDMA_ChannelModulo4Kbytes,
  kEDMA_ChannelModulo8Kbytes,
  kEDMA_ChannelModulo16Kbytes,
  kEDMA_ChannelModulo32Kbytes,
  kEDMA_ChannelModulo64Kbytes,
  kEDMA_ChannelModulo128Kbytes,
  kEDMA_ChannelModulo256Kbytes,
  kEDMA_ChannelModulo512Kbytes,
  kEDMA_ChannelModulo1Mbytes,
  kEDMA_ChannelModulo2Mbytes,
  kEDMA_ChannelModulo4Mbytes,
  kEDMA_ChannelModulo8Mbytes,
  kEDMA_ChannelModulo16Mbytes,
  kEDMA_ChannelModulo32Mbytes,
  kEDMA_ChannelModulo64Mbytes,
  kEDMA_ChannelModulo128Mbytes,
  kEDMA_ChannelModulo256Mbytes,
  kEDMA_ChannelModulo512Mbytes,
  kEDMA_ChannelModulo1Gbytes,
  kEDMA_ChannelModulo2Gbytes
}
 eDMA channel modulo configuration More...
 
enum  edma_channel_bandwidth_t {
  kEDMA_ChannelBandwidthStallNone = 0x0U,
  kEDMA_ChannelBandwidthStall4Cycle = 0x2U,
  kEDMA_ChannelBandwidthStall8Cycle = 0x3U
}
 edma channel Bandwidth control More...
 

eDMA Initialization and De-initialization interfaces

void EDMA_GetDefaultConfig (edma_config_t *psConfig)
 Get default edma peripheral configuration. More...
 
void EDMA_Init (DMA_Type *base, edma_config_t *psConfig)
 EDMA initialization. More...
 
void EDMA_Deinit (DMA_Type *base)
 EDMA De-initialization. More...
 

eDMA non-channel functional interfaces

static void EDMA_EnableContinuousChannelLinkMode (DMA_Type *base, bool bEnable)
 Enable/Disable arbitration before the channel been activate by minor loop link trigger from itself. More...
 
static void EDMA_EnableMinorLoopMapping (DMA_Type *base, bool bEnable)
 Enable/Disable redefine the minor loop bytes register. More...
 
static void EDMA_EnableHaltOnError (DMA_Type *base, bool bEnable)
 Enable/Disable the eDMA halt when error occur feature. More...
 
static void EDMA_SetArbitration (DMA_Type *base, edma_arbitration_type_t eArbitration)
 set EDMA arbitration type to fixed priority or round robin. More...
 

eDMA channel functional interfaces

void EDMA_GetChannelDefaultTransferConfig (edma_channel_transfer_config_t *psTransfer, void *pSrcAddr, void *pDstAddr, uint32_t u32BytesEachRequest, uint32_t u32TotalBytes, edma_channel_transfer_width_t eTransferWidth, edma_channel_transfer_type_t eTransferType)
 Get channel default transfer configuration. More...
 
void EDMA_SetChannelTransferConfig (DMA_Type *base, edma_channel_t eChannel, edma_channel_transfer_config_t *psTransfer)
 EDMA set channel transfer configurations. More...
 
void EDMA_SetChannelMinorLoopOffset (DMA_Type *base, edma_channel_t eChannel, bool bEnableSrcMinorLoopOffset, bool bEnableDestMinorLoopOffset, int32_t i32MinorLoopOffset)
 Configures the eDMA channel minor loop offset value. More...
 
void EDMA_SetChannelPreemption (DMA_Type *base, edma_channel_t eChannel, bool bSuspendedByHighPriorityChannel, bool bSuspendLowPriorityChannel, uint8_t u8Priority)
 Configures the eDMA channel preemption configurations. More...
 
void EDMA_EnableMinorLoopChannelLink (DMA_Type *base, edma_channel_t eChannel, edma_channel_t eLinkChannel)
 Enable the minor loop channel link and configure the linked channel number. More...
 
static void EDMA_DisableMinorLoopChannelLink (DMA_Type *base, edma_channel_t eChannel)
 Disable the minor loop channel link for the eDMA transfer. More...
 
void EDMA_EnableMajorLoopChannelLink (DMA_Type *base, edma_channel_t eChannel, edma_channel_t eLinkChannel)
 Enable the major loop channel link and configure the linked channel number. More...
 
static void EDMA_DisableMajorLoopChannelLink (DMA_Type *base, edma_channel_t eChannel)
 Disable the major loop channel link for the eDMA transfer. More...
 
void EDMA_SetChannelBandWidth (DMA_Type *base, edma_channel_t eChannel, edma_channel_bandwidth_t eBandWidth)
 Sets the edma channel stall cycles after each R/W. More...
 
void EDMA_SetChannelModulo (DMA_Type *base, edma_channel_t eChannel, edma_channel_modulo_t eSrcModulo, edma_channel_modulo_t eDestModulo)
 Sets the source address range and the destination address range for the eDMA transfer. More...
 
static void EDMA_EnableChannelAsyncRequestInStopMode (DMA_Type *base, edma_channel_t eChannel, bool bEnable)
 Enables the edma channel async request in stop mode. More...
 
static void EDMA_EnableChannelAutoStopRequest (DMA_Type *base, edma_channel_t eChannel, bool bEnable)
 Enables the edma channel auto disable request after major loop complete. More...
 
void EDMA_SetChannelMajorLoopOffset (DMA_Type *base, edma_channel_t eChannel, int32_t i32SourceOffset, int32_t i32DestOffset)
 Configures the eDMA channel major loop offset feature. More...
 
static void EDMA_EnableChannelRequest (DMA_Type *base, edma_channel_t eChannel, bool bEnable)
 Enable/disable the eDMA hardware channel request. More...
 
static void EDMA_SoftwareTriggerChannelStart (DMA_Type *base, edma_channel_t eChannel)
 Starts the eDMA transfer by using the software trigger. More...
 
uint32_t EDMA_GetChannelRemainingMajorLoopCount (DMA_Type *base, edma_channel_t eChannel)
 Gets the remaining major loop count from the eDMA current channel TCD. More...
 

eDMA Channel interrupt Interfaces

void EDMA_EnableChannelInterrupts (DMA_Type *base, edma_channel_t eChannel, uint16_t u16InterruptsMask, bool bEnable)
 Enables the edma channel interrupts according to a provided mask, the mask is a logical OR of enumerator members _edma_channel_interrupt_enable. More...
 

eDMA Channel Status Interfaces

uint16_t EDMA_GetChannelStatusFlags (DMA_Type *base, edma_channel_t eChannel)
 Gets the eDMA channel status flags. More...
 
void EDMA_ClearChannelStatusFlags (DMA_Type *base, edma_channel_t eChannel, uint16_t u16StatusFlags)
 Clears the eDMA channel status flags. More...
 
static uint32_t EDMA_GetErrorStatusFlags (DMA_Type *base)
 Gets the eDMA channel error status flags. More...
 

eDMA software TCD Interfaces

void EDMA_ConfigChannelSoftwareTCD (edma_channel_tcd_t *psTcd, edma_channel_transfer_config_t *psTransfer)
 Sets TCD fields according to the user's channel transfer configuration structure, edma_channel_transfer_config_t. More...
 
void EDMA_InstallChannelSoftwareTCD (DMA_Type *base, edma_channel_t eChannel, edma_channel_tcd_t *psTcd)
 Push content of software TCD structure into hardware TCD register. More...
 

eDMA Transactional Interfaces

void EDMA_TransferCreateHandle (DMA_Type *base, edma_handle_t *psHandle, edma_channel_t eChannel, edma_channel_tcd_t *psTcdPool, uint32_t u32TcdCount, edma_transfer_callback_t pfCallback, void *pUserData)
 Creates the eDMA channel handle. More...
 
status_t EDMA_TransferSubmitSingleTransfer (edma_handle_t *psHandle, edma_channel_transfer_config_t *psTransfer)
 Submits the eDMA single transfer configuration. More...
 
status_t EDMA_TransferSubmitLoopTransfer (edma_handle_t *psHandle, edma_channel_transfer_config_t *psTransfer, uint32_t transferLoopCount)
 Submits the eDMA scatter gather transfer configurations. More...
 
void EDMA_TransferStart (edma_handle_t *psHandle)
 eDMA starts transfer. More...
 
void EDMA_TransferStop (edma_handle_t *psHandle)
 eDMA stops transfer. More...
 
void EDMA_TransferAbort (edma_handle_t *psHandle)
 eDMA aborts transfer. More...
 
void EDMA_TransferHandleIRQ (edma_handle_t *psHandle)
 eDMA IRQ handler for the current major loop transfer completion. More...
 

Data Structure Documentation

struct edma_channel_Preemption_config_t

Data Fields

bool bSuspendedByHighPriorityChannel: 1
 a channel can be suspended by other channel with higher priority
 
bool bSuspendLowPriorityChannel: 1
 a channel can suspend other channel with low priority
 
uint8_t u8ChannelPriority: 5
 Channel priority.
 
struct edma_channel_transfer_config_t

The transfer configuration structure support full feature configuration of the transfer control descriptor.

Note
User should pay attention to the transfer size alignment limitation
  1. the u32BytesEachRequest should align with the eSrcWidthOfEachTransfer and the eDstWidthOfEachTransfer that is to say u32BytesEachRequest % eSrcWidthOfEachTransfer should be 0
  2. the i16SrcOffsetOfEachTransfer and i16DstOffsetOfEachTransfer must be aligne with transfer width
  3. the u32TotalBytes should align with the u32BytesEachRequest
  4. the pSrcAddr should align with the eSrcWidthOfEachTransfer
  5. the pDstAddr should align with the eDstWidthOfEachTransfer
  6. the pSrcAddr should align with eSrcAddrModulo if modulo feature is enabled
  7. the pDstAddr should align with eDstAddrModulo if modulo feature is enabled If anyone of above condition can not be satisfied, the edma interfaces will generate assert error.

1.To perform a simple transfer, below members should be initialized at least .pSrcAddr - source address .pDstAddr - destination address .eSrcWidthOfEachTransfer - data width of source address .eDstWidthOfEachTransfer - data width of destination address, normally it should be as same as eSrcWidthOfEachTransfer .u32BytesEachRequest - bytes to be transferred in each DMA request .u32TotalBytes - total bytes to be transferred .i16SrcOffsetOfEachTransfer - offset value in bytes unit to be applied to source address as each source read is completed .i16DstOffsetOfEachTransfer - offset value in bytes unit to be applied to destination address as each destination write is completed bEnableChannelRequest - channel request can be enabled together with transfer configure submission

2.The transfer configuration structure also support advance feature: Programmable source/destination address range(MODULO) Programmable minor loop offset Programmable major loop offset Programmable channel chain feature Programmable channel transfer control descriptor link feature

Data Fields

void * pSrcAddr
 source address
 
void * pDstAddr
 destination address
 
edma_channel_transfer_width_t eSrcWidthOfEachTransfer
 source width of each transfer
 
edma_channel_transfer_width_t eDstWidthOfEachTransfer
 destination width of each transfer
 
uint32_t u32BytesEachMinorLoop
 bytes in each minor loop or each request range: 1 - (2^30 -1) when minor loop mapping is enabled range: 1 - (2^10 - 1) when minor loop mapping is enabled and source or dest minor loop offset is enabled range: 1 - (2^32 - 1) when minor loop mapping is disabled
 
uint16_t u16MinorLoopCountsEachMajorLoop
 minor loop counts in each major loop, should be 1 at least for each transfer range: (0 - (2^15 - 1)) when minor loop channel link is disabled range: (0 - (2^9 - 1)) when minor loop channel link is enabled total bytes in a transfer = u16MinorLoopCountsEachMajorLoop * u32BytesEachMinorLoop
 
uint16_t u16EnabledInterruptMask
 channel interrupt to enable, can be OR'ed value of _edma_channel_interrupt_enable
 
int16_t i16SrcOffsetOfEachTransfer
 
           Sign-extended offset value in byte unit applied to the current source

address to form the next-state value as each source read is completed

 
edma_channel_modulo_t eSrcAddrModulo
 source circular data queue range
 
int32_t i32SrcMajorLoopOffset
 source major loop offset
 
int16_t i16DstOffsetOfEachTransfer
 
          Sign-extended offset value in byte unit applied to the current destination

address to form the next-state value as each destination write is completed. More...

 
edma_channel_modulo_t eDstAddrModulo
 destination circular data queue range
 
int32_t i32DstMajorLoopOffset
 destination major loop offset
 
bool bEnableSrcMinorLoopOffset
 enable source minor loop offset
 
bool bEnableDstMinorLoopOffset
 enable dest minor loop offset
 
int32_t i32MinorLoopOffset
 burst offset, the offset will be applied after minor loop update
 
bool bEnableChannelMajorLoopLink
 channel link when major loop complete
 
edma_channel_t eMajorLoopLinkChannel
 major loop link channel number
 
bool bEnableChannelMinorLoopLink
 channel link when minor loop complete
 
edma_channel_t eMinorLoopLinkChannel
 minor loop link channel number
 
edma_channel_bandwidth_t eChannelBandWidth
 channel bandwidth
 
bool bDisableRequestAfterMajorLoopComplete
 the channel's ERQ bit can be cleared after the major loop complete automatically
 
bool bEnableChannelRequest
 enable the channel request signal
 
edma_channel_tcd_t * psLinkTCD
 pointer to the link transfer control descriptor
 

Field Documentation

int16_t edma_channel_transfer_config_t::i16DstOffsetOfEachTransfer
struct _edma_channel_tcd

edma channel software tcd definition

This structure is same as eDMA hardware channel TCD registers, user doesn't need to understand the structures, since eDMA driver will responsible for configure it.

The software TCD is useful to configure a software TCD which is linked by the channel hardware TCD to have scatter/gather feature without using transactional interface.

Data Fields

__IO uint32_t u32SADDR
 SADDR register, used to save source address.
 
__IO uint16_t u16SOFF
 SOFF register, offset bytes added to source address every transfer.
 
__IO uint16_t u16ATTR
 ATTR register, source/destination transfer size and modulo.
 
__IO uint32_t u32NBYTES
 Nbytes register, minor loop length in bytes.
 
__IO uint32_t u32SLAST
 SLAST register, adjustment value added to the source address at the completion of the major loop.
 
__IO uint32_t u32DADDR
 DADDR register, used for destination address.
 
__IO uint16_t u16DOFF
 DOFF register, offset bytes added to destination address every transfer.
 
__IO uint16_t u16CITER
 CITER register, current minor loop numbers, for unfinished minor loop. More...
 
__IO uint32_t u32DLAST_SGA
 DLASTSGA register, next tcd address used in scatter-gather mode.
 
__IO uint16_t u16CSR
 CSR register, for TCD control status.
 
__IO uint16_t u16BITER
 BITER register, begin minor loop count. More...
 

Field Documentation

__IO uint16_t edma_channel_tcd_t::u16CITER
__IO uint16_t edma_channel_tcd_t::u16BITER
struct edma_config_t

This structure target for whole edma module configurations.

Data Fields

bool bEnableContinuousLinkMode
 Enable (true) continuous link mode. More...
 
bool bEnableHaltOnError
 Enable (true) transfer halt on error. More...
 
bool bEnableDmaInDebugMode
 Enable(true) eDMA debug mode. More...
 
bool bEnableMinorLoopMapping
 TCDn.word2 is redefined to include individual enable fields, an offset field, and the NBYTES field. More...
 
edma_arbitration_type_t eArbitrationType
 Enable (true) round robin channel arbitration method or fixed priority arbitration is used for channel selection.
 
edma_channel_Preemption_config_t sChannelPreemptionConfig [FSL_FEATURE_EDMA_MODULE_CHANNEL]
 channel preemption configuration
 
edma_channel_transfer_config_tpsChannelTransferConfig [FSL_FEATURE_EDMA_MODULE_CHANNEL]
 channel transfer configuration pointer
 

Field Documentation

bool edma_config_t::bEnableContinuousLinkMode

Upon minor loop completion, the channel activates again if that channel has a minor loop channel link enabled and the link channel is itself.

bool edma_config_t::bEnableHaltOnError

Any error causes the HALT bit to set. Subsequently, all service requests are ignored until the HALT bit is cleared.

bool edma_config_t::bEnableDmaInDebugMode

When in debug mode, the eDMA stalls the start of a new channel. Executing channels are allowed to complete.

bool edma_config_t::bEnableMinorLoopMapping

The individual enable fields allow the minor loop offset to be applied to the source address, the destination address, or both. The NBYTES field is reduced when either offset is enabled

struct _edma_handle

handler for eDMA

Data Fields

edma_transfer_callback_t pfCallback
 Callback function for major count exhausted. More...
 
void * pUserData
 Callback function parameter. More...
 
DMA_Type * psBase
 eDMA peripheral base address. More...
 
edma_channel_tcd_t * psTcdPool
 Pointer to memory stored TCDs. More...
 
edma_channel_t eChannel
 eDMA channel number. More...
 
volatile uint8_t u8Header
 The first TCD index. More...
 
volatile uint8_t u8Tail
 The last TCD index. More...
 
volatile uint8_t u8TcdUsed
 The number of used TCD slots. More...
 
volatile uint8_t u8TcdSize
 The total number of TCD slots in the queue. More...
 

Field Documentation

edma_transfer_callback_t edma_handle_t::pfCallback
void* edma_handle_t::pUserData
DMA_Type* edma_handle_t::psBase
edma_channel_tcd_t* edma_handle_t::psTcdPool
edma_channel_t edma_handle_t::eChannel
volatile uint8_t edma_handle_t::u8Header

Should point to the next TCD to be loaded into the eDMA engine.

volatile uint8_t edma_handle_t::u8Tail

Should point to the next TCD to be stored into the memory pool.

volatile uint8_t edma_handle_t::u8TcdUsed

Should reflect the number of TCDs can be used/loaded in the memory.

volatile uint8_t edma_handle_t::u8TcdSize

Typedef Documentation

typedef void(* edma_transfer_callback_t)(edma_handle_t *psHandle, void *pUserData, bool bTransferDone, uint32_t u32Tcds)

This callback function is called in the EDMA interrupt handler function. In normal mode, running into callback function means the transfer users need is done. In scatter gather mode, run into callback function means a transfer control block (tcd) is finished. Not all transfer finished, users can get the finished tcd numbers using interface EDMA_GetUnusedTCDNumber.

Parameters
handleEDMA handle pointer, users shall not touch the values inside.
userDataThe callback user parameter pointer. Users can use this parameter to involve things users need to change in EDMA callback function.
transferDoneIf the current loaded transfer done. In normal mode it means if all transfer done. In scatter gather mode, this parameter shows is the current transfer block in EDMA register is done. As the load of core is different, it will be different if the new tcd loaded into EDMA registers while this callback called. If true, it always means new tcd still not loaded into registers, while false means new tcd already loaded into registers.
tcdsHow many tcds are done from the last callback. This parameter only used in scatter gather mode. It tells user how many tcds are finished between the last callback and this.

Enumeration Type Documentation

The enumerator used for transactional interface only.

Enumerator
kStatus_EDMA_ChannelQueueFull 

TCD queue is full.

kStatus_EDMA_ChannelBusy 

Channel is busy and can't handle the transfer request.

Enumerator
kEDMA_ChannelTransferMemoryToMemory 

Transfer type from memory to memory assume that the both source and destination address are incremental.

kEDMA_ChannelTransferPeripheralToMemory 

Transfer type peripher to memory assume that the source address is fixed.

kEDMA_ChannelTransferMemoryToPeripheral 

Transfer type from memory to peripheral assume that the destination address is fixed.

kEDMA_ChannelTransferPeripheralToPeripheral 

Transfer type from Peripheral to peripheral assume that both source and destination address are fixed.

The eDMA peripheral support generate interrupt when half of the total request bytes transferred or all of the request bytes transferred.

Enumerator
kEDMA_ChannelErrorInterruptEnable 

Enable error interrupt.

kEDMA_ChannelMajorLoopCompleteInterruptEnable 

Enable interrupt while major count exhausted.

kEDMA_ChannelMajorLoopHalfCompleteInterruptEnable 

Enable interrupt while major count to half value.

kEDMA_ChannelAllInterruptEnable 

Enable all the interrupt.

Enumerator
kEDMA_ChannelStatusErrorFlag 

eDMA error flag, an error occurred in a transfer

kEDMA_ChannelStatusMajorLoopCompleteFlag 

Major loop complete flag, set while transfer finished, CITER value exhausted.

kEDMA_ChannelStatusMajorLoopHalfCompleteFlag 

Major loop half complete flag.

Enumerator
kEDMA_ChannelDestinationBusErrorFlag 

Bus error on destination address.

kEDMA_ChannelSourceBusErrorFlag 

Bus error on the source address.

kEDMA_ChannelScatterGatherErrorFlag 

Error on the Scatter/Gather address, not 32byte aligned.

kEDMA_ChannelNbytesErrorFlag 

NBYTES/CITER configuration error.

kEDMA_ChannelDestinationOffsetErrorFlag 

Destination offset not aligned with destination size.

kEDMA_ChannelDestinationAddressErrorFlag 

Destination address not aligned with destination size.

kEDMA_ChannelSourceOffsetErrorFlag 

Source offset not aligned with source size.

kEDMA_ChannelSourceAddressErrorFlag 

Source address not aligned with source size.

kEDMA_ChannelErrorChannelFlag 

Error channel number of the canceled channel number.

kEDMA_ChannelPriorityErrorFlag 

Channel priority is not unique.

kEDMA_ChannelTransferCanceledFlag 

Transfer canceled.

kEDMA_ChannelValidFlag 

No error occurred, this bit is 0.

Otherwise, it is 1.

Enumerator
kEDMA_ArbitrationFixedPriority 

channel arbitration by fixed priority

kEDMA_ArbitrationRoundRobin 

Channel arbitration by round robin.

Enumerator
kEDMA_Channel0 

EDMA channel 0.

kEDMA_Channel1 

EDMA channel 1.

kEDMA_Channel2 

EDMA channel 2.

kEDMA_Channel3 

EDMA channel 3.

Enumerator
kEDMA_ChannelTransferWidth8Bits 

Source/Destination data transfer width is 1 byte every time.

kEDMA_ChannelTransferWidth16Bits 

Source/Destination data transfer width is 2 bytes every time.

kEDMA_ChannelTransferWidth32Bits 

Source/Destination data transfer width is 4 bytes every time.

kEDMA_ChannelTransferWidth128Bits 

Source/Destination data transfer size is 16 bytes every time.

The eDMA modulo feature can be used to specify the address range of the source/destination address, it is useful to implement a circular data queue.

Enumerator
kEDMA_ChannelModuloDisable 

Disable modulo.

kEDMA_ChannelModulo2bytes 

Circular buffer size is 2 bytes.

kEDMA_ChannelModulo4bytes 

Circular buffer size is 4 bytes.

kEDMA_ChannelModulo8bytes 

Circular buffer size is 8 bytes.

kEDMA_ChannelModulo16bytes 

Circular buffer size is 16 bytes.

kEDMA_ChannelModulo32bytes 

Circular buffer size is 32 bytes.

kEDMA_ChannelModulo64bytes 

Circular buffer size is 64 bytes.

kEDMA_ChannelModulo128bytes 

Circular buffer size is 128 bytes.

kEDMA_ChannelModulo256bytes 

Circular buffer size is 256 bytes.

kEDMA_ChannelModulo512bytes 

Circular buffer size is 512 bytes.

kEDMA_ChannelModulo1Kbytes 

Circular buffer size is 1 K bytes.

kEDMA_ChannelModulo2Kbytes 

Circular buffer size is 2 K bytes.

kEDMA_ChannelModulo4Kbytes 

Circular buffer size is 4 K bytes.

kEDMA_ChannelModulo8Kbytes 

Circular buffer size is 8 K bytes.

kEDMA_ChannelModulo16Kbytes 

Circular buffer size is 16 K bytes.

kEDMA_ChannelModulo32Kbytes 

Circular buffer size is 32 K bytes.

kEDMA_ChannelModulo64Kbytes 

Circular buffer size is 64 K bytes.

kEDMA_ChannelModulo128Kbytes 

Circular buffer size is 128 K bytes.

kEDMA_ChannelModulo256Kbytes 

Circular buffer size is 256 K bytes.

kEDMA_ChannelModulo512Kbytes 

Circular buffer size is 512 K bytes.

kEDMA_ChannelModulo1Mbytes 

Circular buffer size is 1 M bytes.

kEDMA_ChannelModulo2Mbytes 

Circular buffer size is 2 M bytes.

kEDMA_ChannelModulo4Mbytes 

Circular buffer size is 4 M bytes.

kEDMA_ChannelModulo8Mbytes 

Circular buffer size is 8 M bytes.

kEDMA_ChannelModulo16Mbytes 

Circular buffer size is 16 M bytes.

kEDMA_ChannelModulo32Mbytes 

Circular buffer size is 32 M bytes.

kEDMA_ChannelModulo64Mbytes 

Circular buffer size is 64 M bytes.

kEDMA_ChannelModulo128Mbytes 

Circular buffer size is 128 M bytes.

kEDMA_ChannelModulo256Mbytes 

Circular buffer size is 256 M bytes.

kEDMA_ChannelModulo512Mbytes 

Circular buffer size is 512 M bytes.

kEDMA_ChannelModulo1Gbytes 

Circular buffer size is 1 G bytes.

kEDMA_ChannelModulo2Gbytes 

Circular buffer size is 2 G bytes.

Generally, as the eDMA processes the minor loop, it continuously generates read/write sequences until the minor count is exhausted. This bandwidth field forces the eDMA to stall after the completion of each read/write access to control the bus request bandwidth.

The default configuration is kEDMA_BandwidthStallNone.

Enumerator
kEDMA_ChannelBandwidthStallNone 

No eDMA engine stalls.

kEDMA_ChannelBandwidthStall4Cycle 

eDMA engine stalls for 4 cycles after each read/write.

kEDMA_ChannelBandwidthStall8Cycle 

eDMA engine stalls for 8 cycles after each read/write.

Function Documentation

void EDMA_GetDefaultConfig ( edma_config_t psConfig)
Note
This function will reset all of the configuration structure members to zero firstly, then apply default configurations to the structure.
Parameters
psConfigpointer to user's eDMA config structure, see edma_config_t for detail.
void EDMA_Init ( DMA_Type *  base,
edma_config_t psConfig 
)
Parameters
baseeDMA peripheral base address.
psConfigpointer to user's eDMA config structure, see edma_transfer_config_t for detail.
void EDMA_Deinit ( DMA_Type *  base)
Parameters
baseeDMA peripheral base address.
static void EDMA_EnableContinuousChannelLinkMode ( DMA_Type *  base,
bool  bEnable 
)
inlinestatic

A minor loop channel link made to itself does not go through channel arbitration before being activated again. Upon minor loop completion, the channel activates again if that channel has a minor loop channel link enabled and the link channel is itself. This effectively applies the minor loop offsets and restarts the next minor loop.

Note
Do not use continuous link mode with a channel linking to itself if there is only one minor loop iteration per service request, for example, if the channel's NBYTES value is the same as either the source or destination size. The same data transfer profile can be achieved by simply increasing the NBYTES value, which provides more efficient, faster processing.
Parameters
baseEDMA peripheral base address.
bEnabletrue is channel link to itself without arbitration false is channel link to itself with arbitration
static void EDMA_EnableMinorLoopMapping ( DMA_Type *  base,
bool  bEnable 
)
inlinestatic

The TCDn.word2 is redefined to include individual enable fields, an offset field and the NBYTES field, the offset will be applied to source/destination address after minor loop complete

Parameters
baseEDMA peripheral base address.
bEnabletrue is minor loop bytes register redefined to individual enable/offset/minor loop bytes fields. false is minor loop bytes register defined as minor loop bytes fields only.
static void EDMA_EnableHaltOnError ( DMA_Type *  base,
bool  bEnable 
)
inlinestatic

Any error causes the HALT bit to set will cause the EDMA halt. Subsequently, all service requests are ignored until the HALT bit is cleared

Parameters
baseEDMA peripheral base address.
bEnabletrue is Stall the start of any new channels when error occur. false is eDMA service request operation normal when error occur.
static void EDMA_SetArbitration ( DMA_Type *  base,
edma_arbitration_type_t  eArbitration 
)
inlinestatic
Parameters
baseEDMA peripheral base address.
eArbitration,arbitrationby priority or round robin, edma_arbitration_type_t.
void EDMA_GetChannelDefaultTransferConfig ( edma_channel_transfer_config_t psTransfer,
void *  pSrcAddr,
void *  pDstAddr,
uint32_t  u32BytesEachRequest,
uint32_t  u32TotalBytes,
edma_channel_transfer_width_t  eTransferWidth,
edma_channel_transfer_type_t  eTransferType 
)
Note
1. This function will reset all of the configuration structure members to zero firstly, then apply default configurations to the structure.
  1. No interrupt enabled by this function by default, if application would like to use DMA interrupt please enable it manually by psTransfer->u16EnabledInterruptMask = _edma_channel_interrupt
Parameters
psConfigpointer to user's eDMA channel configure structure, see edma_channel_transfer_config_t for detail.
pSrcAddrsource address, must be byte address.
pDstAddrdestination address, must be byte address.
u32BytesEachRequestbytes to be transferred in each request(namely, in each minor loop).
u32TotalBytestotal bytes to be transferred.
eTransferWidth,itrepresents how many bits are transferred in each read/write.
eTransferTypeeDMA channel transfer type.
void EDMA_SetChannelTransferConfig ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_transfer_config_t psTransfer 
)
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
psTransferpointer to user's eDMA channel configure structure, see edma_channel_transfer_config_t for detail.
Note
1.This function must not be called while the channel transfer is ongoing or it causes unpredictable results. 2.The psLinkTCD must be configured before invoke this API if scatter/gather function is needed 3.The edma channel request may be enabled after the channel transfer configure done according to the transfer configurations.
void EDMA_SetChannelMinorLoopOffset ( DMA_Type *  base,
edma_channel_t  eChannel,
bool  bEnableSrcMinorLoopOffset,
bool  bEnableDestMinorLoopOffset,
int32_t  i32MinorLoopOffset 
)

The minor offset means that the signed-extended value is added to the source address or destination address after each minor loop.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
bEnableSrcMinorLoopOffset,trueis enable source address minor offset, otherwise is disable
bEnableDestMinorLoopOffset,trueis enable source address minor offset, otherwise is disable
i32MinorLoopOffset,minorloop offset value.
void EDMA_SetChannelPreemption ( DMA_Type *  base,
edma_channel_t  eChannel,
bool  bSuspendedByHighPriorityChannel,
bool  bSuspendLowPriorityChannel,
uint8_t  u8Priority 
)

This function configures the channel preemption attribute and the priority of the channel.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number
bSuspendedByHighPriorityChannel,trueis the channel can be suspended by high priority channel, otherwise cannot.
bSuspendLowPriorityChannel,trueis the channel can suspend low priority channel, otherwise cannot.
priority,channelpriority.
Note
, this function is used only in fixed-priority channel arbitration mode.
void EDMA_EnableMinorLoopChannelLink ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_t  eLinkChannel 
)

This function configures the minor link mode. The minor link means that the channel link is triggered every time that the minor loop bytes transferred complete.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
eLinkChannelThe linked channel number.
Note
Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid.
static void EDMA_DisableMinorLoopChannelLink ( DMA_Type *  base,
edma_channel_t  eChannel 
)
inlinestatic
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
void EDMA_EnableMajorLoopChannelLink ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_t  eLinkChannel 
)

This function configures the major link mode. The major link means that the channel link is triggered when the CITER is exhausted.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
eLinkChannelThe linked channel number.
Note
Users should ensure that DONE flag is cleared before calling this interface, or the configuration is invalid.
static void EDMA_DisableMajorLoopChannelLink ( DMA_Type *  base,
edma_channel_t  eChannel 
)
inlinestatic
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
void EDMA_SetChannelBandWidth ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_bandwidth_t  eBandWidth 
)

Because the eDMA processes the minor loop, it continuously generates read/write sequences until the minor count is exhausted. The bandwidth forces the eDMA to stall after the completion of each read/write access to control the bus request bandwidth seen by the crossbar switch.

Note
: 1.If the source and destination sizes are equal, this field is ignored between the first and second transfers and after the last write of each minor loop. This behavior is a side effect of reducing start-up latency. 2.When executing a large, zero wait-stated memory-to-memory transfer, insert bandwidth control using the TCD_CSR[BWC] bits to avoid: •* Starvation of another master accessing the memory. •* Any delay in writing a TCD duloop the transfer.
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
eBandWidthA bandwidth setting, which can be one of the
void EDMA_SetChannelModulo ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_modulo_t  eSrcModulo,
edma_channel_modulo_t  eDestModulo 
)

This function defines a specific address range of source/destination address, after the source/destination address hits the range boundary, source/destination address will wrap to origin value.

Setting this field provides the ability to implement a circular data queue easily. For data queues require loop power-of-2 size bytes, the queue should start at a 0-modulo-size address and the SMOD field should be set to the appropriate value for the queue, freezing the desired number of upper address bits. The value programmed into this field specifies the number of lower address bits allowed to change

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
eSrcModuloA source modulo value.
eDestModuloA destination modulo value.
static void EDMA_EnableChannelAsyncRequestInStopMode ( DMA_Type *  base,
edma_channel_t  eChannel,
bool  bEnable 
)
inlinestatic

The EARS register is used to enable or disable the DMA requests in Enable Request Register (ERQ) by AND'ing the bits of these two registers in stop mode only.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
bEnableThe command to enable (true) or disable (false).
static void EDMA_EnableChannelAutoStopRequest ( DMA_Type *  base,
edma_channel_t  eChannel,
bool  bEnable 
)
inlinestatic

The eDMA hardware automatically clears the corresponding ERQ bit when the current major iteration count reaches zero.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
bEnableThe command to enable (true) or disable (false).
void EDMA_SetChannelMajorLoopOffset ( DMA_Type *  base,
edma_channel_t  eChannel,
int32_t  i32SourceOffset,
int32_t  i32DestOffset 
)

Adjustment value added to the source/destination address at the completion of the major iteration count

Parameters
baseeDMA peripheral base address.
eChanneledma channel number.
i32SourceOffsetsource address offset.
i32DestOffsetdestination address offset.
static void EDMA_EnableChannelRequest ( DMA_Type *  base,
edma_channel_t  eChannel,
bool  bEnable 
)
inlinestatic

This function enables the hardware channel request.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
bEnabletrue is start, false is stop.
static void EDMA_SoftwareTriggerChannelStart ( DMA_Type *  base,
edma_channel_t  eChannel 
)
inlinestatic

This function starts a minor loop transfer only, the channel will halt when minor loop complete, so application should re-call the function to start the transfer again.

Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
uint32_t EDMA_GetChannelRemainingMajorLoopCount ( DMA_Type *  base,
edma_channel_t  eChannel 
)

This function checks the TCD (Transfer Control Descriptor) status for a specified eDMA channel and returns the number of major loop count that has not finished.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
Return values
Majorloop count which has not been transferred yet for the current TCD.
Note
1. This function can only be used to get unfinished major loop count of transfer without the next TCD, or it might be inaccuracy.
  1. The unfinished/remaining transfer bytes cannot be obtained directly from registers while the channel is running. Because to calculate the remaining bytes, the initial NBYTES configured in DMA_TCDn_NBYTES_MLNO register is needed while the eDMA IP does not support getting it while a channel is active. In another word, the NBYTES value reading is always the actual (decrementing) NBYTES value the dma_engine is working with while a channel is running. Consequently, to get the remaining transfer bytes, a software-saved initial value of NBYTES (for example copied before enabling the channel) is needed. The formula to calculate it is shown below: RemainingBytes = RemainingMajorLoopCount * NBYTES(initially configured)
void EDMA_EnableChannelInterrupts ( DMA_Type *  base,
edma_channel_t  eChannel,
uint16_t  u16InterruptsMask,
bool  bEnable 
)
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
u16InterruptsMaskthe mask is a logical OR of enumerator members see _edma_channel_interrupt_enable.
bEnabletrue is enable, false is disable.
uint16_t EDMA_GetChannelStatusFlags ( DMA_Type *  base,
edma_channel_t  eChannel 
)
Note
if the function return error status, application can call EDMA_GetErrorStatusFlags for the detail error status.
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
Return values
Themask of channel status flags. Users need to use the _edma_channel_status_flags type to decode the return variables.
void EDMA_ClearChannelStatusFlags ( DMA_Type *  base,
edma_channel_t  eChannel,
uint16_t  u16StatusFlags 
)
Parameters
baseeDMA peripheral base address.
eChanneleDMA channel number.
u16StatusFlagsThe mask of channel status to be cleared. Users need to use the defined _edma_channel_status_flags type.
static uint32_t EDMA_GetErrorStatusFlags ( DMA_Type *  base)
inlinestatic
Parameters
baseeDMA peripheral base address.
Returns
The mask of error status flags. Users need to use the _edma_error_status_flags type to decode the return variables.
void EDMA_ConfigChannelSoftwareTCD ( edma_channel_tcd_t *  psTcd,
edma_channel_transfer_config_t psTransfer 
)

Application should be careful about the TCD pool buffer storage class,

  • For the platform has cache, the software TCD should be put in non cache section
  • The TCD pool buffer should have a consistent storage class.
Note
Application should be careful when using the minor loop offset feature with this function, please make sure the EMLM bit is asserted, although EDMA_InitChannel will set this bit by default, if the bit is cleared, application can use EDMA_EnableMinorLoopMapping to enable the feature.
Parameters
psTcdPointer to the TCD structure.
psTransferchannel transfer configuration pointer.
Note
This function enables the auto stop request feature.
void EDMA_InstallChannelSoftwareTCD ( DMA_Type *  base,
edma_channel_t  eChannel,
edma_channel_tcd_t *  psTcd 
)
Parameters
baseEDMA peripheral base address.
eChannelEDMA channel number.
psTcdPoint to TCD structure.
void EDMA_TransferCreateHandle ( DMA_Type *  base,
edma_handle_t *  psHandle,
edma_channel_t  eChannel,
edma_channel_tcd_t *  psTcdPool,
uint32_t  u32TcdCount,
edma_transfer_callback_t  pfCallback,
void *  pUserData 
)

This function is called if using the transactional API for eDMA. This function initializes the internal state of the eDMA handle.

Parameters
baseeDMA peripheral base address.
handleeDMA handle pointer. The eDMA handle stores callback function and parameters.
channeleDMA channel number.
psTcdPoolA memory pool to store TCDs. It must be 32 bytes aligned.
u32TcdCountThe number of TCD slots.
callbackeDMA callback function pointer.
userDataA parameter for the callback function.
status_t EDMA_TransferSubmitSingleTransfer ( edma_handle_t *  psHandle,
edma_channel_transfer_config_t psTransfer 
)

Application can submit single transfer when

  1. channel is idle, the transfer request will be submitted to eDMA channel TCD register directly
  2. channel is idle, a previous transfer request is pending, the new transfer request will be submitted to the installed TCD pool and linked to the pending one.
  3. channel is active, the transfer request will be submitted to the installed TCD pool and linked to previous one.
Note
, 1.Please be aware of that tcd pool maintain is unprotect by default, that is to say, the behavior of multiple task trying to access the same channel is undefine, application can protect the channel by itself or overwrite EDMA_ENTER_CRITICAL_SECTION/EDMA_LEAVE_CRITICAL_SECTION to have edma driver protect the TCD pool maintain. 2.Since the destination major loop offset feature register is reused as scatter gather tcd address, so the two features cannot be used together, if the destination major loop offset feature is used, then the transfer request will be submit hardware TCD directly.

It is suggest that application should check the return value of this function to make sure that the transfer request is submitted successfully.

Parameters
psHandleeDMA handle pointer.
psTransferpointer to user's eDMA channel configure structure, see edma_channel_transfer_config_t for detail.
Return values
#kStatus_EDMA_SuccessIt means submit transfer request succeed.
#kStatus_EDMA_QueueFullIt means TCD queue is full. Submit transfer request is not allowed.
status_t EDMA_TransferSubmitLoopTransfer ( edma_handle_t *  psHandle,
edma_channel_transfer_config_t psTransfer,
uint32_t  transferLoopCount 
)

The function is target for submit loop transfer request, the ring transfer request means that the transfer request TAIL is link to HEAD, such as, A->B->C->D->A, or A->A

To use the ring transfer feature, the application should allocate several transfer object, such as

* EDMA_TransferSubmitLoopTransfer(psHandle, &transfer, 2U);
*

Then eDMA driver will link transfer[0] and transfer[1] to each other

Note
Application should check the return value of this function to avoid transfer request submit failed
Parameters
psHandleeDMA handle pointer
psTransferpointer to user's eDMA channel configure structure, see edma_channel_transfer_config_t for detail
transferLoopCountthe count of the transfer ring, if loop count is 1, that means that the one will link to itself.
Return values
#kStatus_EDMA_SuccessIt means submit transfer request succeed
kStatus_EDMA_ChannelBusychannel is in busy status
#kStatus_EDMA_QueueFullIt means TCD pool is not len enough for the ring transfer request
void EDMA_TransferStart ( edma_handle_t *  psHandle)

This function enables the channel request. Users can call this function after submitting the transfer request or before submitting the transfer request.

Parameters
psHandleeDMA handle pointer.
void EDMA_TransferStop ( edma_handle_t *  psHandle)

This function disables the channel request to pause the transfer. Users can call EDMA_StartTransfer() again to resume the transfer.

Parameters
psHandleeDMA handle pointer.
void EDMA_TransferAbort ( edma_handle_t *  psHandle)

This function disables the channel request and clear transfer status bits. Users can submit another transfer after calling this API.

Parameters
psHandleDMA handle pointer.
void EDMA_TransferHandleIRQ ( edma_handle_t *  psHandle)

This function clears the channel major interrupt flag and calls the callback function if it is not NULL.

Note: For the case using TCD queue, when the major iteration count is exhausted, additional Interfaces are performed. These include the final address adjustments and reloading of the BITER field into the CITER. Assertion of an optional interrupt request also occurs at this time, as does a possible fetch of a new TCD from memory using the scatter/gather address pointer included in the descriptor (if scatter/gather is enabled).

For instance, when the time interrupt of TCD[0] happens, the TCD[1] has already been loaded into the eDMA engine. As sga and sga_index are calculated based on the DLAST_SGA bit field lies in the TCD_CSR register, the sga_index in this case should be 2 (DLAST_SGA of TCD[1] stores the address of TCD[2]). Thus, the "tcdUsed" updated should be (tcdUsed - 2U) which indicates the number of TCDs can be loaded in the memory pool (because TCD[0] and TCD[1] have been loaded into the eDMA engine at this point already.).

For the last two continuous ISRs in a scatter/gather process, they both load the last TCD (The last ISR does not load a new TCD) from the memory pool to the eDMA engine when major loop completes. Therefore, ensure that the header and tcdUsed updated are identical for them. tcdUsed are both 0 in this case as no TCD to be loaded.

See the "eDMA basic data flow" in the eDMA Functional description section of the Reference Manual for further details.

Parameters
psHandleeDMA handle pointer.