Kinetis SDK v.2.0 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
eDMA: Enhanced Direct Memory Access Controller Driver

Overview

The KSDK provides a peripheral driver for the enhanced Direct Memory Access of Kinetis devices.

Typical use case

eDMA Operation

edma_transfer_config_t transferConfig;
edma_config_t userConfig;
uint32_t transferDone = false;
EDMA_GetDefaultConfig(&userConfig);
EDMA_Init(DMA0, &userConfig);
EDMA_CreateHandle(&g_EDMA_Handle, DMA0, channel);
EDMA_SetCallback(&g_EDMA_Handle, EDMA_Callback, &transferDone);
EDMA_PrepareTransfer(&transferConfig, srcAddr, srcWidth, destAddr, destWidth,
bytesEachRequest, transferBytes, kEDMA_MemoryToMemory);
EDMA_SubmitTransfer(&g_EDMA_Handle, &transferConfig, true);
EDMA_StartTransfer(&g_EDMA_Handle);
/* Wait for EDMA transfer finish
while (transferDone != true);

Files

file  fsl_edma.h
 

Data Structures

struct  edma_config_t
 eDMA global configuration structure. More...
 
struct  edma_transfer_config_t
 eDMA transfer configuration More...
 
struct  edma_channel_Preemption_config_t
 eDMA channel priority configuration More...
 
struct  edma_minor_offset_config_t
 eDMA minor offset configuration More...
 
struct  edma_tcd_t
 eDMA TCD. More...
 
struct  edma_handle_t
 eDMA transfer handle structure More...
 

Macros

#define DMA_DCHPRI_INDEX(channel)   (((channel) & ~0x03U) | (3 - ((channel)&0x03U)))
 Compute the offset unit from DCHPRI3.
 
#define DMA_DCHPRIn(base, channel)   ((volatile uint8_t *)&(base->DCHPRI3))[DMA_DCHPRI_INDEX(channel)]
 Get the pointer of DCHPRIn.
 

Typedefs

typedef void(* edma_callback )(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds)
 Define Callback function for eDMA. More...
 

Enumerations

enum  edma_transfer_size_t {
  kEDMA_TransferSize1Bytes = 0x0U,
  kEDMA_TransferSize2Bytes = 0x1U,
  kEDMA_TransferSize4Bytes = 0x2U,
  kEDMA_TransferSize16Bytes = 0x4U,
  kEDMA_TransferSize32Bytes = 0x5U
}
 eDMA transfer configuration More...
 
enum  edma_modulo_t {
  kEDMA_ModuloDisable = 0x0U,
  kEDMA_Modulo2bytes,
  kEDMA_Modulo4bytes,
  kEDMA_Modulo8bytes,
  kEDMA_Modulo16bytes,
  kEDMA_Modulo32bytes,
  kEDMA_Modulo64bytes,
  kEDMA_Modulo128bytes,
  kEDMA_Modulo256bytes,
  kEDMA_Modulo512bytes,
  kEDMA_Modulo1Kbytes,
  kEDMA_Modulo2Kbytes,
  kEDMA_Modulo4Kbytes,
  kEDMA_Modulo8Kbytes,
  kEDMA_Modulo16Kbytes,
  kEDMA_Modulo32Kbytes,
  kEDMA_Modulo64Kbytes,
  kEDMA_Modulo128Kbytes,
  kEDMA_Modulo256Kbytes,
  kEDMA_Modulo512Kbytes,
  kEDMA_Modulo1Mbytes,
  kEDMA_Modulo2Mbytes,
  kEDMA_Modulo4Mbytes,
  kEDMA_Modulo8Mbytes,
  kEDMA_Modulo16Mbytes,
  kEDMA_Modulo32Mbytes,
  kEDMA_Modulo64Mbytes,
  kEDMA_Modulo128Mbytes,
  kEDMA_Modulo256Mbytes,
  kEDMA_Modulo512Mbytes,
  kEDMA_Modulo1Gbytes,
  kEDMA_Modulo2Gbytes
}
 eDMA modulo configuration More...
 
enum  edma_bandwidth_t {
  kEDMA_BandwidthStallNone = 0x0U,
  kEDMA_BandwidthStall4Cycle = 0x2U,
  kEDMA_BandwidthStall8Cycle = 0x3U
}
 Bandwidth control. More...
 
enum  edma_channel_link_type_t {
  kEDMA_LinkNone = 0x0U,
  kEDMA_MinorLink,
  kEDMA_MajorLink
}
 Channel link type. More...
 
enum  _edma_channel_status_flags {
  kEDMA_DoneFlag = 0x1U,
  kEDMA_ErrorFlag = 0x2U,
  kEDMA_InterruptFlag = 0x4U
}
 eDMA channel status flags. More...
 
enum  _edma_error_status_flags {
  kEDMA_DestinationBusErrorFlag = DMA_ES_DBE_MASK,
  kEDMA_SourceBusErrorFlag = DMA_ES_SBE_MASK,
  kEDMA_ScatterGatherErrorFlag = DMA_ES_SGE_MASK,
  kEDMA_NbytesErrorFlag = DMA_ES_NCE_MASK,
  kEDMA_DestinationOffsetErrorFlag = DMA_ES_DOE_MASK,
  kEDMA_DestinationAddressErrorFlag = DMA_ES_DAE_MASK,
  kEDMA_SourceOffsetErrorFlag = DMA_ES_SOE_MASK,
  kEDMA_SourceAddressErrorFlag = DMA_ES_SAE_MASK,
  kEDMA_ErrorChannelFlag = DMA_ES_ERRCHN_MASK,
  kEDMA_ChannelPriorityErrorFlag = DMA_ES_CPE_MASK,
  kEDMA_TransferCanceledFlag = DMA_ES_ECX_MASK,
  kEDMA_ValidFlag = DMA_ES_VLD_MASK
}
 eDMA channel error status flags. More...
 
enum  edma_interrupt_enable_t {
  kEDMA_ErrorInterruptEnable = 0x1U,
  kEDMA_MajorInterruptEnable = DMA_CSR_INTMAJOR_MASK,
  kEDMA_HalfInterruptEnable = DMA_CSR_INTHALF_MASK
}
 eDMA interrupt source More...
 
enum  edma_transfer_type_t {
  kEDMA_MemoryToMemory = 0x0U,
  kEDMA_PeripheralToMemory,
  kEDMA_MemoryToPeripheral
}
 eDMA transfer type More...
 
enum  _edma_transfer_status {
  kStatus_EDMA_QueueFull = MAKE_STATUS(kStatusGroup_EDMA, 0),
  kStatus_EDMA_Busy = MAKE_STATUS(kStatusGroup_EDMA, 1)
}
 eDMA transfer status More...
 

Driver version

#define FSL_EDMA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 eDMA driver version More...
 

eDMA initialization and De-initialization

void EDMA_Init (DMA_Type *base, const edma_config_t *config)
 Initializes eDMA peripheral. More...
 
void EDMA_Deinit (DMA_Type *base)
 Deinitializes eDMA peripheral. More...
 
void EDMA_GetDefaultConfig (edma_config_t *config)
 Gets the eDMA default configuration structure. More...
 

eDMA Channel Operation

void EDMA_ResetChannel (DMA_Type *base, uint32_t channel)
 Sets all TCD registers to a default value. More...
 
void EDMA_SetTransferConfig (DMA_Type *base, uint32_t channel, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
 Configures the eDMA transfer attribute. More...
 
void EDMA_SetMinorOffsetConfig (DMA_Type *base, uint32_t channel, const edma_minor_offset_config_t *config)
 Configures the eDMA minor offset feature. More...
 
static void EDMA_SetChannelPreemptionConfig (DMA_Type *base, uint32_t channel, const edma_channel_Preemption_config_t *config)
 Configures the eDMA channel preemption feature. More...
 
void EDMA_SetChannelLink (DMA_Type *base, uint32_t channel, edma_channel_link_type_t type, uint32_t linkedChannel)
 Sets the channel link for the eDMA transfer. More...
 
void EDMA_SetBandWidth (DMA_Type *base, uint32_t channel, edma_bandwidth_t bandWidth)
 Sets the bandwidth for the eDMA transfer. More...
 
void EDMA_SetModulo (DMA_Type *base, uint32_t channel, edma_modulo_t srcModulo, edma_modulo_t destModulo)
 Sets the source modulo and destination modulo for eDMA transfer. More...
 
static void EDMA_EnableAutoStopRequest (DMA_Type *base, uint32_t channel, bool enable)
 Enables an auto stop request for the eDMA transfer. More...
 
void EDMA_EnableChannelInterrupts (DMA_Type *base, uint32_t channel, uint32_t mask)
 Enables the interrupt source for the eDMA transfer. More...
 
void EDMA_DisableChannelInterrupts (DMA_Type *base, uint32_t channel, uint32_t mask)
 Disables the interrupt source for the eDMA transfer. More...
 

eDMA TCD Operation

void EDMA_TcdReset (edma_tcd_t *tcd)
 Sets all fields to default values for the TCD structure. More...
 
void EDMA_TcdSetTransferConfig (edma_tcd_t *tcd, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
 Configures the eDMA TCD transfer attribute. More...
 
void EDMA_TcdSetMinorOffsetConfig (edma_tcd_t *tcd, const edma_minor_offset_config_t *config)
 Configures the eDMA TCD minor offset feature. More...
 
void EDMA_TcdSetChannelLink (edma_tcd_t *tcd, edma_channel_link_type_t type, uint32_t linkedChannel)
 Sets the channel link for eDMA TCD. More...
 
static void EDMA_TcdSetBandWidth (edma_tcd_t *tcd, edma_bandwidth_t bandWidth)
 Sets the bandwidth for the eDMA TCD. More...
 
void EDMA_TcdSetModulo (edma_tcd_t *tcd, edma_modulo_t srcModulo, edma_modulo_t destModulo)
 Sets the source modulo and destination modulo for eDMA TCD. More...
 
static void EDMA_TcdEnableAutoStopRequest (edma_tcd_t *tcd, bool enable)
 Sets the auto stop request for the eDMA TCD. More...
 
void EDMA_TcdEnableInterrupts (edma_tcd_t *tcd, uint32_t mask)
 Enables the interrupt source for the eDMA TCD. More...
 
void EDMA_TcdDisableInterrupts (edma_tcd_t *tcd, uint32_t mask)
 Disables the interrupt source for the eDMA TCD. More...
 

eDMA Channel Transfer Operation

static void EDMA_EnableChannelRequest (DMA_Type *base, uint32_t channel)
 Enables the eDMA hardware channel request. More...
 
static void EDMA_DisableChannelRequest (DMA_Type *base, uint32_t channel)
 Disables the eDMA hardware channel request. More...
 
static void EDMA_TriggerChannelStart (DMA_Type *base, uint32_t channel)
 Starts the eDMA transfer by software trigger. More...
 

eDMA Channel Status Operation

uint32_t EDMA_GetRemainingBytes (DMA_Type *base, uint32_t channel)
 Gets the Remaining bytes from the eDMA current channel TCD. More...
 
static uint32_t EDMA_GetErrorStatusFlags (DMA_Type *base)
 Gets the eDMA channel error status flags. More...
 
uint32_t EDMA_GetChannelStatusFlags (DMA_Type *base, uint32_t channel)
 Gets the eDMA channel status flags. More...
 
void EDMA_ClearChannelStatusFlags (DMA_Type *base, uint32_t channel, uint32_t mask)
 Clears the eDMA channel status flags. More...
 

eDMA Transactional Operation

void EDMA_CreateHandle (edma_handle_t *handle, DMA_Type *base, uint32_t channel)
 Creates the eDMA handle. More...
 
void EDMA_InstallTCDMemory (edma_handle_t *handle, edma_tcd_t *tcdPool, uint32_t tcdSize)
 Installs the TCDs memory pool into eDMA handle. More...
 
void EDMA_SetCallback (edma_handle_t *handle, edma_callback callback, void *userData)
 Installs a callback function for the eDMA transfer. More...
 
void EDMA_PrepareTransfer (edma_transfer_config_t *config, void *srcAddr, uint32_t srcWidth, void *destAddr, uint32_t destWidth, uint32_t bytesEachRequest, uint32_t transferBytes, edma_transfer_type_t type)
 Prepares the eDMA transfer structure. More...
 
status_t EDMA_SubmitTransfer (edma_handle_t *handle, const edma_transfer_config_t *config)
 Submits the eDMA transfer request. More...
 
void EDMA_StartTransfer (edma_handle_t *handle)
 eDMA start transfer. More...
 
void EDMA_StopTransfer (edma_handle_t *handle)
 eDMA stop transfer. More...
 
void EDMA_AbortTransfer (edma_handle_t *handle)
 eDMA abort transfer. More...
 
void EDMA_HandleIRQ (edma_handle_t *handle)
 eDMA IRQ handler for current major loop transfer complete. More...
 

Data Structure Documentation

struct edma_config_t

Data Fields

bool enableContinuousLinkMode
 Enable (true) continuous link mode. More...
 
bool enableHaltOnError
 Enable (true) transfer halt on error. More...
 
bool enableRoundRobinArbitration
 Enable (true) round robin channel arbitration method, or fixed priority arbitration is used for channel selection.
 
bool enableDebugMode
 Enable(true) eDMA debug mode. More...
 

Field Documentation

bool edma_config_t::enableContinuousLinkMode

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::enableHaltOnError

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

bool edma_config_t::enableDebugMode

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

struct edma_transfer_config_t

This structure configures the source/destination transfer attribute. This figure shows the eDMA's transfer model:


| Transfer Size | | Minor Loop |_______________| Major loop Count 1 | Bytes | Transfer Size | | ____________|_______________|____________________|–> Minor loop complete


| | | |_______________| Major Loop Count 2 | | | | |_______________|____________________|–> Minor loop Complete

------------------------------------------------------—> Transfer complete

Data Fields

uint32_t srcAddr
 Source data address. More...
 
uint32_t destAddr
 Destination data address. More...
 
edma_transfer_size_t srcTransferSize
 Source data transfer size. More...
 
edma_transfer_size_t destTransferSize
 Destination data transfer size. More...
 
int16_t srcOffset
 Sign-extended offset applied to the current source address to form the next-state value as each source read is completed. More...
 
int16_t destOffset
 Sign-extended offset applied to the current destination address to form the next-state value as each destination write is completed. More...
 
uint16_t minorLoopBytes
 Bytes to transfer in a minor loop.
 
uint32_t majorLoopCounts
 Major loop iteration count. More...
 

Field Documentation

uint32_t edma_transfer_config_t::srcAddr
uint32_t edma_transfer_config_t::destAddr
edma_transfer_size_t edma_transfer_config_t::srcTransferSize
edma_transfer_size_t edma_transfer_config_t::destTransferSize
int16_t edma_transfer_config_t::srcOffset
int16_t edma_transfer_config_t::destOffset
uint32_t edma_transfer_config_t::majorLoopCounts
struct edma_channel_Preemption_config_t

Data Fields

bool enableChannelPreemption
 If true: channel can be suspended by other channel with higher priority.
 
bool enablePreemptAbility
 If true: channel can suspend other channel with low priority.
 
uint8_t channelPriority
 Channel priority.
 
struct edma_minor_offset_config_t

Data Fields

bool enableSrcMinorOffset
 Enable(true) or Disable(false) source minor loop offset. More...
 
bool enableDestMinorOffset
 Enable(true) or Disable(false) destination minor loop offset. More...
 
uint32_t minorOffset
 Offset for minor loop mapping. More...
 

Field Documentation

bool edma_minor_offset_config_t::enableSrcMinorOffset
bool edma_minor_offset_config_t::enableDestMinorOffset
uint32_t edma_minor_offset_config_t::minorOffset
struct edma_tcd_t

This structure is same as TCD register which is described in reference manual, and is used to configure scatter/gather feature as a next hardware TCD.

Data Fields

__IO uint32_t SADDR
 SADDR register, used to save source address.
 
__IO uint16_t SOFF
 SOFF register, save offset bytes every transfer.
 
__IO uint16_t ATTR
 ATTR register, source/destination transfer size and modulo.
 
__IO uint32_t NBYTES
 Nbytes register, minor loop length in bytes.
 
__IO uint32_t SLAST
 SLAST register.
 
__IO uint32_t DADDR
 DADDR register, used for destination address.
 
__IO uint16_t DOFF
 DOFF register, used for destination offset.
 
__IO uint16_t CITER
 CITER register, current minor loop numbers, for unfinished minor loop. More...
 
__IO uint32_t DLAST_SGA
 DLASTSGA register, next stcd address used in scatter-gather mode.
 
__IO uint16_t CSR
 CSR register, for TCD control status.
 
__IO uint16_t BITER
 BITER register, begin minor loop count. More...
 

Field Documentation

__IO uint16_t edma_tcd_t::CITER
__IO uint16_t edma_tcd_t::BITER
struct edma_handle_t

Data Fields

edma_callback callback
 Callback function for major count exhausted. More...
 
void * userData
 Callback function parameter. More...
 
DMA_Type * base
 eDMA peripheral base address. More...
 
edma_tcd_ttcdPool
 Pointer to memory stored TCDs. More...
 
uint8_t channel
 eDMA channel number. More...
 
volatile int8_t header
 The first TCD index. More...
 
volatile int8_t tail
 The last TCD index. More...
 
volatile int8_t tcdUsed
 The number of used TCD slots. More...
 
volatile int8_t tcdSize
 The total number of TCD slots in the queue. More...
 
uint8_t flags
 The status of the current channel. More...
 

Field Documentation

edma_callback edma_handle_t::callback
void* edma_handle_t::userData
DMA_Type* edma_handle_t::base
edma_tcd_t* edma_handle_t::tcdPool
uint8_t edma_handle_t::channel
volatile int8_t edma_handle_t::header
volatile int8_t edma_handle_t::tail
volatile int8_t edma_handle_t::tcdUsed
volatile int8_t edma_handle_t::tcdSize
uint8_t edma_handle_t::flags

Macro Definition Documentation

#define FSL_EDMA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Version 2.0.0.

Typedef Documentation

typedef void(* edma_callback)(struct _edma_handle *handle, void *userData, bool transferDone, uint32_t tcds)

Enumeration Type Documentation

Enumerator
kEDMA_TransferSize1Bytes 

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

kEDMA_TransferSize2Bytes 

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

kEDMA_TransferSize4Bytes 

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

kEDMA_TransferSize16Bytes 

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

kEDMA_TransferSize32Bytes 

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

Enumerator
kEDMA_ModuloDisable 

Disable modulo.

kEDMA_Modulo2bytes 

Circular buffer size is 2 bytes.

kEDMA_Modulo4bytes 

Circular buffer size is 4 bytes.

kEDMA_Modulo8bytes 

Circular buffer size is 8 bytes.

kEDMA_Modulo16bytes 

Circular buffer size is 16 bytes.

kEDMA_Modulo32bytes 

Circular buffer size is 32 bytes.

kEDMA_Modulo64bytes 

Circular buffer size is 64 bytes.

kEDMA_Modulo128bytes 

Circular buffer size is 128 bytes.

kEDMA_Modulo256bytes 

Circular buffer size is 256 bytes.

kEDMA_Modulo512bytes 

Circular buffer size is 512 bytes.

kEDMA_Modulo1Kbytes 

Circular buffer size is 1K bytes.

kEDMA_Modulo2Kbytes 

Circular buffer size is 2K bytes.

kEDMA_Modulo4Kbytes 

Circular buffer size is 4K bytes.

kEDMA_Modulo8Kbytes 

Circular buffer size is 8K bytes.

kEDMA_Modulo16Kbytes 

Circular buffer size is 16K bytes.

kEDMA_Modulo32Kbytes 

Circular buffer size is 32K bytes.

kEDMA_Modulo64Kbytes 

Circular buffer size is 64K bytes.

kEDMA_Modulo128Kbytes 

Circular buffer size is 128K bytes.

kEDMA_Modulo256Kbytes 

Circular buffer size is 256K bytes.

kEDMA_Modulo512Kbytes 

Circular buffer size is 512K bytes.

kEDMA_Modulo1Mbytes 

Circular buffer size is 1M bytes.

kEDMA_Modulo2Mbytes 

Circular buffer size is 2M bytes.

kEDMA_Modulo4Mbytes 

Circular buffer size is 4M bytes.

kEDMA_Modulo8Mbytes 

Circular buffer size is 8M bytes.

kEDMA_Modulo16Mbytes 

Circular buffer size is 16M bytes.

kEDMA_Modulo32Mbytes 

Circular buffer size is 32M bytes.

kEDMA_Modulo64Mbytes 

Circular buffer size is 64M bytes.

kEDMA_Modulo128Mbytes 

Circular buffer size is 128M bytes.

kEDMA_Modulo256Mbytes 

Circular buffer size is 256M bytes.

kEDMA_Modulo512Mbytes 

Circular buffer size is 512M bytes.

kEDMA_Modulo1Gbytes 

Circular buffer size is 1G bytes.

kEDMA_Modulo2Gbytes 

Circular buffer size is 2G bytes.

Enumerator
kEDMA_BandwidthStallNone 

No eDMA engine stalls.

kEDMA_BandwidthStall4Cycle 

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

kEDMA_BandwidthStall8Cycle 

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

Enumerator
kEDMA_LinkNone 

No channel link.

kEDMA_MinorLink 

Channel link after each minor loop.

kEDMA_MajorLink 

Channel link while major loop count exhausted.

Enumerator
kEDMA_DoneFlag 

DONE flag, set while transfer finished, CITER value exhausted.

kEDMA_ErrorFlag 

eDMA error flag, an error occurred in a transfer

kEDMA_InterruptFlag 

eDMA interrupt flag, set while an interrupt occurred of this channel

Enumerator
kEDMA_DestinationBusErrorFlag 

Bus error on destination address.

kEDMA_SourceBusErrorFlag 

Bus error on the source address.

kEDMA_ScatterGatherErrorFlag 

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

kEDMA_NbytesErrorFlag 

NBYTES/CITER configuration error.

kEDMA_DestinationOffsetErrorFlag 

Destination offset not aligned with destination size.

kEDMA_DestinationAddressErrorFlag 

Destination address not aligned with destination size.

kEDMA_SourceOffsetErrorFlag 

Source offset not aligned with source size.

kEDMA_SourceAddressErrorFlag 

Source address not aligned with source size.

kEDMA_ErrorChannelFlag 

Error channel number of the cancelled channel number.

kEDMA_ChannelPriorityErrorFlag 

Channel priority is not unique.

kEDMA_TransferCanceledFlag 

Transfer cancelled.

kEDMA_ValidFlag 

No error occurred, this bit will be 0, otherwise be 1.

Enumerator
kEDMA_ErrorInterruptEnable 

Enable interrupt while channel error occurs.

kEDMA_MajorInterruptEnable 

Enable interrupt while major count exhausted.

kEDMA_HalfInterruptEnable 

Enable interrupt while major count to half value.

Enumerator
kEDMA_MemoryToMemory 

Transfer from memory to memory.

kEDMA_PeripheralToMemory 

Transfer from peripheral to memory.

kEDMA_MemoryToPeripheral 

Transfer from memory to peripheral.

Enumerator
kStatus_EDMA_QueueFull 

TCD queue is full.

kStatus_EDMA_Busy 

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

Function Documentation

void EDMA_Init ( DMA_Type *  base,
const edma_config_t config 
)

This function ungates the eDMA clock and configure eDMA peripheral according to the configuration structure.

Parameters
baseeDMA peripheral base address.
configPointer to configuration structure, see "edma_config_t".
Note
This function enable the minor loop map feature.
void EDMA_Deinit ( DMA_Type *  base)

This function gates the eDMA clock.

Parameters
baseeDMA peripheral base address.
void EDMA_GetDefaultConfig ( edma_config_t config)

This function sets the configuration structure to a default value. The default configuration is set to the following value:

config.enableContinuousLinkMode = false;
config.enableHaltOnError = true;
config.enableRoundRobinArbitration = false;
config.enableDebugMode = false;
Parameters
configPointer to eDMA configuration structure.
void EDMA_ResetChannel ( DMA_Type *  base,
uint32_t  channel 
)

This function sets TCD registers for this channel to default value.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
Note
This function must not be called while the channel transfer is on-going, or it will case unpredicated results.
This function will enable auto stop request feature.
void EDMA_SetTransferConfig ( DMA_Type *  base,
uint32_t  channel,
const edma_transfer_config_t config,
edma_tcd_t nextTcd 
)

This function configure the transfer attribute, including source address, destination address, transfer size, address offset, and so on. It also configures the scatter gather feature if the user supplies the TCD address. Example:

edma_transfer_t config;
config.srcAddr = ..;
config.destAddr = ..;
...
EDMA_SetTransferConfig(DMA0, channel, &config, &stcd);
Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
configPointer to eDMA transfer configuration structure.
nextTcdPoint to TCD structure. It can be NULL if user do not want to enable scatter/gather feature.
Note
If nextTcd is not NULL, it means scatter gather feature will be enabled. And DREQ bit will be cleared in the previous transfer configuration which will be set in eDMA_ResetChannel.
void EDMA_SetMinorOffsetConfig ( DMA_Type *  base,
uint32_t  channel,
const edma_minor_offset_config_t config 
)

Minor offset means signed-extended value added to source address or destination address after each minor loop.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
configPointer to Minor offset configuration structure.
static void EDMA_SetChannelPreemptionConfig ( DMA_Type *  base,
uint32_t  channel,
const edma_channel_Preemption_config_t config 
)
inlinestatic

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

Parameters
baseeDMA peripheral base address.
channeleDMA channel number
configPointer to channel preemption configuration structure.
void EDMA_SetChannelLink ( DMA_Type *  base,
uint32_t  channel,
edma_channel_link_type_t  type,
uint32_t  linkedChannel 
)

This function configures minor link or major link mode. The minor link means that the channel link is triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is exhausted.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
typeChannel link type, it can be one of:
  • kEDMA_LinkNone
  • kEDMA_MinorLink
  • kEDMA_MajorLink
linkedChannelThe linked channel number.
Note
User should ensure that DONE flag is cleared before call this interface, or the configuration will be invalid.
void EDMA_SetBandWidth ( DMA_Type *  base,
uint32_t  channel,
edma_bandwidth_t  bandWidth 
)

In general, 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.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
bandWidthBandwidth setting, it can be one of:
  • kEDMABandwidthStallNone
  • kEDMABandwidthStall4Cycle
  • kEDMABandwidthStall8Cycle
void EDMA_SetModulo ( DMA_Type *  base,
uint32_t  channel,
edma_modulo_t  srcModulo,
edma_modulo_t  destModulo 
)

This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) calculation is performed or the original register value. It provides the ability to implement a circular data queue easily.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
srcModuloSource modulo value.
destModuloDestination modulo value.
static void EDMA_EnableAutoStopRequest ( DMA_Type *  base,
uint32_t  channel,
bool  enable 
)
inlinestatic

If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
enableThe command for enable (true) or disable (false).
void EDMA_EnableChannelInterrupts ( DMA_Type *  base,
uint32_t  channel,
uint32_t  mask 
)
Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
maskThe mask of interrupt source to be set. User need to use the defined edma_interrupt_enable_t type.
void EDMA_DisableChannelInterrupts ( DMA_Type *  base,
uint32_t  channel,
uint32_t  mask 
)
Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
maskThe mask of interrupt source to be set. Use the defined edma_interrupt_enable_t type.
void EDMA_TcdReset ( edma_tcd_t tcd)

This function sets all fields for this TCD structure to default value.

Parameters
tcdPointer to the TCD structure.
Note
This function will enable auto stop request feature.
void EDMA_TcdSetTransferConfig ( edma_tcd_t tcd,
const edma_transfer_config_t config,
edma_tcd_t nextTcd 
)

TCD is a transfer control descriptor. The content of the TCD is the same as hardware TCD registers. STCD is used in scatter-gather mode. This function configures the TCD transfer attribute, including source address, destination address, transfer size, address offset, and so on. It also configures the scatter gather feature if the user supplies the next TCD address. Example:

edma_transfer_t config = {
...
}
edma_tcd_t tcd __aligned(32);
edma_tcd_t nextTcd __aligned(32);
EDMA_TcdSetTransferConfig(&tcd, &config, &nextTcd);
Parameters
tcdPointer to the TCD structure.
configPointer to eDMA transfer configuration structure.
nextTcdPointer to the next TCD structure. It can be NULL if user do not want to enable scatter/gather feature.
Note
TCD address should be 32 bytes aligned, or it will cause eDMA error.
If nextTcd is not NULL, it means scatter gather feature will be enabled. And DREQ bit will be cleared in the previous transfer configuration which will be set in EDMA_TcdReset.
void EDMA_TcdSetMinorOffsetConfig ( edma_tcd_t tcd,
const edma_minor_offset_config_t config 
)

Minor offset is a signed-extended value added to the source address or destination address after each minor loop.

Parameters
tcdPoint to the TCD structure.
configPointer to Minor offset configuration structure.
void EDMA_TcdSetChannelLink ( edma_tcd_t tcd,
edma_channel_link_type_t  type,
uint32_t  linkedChannel 
)

This function configures either a minor link or a major link. The minor link means the channel link is triggered every time CITER decreases by 1. The major link means that the channel link is triggered when the CITER is exhausted.

Note
User should ensure that DONE flag is cleared before call this interface, or the configuration will be invalid.
Parameters
tcdPoint to the TCD structure.
typeChannel link type, it can be one of:
  • kEDMA_LinkNone
  • kEDMA_MinorLink
  • kEDMA_MajorLink
linkedChannelThe linked channel number.
static void EDMA_TcdSetBandWidth ( edma_tcd_t tcd,
edma_bandwidth_t  bandWidth 
)
inlinestatic

In general, because the eDMA processes the minor loop, it continuously generates read/write sequences until the minor count is exhausted. 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.

Parameters
tcdPoint to the TCD structure.
bandWidthBandwidth setting, it can be one of:
  • kEDMABandwidthStallNone
  • kEDMABandwidthStall4Cycle
  • kEDMABandwidthStall8Cycle
void EDMA_TcdSetModulo ( edma_tcd_t tcd,
edma_modulo_t  srcModulo,
edma_modulo_t  destModulo 
)

This function defines a specific address range specified to be the value after (SADDR + SOFF)/(DADDR + DOFF) calculation is performed or the original register value. It provides the ability to implement a circular data queue easily.

Parameters
tcdPoint to the TCD structure.
srcModuloSource modulo value.
destModuloDestination modulo value.
static void EDMA_TcdEnableAutoStopRequest ( edma_tcd_t tcd,
bool  enable 
)
inlinestatic

If enabling the auto stop request, the eDMA hardware automatically disables the hardware channel request.

Parameters
tcdPoint to the TCD structure.
enableThe command for enable(ture) or disable(false).
void EDMA_TcdEnableInterrupts ( edma_tcd_t tcd,
uint32_t  mask 
)
Parameters
tcdPoint to the TCD structure.
maskThe mask of interrupt source to be set. User need to use the defined edma_interrupt_enable_t type.
void EDMA_TcdDisableInterrupts ( edma_tcd_t tcd,
uint32_t  mask 
)
Parameters
tcdPoint to the TCD structure.
maskThe mask of interrupt source to be set. User need to use the defined edma_interrupt_enable_t type.
static void EDMA_EnableChannelRequest ( DMA_Type *  base,
uint32_t  channel 
)
inlinestatic

This function enables the hardware channel request.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
static void EDMA_DisableChannelRequest ( DMA_Type *  base,
uint32_t  channel 
)
inlinestatic

This function disables the hardware channel request.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
static void EDMA_TriggerChannelStart ( DMA_Type *  base,
uint32_t  channel 
)
inlinestatic

This function starts a minor loop transfer.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
uint32_t EDMA_GetRemainingBytes ( DMA_Type *  base,
uint32_t  channel 
)

This function checks the TCD (Task Control Descriptor) status for a specified eDMA channel and returns the the number of bytes that have not finished.

Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
Returns
Bytes have not been transferred yet for the current TCD.
Note
This function can only be used to get unfinished bytes of transfer without the next TCD, or it might be inaccuracy.
static uint32_t EDMA_GetErrorStatusFlags ( DMA_Type *  base)
inlinestatic
Parameters
baseeDMA peripheral base address.
Returns
The mask of error status flags. User need to use the _edma_error_status_flags type to decode the return variables.
uint32_t EDMA_GetChannelStatusFlags ( DMA_Type *  base,
uint32_t  channel 
)
Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
Returns
The mask of channel status flags. User need to use the _edma_channel_status_flags type to decode the return variables.
void EDMA_ClearChannelStatusFlags ( DMA_Type *  base,
uint32_t  channel,
uint32_t  mask 
)
Parameters
baseeDMA peripheral base address.
channeleDMA channel number.
maskThe mask of channel status to be cleared. User need to use the defined _edma_channel_status_flags type.
void EDMA_CreateHandle ( edma_handle_t handle,
DMA_Type *  base,
uint32_t  channel 
)

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

Parameters
handleeDMA handle pointer. The eDMA handle stores callback function and parameters.
baseeDMA peripheral base address.
channeleDMA channel number.
void EDMA_InstallTCDMemory ( edma_handle_t handle,
edma_tcd_t tcdPool,
uint32_t  tcdSize 
)

This function is called after the EDMA_CreateHandle to use scatter/gather feature.

Parameters
handleeDMA handle pointer.
tcdPoolMemory pool to store TCDs. It must be 32 bytes aligned.
tcdSizeThe number of TCD slots.
void EDMA_SetCallback ( edma_handle_t handle,
edma_callback  callback,
void *  userData 
)

This callback is called in eDMA IRQ handler. Use the callback to do something after the current major loop transfer completes.

Parameters
handleeDMA handle pointer.
callbackeDMA callback function pointer.
userDataParameter for callback function.
void EDMA_PrepareTransfer ( edma_transfer_config_t config,
void *  srcAddr,
uint32_t  srcWidth,
void *  destAddr,
uint32_t  destWidth,
uint32_t  bytesEachRequest,
uint32_t  transferBytes,
edma_transfer_type_t  type 
)

This function prepares the transfer configuration structure according to the user input.

Parameters
configThe user configuration structure of type edma_transfer_t.
srcAddreDMA transfer source address.
srcWidtheDMA transfer source address width(bytes).
destAddreDMA transfer destination address.
destWidtheDMA transfer destination address width(bytes).
bytesEachRequesteDMA transfer bytes per channel request.
transferByteseDMA transfer bytes to be transferred.
typeeDMA transfer type.
Note
The data address and the data width must be consistent. For example, if the SRC is 4 bytes, so the source address must be 4 bytes aligned, or it shall result in source address error(SAE).
status_t EDMA_SubmitTransfer ( edma_handle_t handle,
const edma_transfer_config_t config 
)

This function submits the eDMA transfer request according to the transfer configuration structure. If the user submits the transfer request repeatedly, this function packs an unprocessed request as a TCD and enables scatter/gather feature to process it in the next time.

Parameters
handleeDMA handle pointer.
configPointer to eDMA transfer configuration structure.
Return values
kStatus_EDMA_SuccessIt means submit transfer request succeed.
kStatus_EDMA_QueueFullIt means TCD queue is full. Submit transfer request is not allowed.
kStatus_EDMA_BusyIt means the given channel is busy, need to submit request later.
void EDMA_StartTransfer ( edma_handle_t handle)

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

Parameters
handleeDMA handle pointer.
void EDMA_StopTransfer ( edma_handle_t handle)

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

Parameters
handleeDMA handle pointer.
void EDMA_AbortTransfer ( edma_handle_t handle)

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

Parameters
handleDMA handle pointer.
void EDMA_HandleIRQ ( edma_handle_t handle)

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

Parameters
handleeDMA handle pointer.