MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
Files | |
file | fsl_dma.h |
Data Structures | |
struct | dma_descriptor_t |
DMA descriptor structure. More... | |
struct | dma_xfercfg_t |
DMA transfer configuration. More... | |
struct | dma_channel_trigger_t |
DMA channel trigger. More... | |
struct | dma_channel_config_t |
DMA channel trigger. More... | |
struct | dma_transfer_config_t |
DMA transfer configuration. More... | |
struct | dma_handle_t |
DMA transfer handle structure. More... | |
Macros | |
#define | DMA_MAX_TRANSFER_COUNT 0x400U |
DMA max transfer size. | |
#define | FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE (16U) |
DMA channel numbers. More... | |
#define | DMA_ALLOCATE_HEAD_DESCRIPTORS(name, number) SDK_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE) |
DMA head descriptor table allocate macro To simplify user interface, this macro will help allocate descriptor memory, user just need to provide the name and the number for the allocate descriptor. More... | |
#define | DMA_ALLOCATE_HEAD_DESCRIPTORS_AT_NONCACHEABLE(name, number) AT_NONCACHEABLE_SECTION_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE) |
DMA head descriptor table allocate macro at noncacheable section To simplify user interface, this macro will help allocate descriptor memory at noncacheable section, user just need to provide the name and the number for the allocate descriptor. More... | |
#define | DMA_ALLOCATE_LINK_DESCRIPTORS(name, number) SDK_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE) |
DMA link descriptor table allocate macro To simplify user interface, this macro will help allocate descriptor memory, user just need to provide the name and the number for the allocate descriptor. More... | |
#define | DMA_ALLOCATE_LINK_DESCRIPTORS_AT_NONCACHEABLE(name, number) AT_NONCACHEABLE_SECTION_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE) |
DMA link descriptor table allocate macro at noncacheable section To simplify user interface, this macro will help allocate descriptor memory at noncacheable section, user just need to provide the name and the number for the allocate descriptor. More... | |
#define | DMA_ALLOCATE_DATA_TRANSFER_BUFFER(name, width) SDK_ALIGN(name, width) |
DMA transfer buffer address need to align with the transfer width. | |
#define | DMA_COMMON_REG_GET(base, channel, reg) (((volatile uint32_t *)(&((base)->COMMON[0].reg)))[DMA_CHANNEL_GROUP(channel)]) |
DMA linked descriptor address algin size. | |
#define | DMA_DESCRIPTOR_END_ADDRESS(start, inc, bytes, width) ((uint32_t *)((uint32_t)(start) + (inc) * (bytes) - (inc) * (width))) |
DMA descriptor end address calculate. More... | |
#define | DMA_CHANNEL_XFER(reload, clrTrig, intA, intB, width, srcInc, dstInc, bytes) |
DMA channel transfer configurations macro. More... | |
Typedefs | |
typedef void(* | dma_callback )(struct _dma_handle *handle, void *userData, bool transferDone, uint32_t intmode) |
Define Callback function for DMA. More... | |
Driver version | |
#define | FSL_DMA_DRIVER_VERSION (MAKE_VERSION(2, 4, 0)) |
DMA driver version. More... | |
DMA initialization and De-initialization | |
void | DMA_Init (DMA_Type *base) |
Initializes DMA peripheral. More... | |
void | DMA_Deinit (DMA_Type *base) |
Deinitializes DMA peripheral. More... | |
void | DMA_InstallDescriptorMemory (DMA_Type *base, void *addr) |
Install DMA descriptor memory. More... | |
DMA Channel Operation | |
static bool | DMA_ChannelIsActive (DMA_Type *base, uint32_t channel) |
Return whether DMA channel is processing transfer. More... | |
static bool | DMA_ChannelIsBusy (DMA_Type *base, uint32_t channel) |
Return whether DMA channel is busy. More... | |
static void | DMA_EnableChannelInterrupts (DMA_Type *base, uint32_t channel) |
Enables the interrupt source for the DMA transfer. More... | |
static void | DMA_DisableChannelInterrupts (DMA_Type *base, uint32_t channel) |
Disables the interrupt source for the DMA transfer. More... | |
static void | DMA_EnableChannel (DMA_Type *base, uint32_t channel) |
Enable DMA channel. More... | |
static void | DMA_DisableChannel (DMA_Type *base, uint32_t channel) |
Disable DMA channel. More... | |
static void | DMA_EnableChannelPeriphRq (DMA_Type *base, uint32_t channel) |
Set PERIPHREQEN of channel configuration register. More... | |
static void | DMA_DisableChannelPeriphRq (DMA_Type *base, uint32_t channel) |
Get PERIPHREQEN value of channel configuration register. More... | |
void | DMA_ConfigureChannelTrigger (DMA_Type *base, uint32_t channel, dma_channel_trigger_t *trigger) |
Set trigger settings of DMA channel. More... | |
void | DMA_SetChannelConfig (DMA_Type *base, uint32_t channel, dma_channel_trigger_t *trigger, bool isPeriph) |
set channel config. More... | |
uint32_t | DMA_GetRemainingBytes (DMA_Type *base, uint32_t channel) |
Gets the remaining bytes of the current DMA descriptor transfer. More... | |
static void | DMA_SetChannelPriority (DMA_Type *base, uint32_t channel, dma_priority_t priority) |
Set priority of channel configuration register. More... | |
static dma_priority_t | DMA_GetChannelPriority (DMA_Type *base, uint32_t channel) |
Get priority of channel configuration register. More... | |
static void | DMA_SetChannelConfigValid (DMA_Type *base, uint32_t channel) |
Set channel configuration valid. More... | |
static void | DMA_DoChannelSoftwareTrigger (DMA_Type *base, uint32_t channel) |
Do software trigger for the channel. More... | |
static void | DMA_LoadChannelTransferConfig (DMA_Type *base, uint32_t channel, uint32_t xfer) |
Load channel transfer configurations. More... | |
void | DMA_CreateDescriptor (dma_descriptor_t *desc, dma_xfercfg_t *xfercfg, void *srcAddr, void *dstAddr, void *nextDesc) |
Create application specific DMA descriptor to be used in a chain in transfer. More... | |
void | DMA_SetupDescriptor (dma_descriptor_t *desc, uint32_t xfercfg, void *srcStartAddr, void *dstStartAddr, void *nextDesc) |
setup dma descriptor More... | |
void | DMA_SetupChannelDescriptor (dma_descriptor_t *desc, uint32_t xfercfg, void *srcStartAddr, void *dstStartAddr, void *nextDesc, dma_burst_wrap_t wrapType, uint32_t burstSize) |
setup dma channel descriptor More... | |
void | DMA_LoadChannelDescriptor (DMA_Type *base, uint32_t channel, dma_descriptor_t *descriptor) |
load channel transfer decriptor. More... | |
DMA Transactional Operation | |
void | DMA_AbortTransfer (dma_handle_t *handle) |
Abort running transfer by handle. More... | |
void | DMA_CreateHandle (dma_handle_t *handle, DMA_Type *base, uint32_t channel) |
Creates the DMA handle. More... | |
void | DMA_SetCallback (dma_handle_t *handle, dma_callback callback, void *userData) |
Installs a callback function for the DMA transfer. More... | |
void | DMA_PrepareTransfer (dma_transfer_config_t *config, void *srcAddr, void *dstAddr, uint32_t byteWidth, uint32_t transferBytes, dma_transfer_type_t type, void *nextDesc) |
Prepares the DMA transfer structure. More... | |
void | DMA_PrepareChannelTransfer (dma_channel_config_t *config, void *srcStartAddr, void *dstStartAddr, uint32_t xferCfg, dma_transfer_type_t type, dma_channel_trigger_t *trigger, void *nextDesc) |
Prepare channel transfer configurations. More... | |
status_t | DMA_SubmitTransfer (dma_handle_t *handle, dma_transfer_config_t *config) |
Submits the DMA transfer request. More... | |
void | DMA_SubmitChannelTransferParameter (dma_handle_t *handle, uint32_t xfercfg, void *srcStartAddr, void *dstStartAddr, void *nextDesc) |
Submit channel transfer paramter directly. More... | |
void | DMA_SubmitChannelDescriptor (dma_handle_t *handle, dma_descriptor_t *descriptor) |
Submit channel descriptor. More... | |
status_t | DMA_SubmitChannelTransfer (dma_handle_t *handle, dma_channel_config_t *config) |
Submits the DMA channel transfer request. More... | |
void | DMA_StartTransfer (dma_handle_t *handle) |
DMA start transfer. More... | |
void | DMA_IRQHandle (DMA_Type *base) |
DMA IRQ handler for descriptor transfer complete. More... | |
The MCUXpresso SDK provides a peripheral driver for the Direct Memory Access (DMA) of MCUXpresso SDK devices.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dma
struct dma_descriptor_t |
Data Fields | |
volatile uint32_t | xfercfg |
Transfer configuration. | |
void * | srcEndAddr |
Last source address of DMA transfer. | |
void * | dstEndAddr |
Last destination address of DMA transfer. | |
void * | linkToNextDesc |
Address of next DMA descriptor in chain. | |
struct dma_xfercfg_t |
Data Fields | |
bool | valid |
Descriptor is ready to transfer. | |
bool | reload |
Reload channel configuration register after current descriptor is exhausted. | |
bool | swtrig |
Perform software trigger. More... | |
bool | clrtrig |
Clear trigger. | |
bool | intA |
Raises IRQ when transfer is done and set IRQA status register flag. | |
bool | intB |
Raises IRQ when transfer is done and set IRQB status register flag. | |
uint8_t | byteWidth |
Byte width of data to transfer. | |
uint8_t | srcInc |
Increment source address by 'srcInc' x 'byteWidth'. | |
uint8_t | dstInc |
Increment destination address by 'dstInc' x 'byteWidth'. | |
uint16_t | transferCount |
Number of transfers. | |
bool dma_xfercfg_t::swtrig |
Transfer if fired when 'valid' is set
struct dma_channel_trigger_t |
Data Fields | |
dma_trigger_type_t | type |
Select hardware trigger as edge triggered or level triggered. More... | |
dma_trigger_burst_t | burst |
Select whether hardware triggers cause a single or burst transfer. More... | |
dma_burst_wrap_t | wrap |
Select wrap type, source wrap or dest wrap, or both. More... | |
dma_trigger_type_t dma_channel_trigger_t::type |
dma_trigger_burst_t dma_channel_trigger_t::burst |
dma_burst_wrap_t dma_channel_trigger_t::wrap |
struct dma_channel_config_t |
Data Fields | |
void * | srcStartAddr |
Source data address. | |
void * | dstStartAddr |
Destination data address. | |
void * | nextDesc |
Chain custom descriptor. | |
uint32_t | xferCfg |
channel transfer configurations | |
dma_channel_trigger_t * | trigger |
DMA trigger type. | |
bool | isPeriph |
select the request type | |
struct dma_transfer_config_t |
struct dma_handle_t |
Data Fields | |
dma_callback | callback |
Callback function. More... | |
void * | userData |
Callback function parameter. | |
DMA_Type * | base |
DMA peripheral base address. | |
uint8_t | channel |
DMA channel number. | |
dma_callback dma_handle_t::callback |
Invoked when transfer of descriptor with interrupt flag finishes
#define FSL_DMA_DRIVER_VERSION (MAKE_VERSION(2, 4, 0)) |
Version 2.4.0.
#define FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE (16U) |
DMA head link descriptor table align size
#define DMA_ALLOCATE_HEAD_DESCRIPTORS | ( | name, | |
number | |||
) | SDK_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE) |
name,allocate | decriptor name. |
number,number | of descriptor to be allocated. |
#define DMA_ALLOCATE_HEAD_DESCRIPTORS_AT_NONCACHEABLE | ( | name, | |
number | |||
) | AT_NONCACHEABLE_SECTION_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_DESCRIPTOR_ALIGN_SIZE) |
name,allocate | decriptor name. |
number,number | of descriptor to be allocated. |
#define DMA_ALLOCATE_LINK_DESCRIPTORS | ( | name, | |
number | |||
) | SDK_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE) |
name,allocate | decriptor name. |
number,number | of descriptor to be allocated. |
#define DMA_ALLOCATE_LINK_DESCRIPTORS_AT_NONCACHEABLE | ( | name, | |
number | |||
) | AT_NONCACHEABLE_SECTION_ALIGN(dma_descriptor_t name[number], FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE) |
name,allocate | decriptor name. |
number,number | of descriptor to be allocated. |
#define DMA_DESCRIPTOR_END_ADDRESS | ( | start, | |
inc, | |||
bytes, | |||
width | |||
) | ((uint32_t *)((uint32_t)(start) + (inc) * (bytes) - (inc) * (width))) |
start,start | address |
inc,address | interleave size |
bytes,transfer | bytes |
width,transfer | width |
#define DMA_CHANNEL_XFER | ( | reload, | |
clrTrig, | |||
intA, | |||
intB, | |||
width, | |||
srcInc, | |||
dstInc, | |||
bytes | |||
) |
reload,true | is reload link descriptor after current exhaust, false is not |
clrTrig,true | is clear trigger status, wait software trigger, false is not |
intA,enable | interruptA |
intB,enable | interruptB |
width,transfer | width |
srcInc,source | address interleave size |
dstInc,destination | address interleave size |
bytes,transfer | bytes |
typedef void(* dma_callback)(struct _dma_handle *handle, void *userData, bool transferDone, uint32_t intmode) |
anonymous enum |
anonymous enum |
enum dma_priority_t |
enum dma_irq_t |
enum dma_trigger_type_t |
anonymous enum |
enum dma_trigger_burst_t |
enum dma_burst_wrap_t |
enum dma_transfer_type_t |
void DMA_Init | ( | DMA_Type * | base | ) |
This function enable the DMA clock, set descriptor table and enable DMA peripheral.
base | DMA peripheral base address. |
void DMA_Deinit | ( | DMA_Type * | base | ) |
This function gates the DMA clock.
base | DMA peripheral base address. |
void DMA_InstallDescriptorMemory | ( | DMA_Type * | base, |
void * | addr | ||
) |
This function used to register DMA descriptor memory for linked transfer, a typical case is ping pong transfer which will request more than one DMA descriptor memory space, althrough current DMA driver has a default DMA descriptor buffer, but it support one DMA descriptor for one channel only.
base | DMA base address. |
addr | DMA descriptor address |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
void DMA_ConfigureChannelTrigger | ( | DMA_Type * | base, |
uint32_t | channel, | ||
dma_channel_trigger_t * | trigger | ||
) |
base | DMA peripheral base address. |
channel | DMA channel number. |
trigger | trigger configuration. |
void DMA_SetChannelConfig | ( | DMA_Type * | base, |
uint32_t | channel, | ||
dma_channel_trigger_t * | trigger, | ||
bool | isPeriph | ||
) |
This function provide a interface to configure channel configuration reisters.
base | DMA base address. |
channel | DMA channel number. |
trigger | channel configurations structure. |
isPeriph | true is periph request, false is not. |
uint32_t DMA_GetRemainingBytes | ( | DMA_Type * | base, |
uint32_t | channel | ||
) |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
priority | Channel priority value. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
|
inlinestatic |
base | DMA peripheral base address. |
channel | DMA channel number. |
xfer | transfer configurations. |
void DMA_CreateDescriptor | ( | dma_descriptor_t * | desc, |
dma_xfercfg_t * | xfercfg, | ||
void * | srcAddr, | ||
void * | dstAddr, | ||
void * | nextDesc | ||
) |
desc | DMA descriptor address. |
xfercfg | Transfer configuration for DMA descriptor. |
srcAddr | Address of last item to transmit |
dstAddr | Address of last item to receive. |
nextDesc | Address of next descriptor in chain. |
void DMA_SetupDescriptor | ( | dma_descriptor_t * | desc, |
uint32_t | xfercfg, | ||
void * | srcStartAddr, | ||
void * | dstStartAddr, | ||
void * | nextDesc | ||
) |
Note: This function do not support configure wrap descriptor.
desc | DMA descriptor address. |
xfercfg | Transfer configuration for DMA descriptor. |
srcStartAddr | Start address of source address. |
dstStartAddr | Start address of destination address. |
nextDesc | Address of next descriptor in chain. |
void DMA_SetupChannelDescriptor | ( | dma_descriptor_t * | desc, |
uint32_t | xfercfg, | ||
void * | srcStartAddr, | ||
void * | dstStartAddr, | ||
void * | nextDesc, | ||
dma_burst_wrap_t | wrapType, | ||
uint32_t | burstSize | ||
) |
Note: This function support configure wrap descriptor.
desc | DMA descriptor address. |
xfercfg | Transfer configuration for DMA descriptor. |
srcStartAddr | Start address of source address. |
dstStartAddr | Start address of destination address. |
nextDesc | Address of next descriptor in chain. |
wrapType | burst wrap type. |
burstSize | burst size, reference _dma_burst_size. |
void DMA_LoadChannelDescriptor | ( | DMA_Type * | base, |
uint32_t | channel, | ||
dma_descriptor_t * | descriptor | ||
) |
This function can be used to load desscriptor to driver internal channel descriptor that is used to start DMA transfer, the head descriptor table is defined in DMA driver, it is useful for the case:
base | DMA base address. |
channel | DMA channel. |
descriptor | configured DMA descriptor. |
void DMA_AbortTransfer | ( | dma_handle_t * | handle | ) |
This function aborts DMA transfer specified by handle.
handle | DMA handle pointer. |
void DMA_CreateHandle | ( | dma_handle_t * | handle, |
DMA_Type * | base, | ||
uint32_t | channel | ||
) |
This function is called if using transaction API for DMA. This function initializes the internal state of DMA handle.
handle | DMA handle pointer. The DMA handle stores callback function and parameters. |
base | DMA peripheral base address. |
channel | DMA channel number. |
void DMA_SetCallback | ( | dma_handle_t * | handle, |
dma_callback | callback, | ||
void * | userData | ||
) |
This callback is called in DMA IRQ handler. Use the callback to do something after the current major loop transfer completes.
handle | DMA handle pointer. |
callback | DMA callback function pointer. |
userData | Parameter for callback function. |
void DMA_PrepareTransfer | ( | dma_transfer_config_t * | config, |
void * | srcAddr, | ||
void * | dstAddr, | ||
uint32_t | byteWidth, | ||
uint32_t | transferBytes, | ||
dma_transfer_type_t | type, | ||
void * | nextDesc | ||
) |
config | The user configuration structure of type dma_transfer_t. |
srcAddr | DMA transfer source address. |
dstAddr | DMA transfer destination address. |
byteWidth | DMA transfer destination address width(bytes). |
transferBytes | DMA transfer bytes to be transferred. |
type | DMA transfer type. |
nextDesc | Chain custom descriptor to transfer. |
void DMA_PrepareChannelTransfer | ( | dma_channel_config_t * | config, |
void * | srcStartAddr, | ||
void * | dstStartAddr, | ||
uint32_t | xferCfg, | ||
dma_transfer_type_t | type, | ||
dma_channel_trigger_t * | trigger, | ||
void * | nextDesc | ||
) |
This function used to prepare channel transfer configurations.
config | Pointer to DMA channel transfer configuration structure. |
srcStartAddr | source start address. |
dstStartAddr | destination start address. |
xferCfg | xfer configuration, user can reference DMA_CHANNEL_XFER about to how to get xferCfg value. |
type | transfer type. |
trigger | DMA channel trigger configurations. |
nextDesc | address of next descriptor. |
status_t DMA_SubmitTransfer | ( | dma_handle_t * | handle, |
dma_transfer_config_t * | config | ||
) |
This function submits the DMA 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.
handle | DMA handle pointer. |
config | Pointer to DMA transfer configuration structure. |
kStatus_DMA_Success | It means submit transfer request succeed. |
kStatus_DMA_QueueFull | It means TCD queue is full. Submit transfer request is not allowed. |
kStatus_DMA_Busy | It means the given channel is busy, need to submit request later. |
void DMA_SubmitChannelTransferParameter | ( | dma_handle_t * | handle, |
uint32_t | xfercfg, | ||
void * | srcStartAddr, | ||
void * | dstStartAddr, | ||
void * | nextDesc | ||
) |
This function used to configue channel head descriptor that is used to start DMA transfer, the head descriptor table is defined in DMA driver, it is useful for the case:
handle | Pointer to DMA handle. |
xferCfg | xfer configuration, user can reference DMA_CHANNEL_XFER about to how to get xferCfg value. |
srcStartAddr | source start address. |
dstStartAddr | destination start address. |
nextDesc | address of next descriptor. |
void DMA_SubmitChannelDescriptor | ( | dma_handle_t * | handle, |
dma_descriptor_t * | descriptor | ||
) |
This function used to configue channel head descriptor that is used to start DMA transfer, the head descriptor table is defined in DMA driver, this functiono is typical for the ping pong case:
handle | Pointer to DMA handle. |
descriptor | descriptor to submit. |
status_t DMA_SubmitChannelTransfer | ( | dma_handle_t * | handle, |
dma_channel_config_t * | config | ||
) |
This function submits the DMA 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. It is used for the case:
handle | DMA handle pointer. |
config | Pointer to DMA transfer configuration structure. |
kStatus_DMA_Success | It means submit transfer request succeed. |
kStatus_DMA_QueueFull | It means TCD queue is full. Submit transfer request is not allowed. |
kStatus_DMA_Busy | It means the given channel is busy, need to submit request later. |
void DMA_StartTransfer | ( | dma_handle_t * | handle | ) |
This function enables the channel request. User can call this function after submitting the transfer request It will trigger transfer start with software trigger only when hardware trigger is not used.
handle | DMA handle pointer. |
void DMA_IRQHandle | ( | DMA_Type * | base | ) |
This function clears the channel major interrupt flag and call the callback function if it is not NULL.
base | DMA base address. |