MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
GDMA: General DMA(GDMA) Driver

Overview

The MCUXpresso SDK provides a driver for the GDMA.

GDMA driver provides two types of APIs:

The first type is functional APIs, or the basic channel operation APIs. Such as GDMA_SetChannelSourceAddress, GDMA_StartChannel. Generally, functional APIs use the GDMA_Type *base as parameter. They are simple basic function blocks and does not handle the interrupts. Application should implement the ISR if only functional APIs used.

The second type is transactional APIs. Such as GDMA_SubmitTransfer. Generally these APIs uses the parameter gdma_handle_t. Transactional APIs handles the interrupts, user could get the interrupt status by registering callback.

The functional APIs and transactional APIs are very similar to each other, please refer the driver examples.

Data Structures

struct  gdma_channel_xfer_config_t
 GDMA channel transfer configuration. More...
 
struct  gdma_handle_t
 GDMA transfer handle structure. More...
 

Macros

#define GDMA_DESC_LLI(linkListAddr, stopAfterDescFinished, enableDescInterrupt)
 Macro for GDMA link list descriptor LLI. More...
 

Typedefs

typedef void(* gdma_callback_t )(struct _gdma_handle *handle, void *userData, uint32_t interrupts)
 Define Callback function for GDMA. More...
 

Enumerations

enum  gdma_transfer_width_t {
  kGDMA_TransferWidth1Byte = 1U,
  kGDMA_TransferWidth2Byte = 2U,
  kGDMA_TransferWidth4Byte = 3U
}
 GDMA transfer width. More...
 
enum  gdma_burst_size_t {
  kGDMA_BurstSize1 = 0U,
  kGDMA_BurstSize4 = 1U,
  kGDMA_BurstSize8 = 2U,
  kGDMA_BurstSize16 = 3U,
  kGDMA_BurstSizeWrap4 = 5U,
  kGDMA_BurstSizeWrap8 = 6U,
  kGDMA_BurstSizeWrap16 = 7U
}
 GDMA burst size. More...
 
enum  _gdma_ahb_prot {
  kGDMA_ProtUserMode = (0U << 0U),
  kGDMA_ProtPrevilegedMode = (1U << 0U),
  kGDMA_ProtUnbufferable = (0U << 1U),
  kGDMA_ProtBufferable = (1U << 1U),
  kGDMA_ProtUncacheable = (0U << 2U),
  kGDMA_ProtCacheable = (1U << 2U)
}
 GDMA AHB HPROT flags. More...
 
enum  gdma_priority_t {
  kGDMA_ChannelPriority0 = 0,
  kGDMA_ChannelPriority1,
  kGDMA_ChannelPriority2,
  kGDMA_ChannelPriority3,
  kGDMA_ChannelPriority4,
  kGDMA_ChannelPriority5,
  kGDMA_ChannelPriority6,
  kGDMA_ChannelPriority7,
  kGDMA_ChannelPriority8,
  kGDMA_ChannelPriority9,
  kGDMA_ChannelPriority10,
  kGDMA_ChannelPriority11,
  kGDMA_ChannelPriority12,
  kGDMA_ChannelPriority13,
  kGDMA_ChannelPriority14,
  kGDMA_ChannelPriority15
}
 GDMA channel priority. More...
 
enum  _gdma_interrupt_enable {
  kGDMA_DescriptorTransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_DESC_TFRINT_MASK,
  kGDMA_AddressErrorInterruptEnable = GDMA_CHNL_INT_MASK_ADDRERRINT_MASK,
  kGDMA_BusErrorInterruptEnable = GDMA_CHNL_INT_MASK_BUSERRINT_MASK,
  kGDMA_TransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_TFRINT_MASK,
  kGDMA_BlockTransferDoneInterruptEnable = GDMA_CHNL_INT_MASK_BLOCKINT_MASK,
  kGDMA_AllInterruptEnable
}
 GDMA interrupts to enable. More...
 
enum  _gdma_interrupt_flags {
  kGDMA_DescriptorTransferDoneFlag = GDMA_CHNL_INT_DESC_STATUS_TFRINT_MASK,
  kGDMA_ChannelInterruptFlag = GDMA_CHNL_INT_STATUS_CHLINT_MASK,
  kGDMA_AddressErrorFlag = GDMA_CHNL_INT_STATUS_ADDRERRINT_MASK,
  kGDMA_BusErrorFlag = GDMA_CHNL_INT_STATUS_BUSERRINT_MASK,
  kGDMA_TransferDoneFlag = GDMA_CHNL_INT_STATUS_TFRINT_MASK,
  kGDMA_BlockTransferDoneFlag = GDMA_CHNL_INT_STATUS_BLOCKINT_MASK,
  kGDMA_AllInterruptFlag
}
 GDMA interrupt status flags. More...
 

Functions

struct __ALIGNED (16) _gdma_descriptor
 GDMA channel link list descriptor structure. More...
 

Driver version

#define FSL_GDMA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))
 

GDMA initialization and De-initialization

void GDMA_Init (GDMA_Type *base)
 Initializes GDMA peripheral. More...
 
void GDMA_Deinit (GDMA_Type *base)
 Deinitializes GDMA peripheral. More...
 

GDMA Channel Operation

static void GDMA_SetChannelSourceAddress (GDMA_Type *base, uint8_t channel, uint32_t addr)
 Set GDMA channel source address. More...
 
static void GDMA_SetChannelDestAddress (GDMA_Type *base, uint8_t channel, uint32_t addr)
 Set GDMA channel destination address. More...
 
static void GDMA_StartChannel (GDMA_Type *base, uint8_t channel)
 Start GDMA channel to work. More...
 
static void GDMA_StopChannel (GDMA_Type *base, uint8_t channel)
 Stop GDMA channel. More...
 
static bool GDMA_IsChannelBusy (GDMA_Type *base, uint8_t channel)
 Return whether GDMA channel is processing transfer. More...
 
static void GDMA_EnableChannelInterrupts (GDMA_Type *base, uint8_t channel, uint32_t interrupts)
 Enables the interrupt for the GDMA transfer. More...
 
static void GDMA_DisableChannelInterrupts (GDMA_Type *base, uint8_t channel, uint32_t interrupts)
 Disables the interrupt for the GDMA transfer. More...
 
static uint32_t GDMA_GetChannelInterruptFlags (GDMA_Type *base, uint8_t channel)
 Get the GDMA channel interrupt flags. More...
 
static void GDMA_ClearChannelInterruptFlags (GDMA_Type *base, uint8_t channel, uint32_t flags)
 Clear the GDMA channel interrupt flags. More...
 
static uint32_t GDMA_GetChannelFinishedDescriptorNumber (GDMA_Type *base, uint8_t channel)
 Get the number of finished descriptor. More...
 
static void GDMA_ClearChannelFinishedDescriptorNumber (GDMA_Type *base, uint8_t channel)
 Clear the number of finished descriptor. More...
 
static void GDMA_SetChannelPriority (GDMA_Type *base, uint8_t channel, gdma_priority_t priority)
 Set priority of channel. More...
 
status_t GDMA_SetChannelTransferConfig (GDMA_Type *base, uint8_t channel, const gdma_channel_xfer_config_t *config)
 Set channel transfer configuration. More...
 

GDMA Transactional Operation

void GDMA_CreateHandle (gdma_handle_t *handle, GDMA_Type *base, uint8_t channel)
 Creates the GDMA handle. More...
 
void GDMA_SetCallback (gdma_handle_t *handle, gdma_callback_t callback, void *userData)
 Installs a callback function for the GDMA transfer. More...
 
status_t GDMA_SubmitTransfer (gdma_handle_t *handle, gdma_channel_xfer_config_t *config)
 Submits the GDMA channel transfer request. More...
 
void GDMA_StartTransfer (gdma_handle_t *handle)
 GDMA start transfer. More...
 
void GDMA_AbortTransfer (gdma_handle_t *handle)
 Abort running transfer by handle. More...
 
void GDMA_IRQHandle (GDMA_Type *base)
 GDMA IRQ handler. More...
 

Data Structure Documentation

struct gdma_channel_xfer_config_t
Note
The transfer configuration must follow the requirements:
  • SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
  • If wrap not used, the address should align with WIDTH
  • If wrap used, the address should align with WIDTH * BURST_SIZE.

Data Fields

uint32_t srcAddr
 Source data address.
 
uint32_t destAddr
 Destination data address.
 
uint8_t ahbProt
 GDMA AHB HPROT flags, it could be OR'ed value of _gdma_ahb_prot. More...
 
gdma_burst_size_t srcBurstSize
 Source address burst size. More...
 
gdma_burst_size_t destBurstSize
 Destination address burst size. More...
 
gdma_transfer_width_t srcWidth
 Source transfer width. More...
 
gdma_transfer_width_t destWidth
 Destination transfer width. More...
 
bool srcAddrInc
 Increase source address on each successive access. More...
 
bool destAddrInc
 Increase destination address on each successive access. More...
 
uint16_t transferLen
 Transfer length in bytes, max value is 8 * 1024 - 1, should align with transfer size. More...
 
bool enableLinkList
 Enable link list or not. More...
 
bool enableDescInterrupt
 Generate interrupt when descriptor transfer finished, only used when enableLinkList is true. More...
 
bool stopAfterDescFinished
 Stop channel when descriptor transfer finished, only used when enableLinkList is true. More...
 
uint32_t linkListAddr
 Link list address, only used when enableLinkList is true. More...
 

Field Documentation

uint8_t gdma_channel_xfer_config_t::ahbProt
gdma_burst_size_t gdma_channel_xfer_config_t::srcBurstSize
gdma_burst_size_t gdma_channel_xfer_config_t::destBurstSize
gdma_transfer_width_t gdma_channel_xfer_config_t::srcWidth
gdma_transfer_width_t gdma_channel_xfer_config_t::destWidth
bool gdma_channel_xfer_config_t::srcAddrInc
bool gdma_channel_xfer_config_t::destAddrInc
uint16_t gdma_channel_xfer_config_t::transferLen
bool gdma_channel_xfer_config_t::enableLinkList
bool gdma_channel_xfer_config_t::enableDescInterrupt
bool gdma_channel_xfer_config_t::stopAfterDescFinished
uint32_t gdma_channel_xfer_config_t::linkListAddr
struct gdma_handle_t

Data Fields

GDMA_Type * gdma
 GDMA peripheral base address.
 
uint8_t channel
 GDMA channel number.
 
gdma_callback_t callback
 Callback function. More...
 
void * userData
 Callback function parameter.
 

Field Documentation

gdma_callback_t gdma_handle_t::callback

Invoked interrupt happens.

Macro Definition Documentation

#define GDMA_DESC_LLI (   linkListAddr,
  stopAfterDescFinished,
  enableDescInterrupt 
)
Value:
(((uint32_t)(linkListAddr)&GDMA_LLI_LLI_MASK) | ((enableDescInterrupt) ? GDMA_LLI_DESC_INT_EN_MASK : 0UL) | \
((stopAfterDescFinished) ? GDMA_LLI_STOP_MASK : 0UL))

This macro constructs gdma_descriptor_t::lli.

Parameters
linkListAddrAddress of next link list descriptor item.
stopAfterDescFinishedStop or not after this descriptor transfer done.
enableDescInterruptGenerate interrupt after this descriptor transfer done.

Typedef Documentation

typedef void(* gdma_callback_t)(struct _gdma_handle *handle, void *userData, uint32_t interrupts)

handle: Pointer to the GDMA driver handle. userData: The userData registered using GDMA_SetCallback. interrupts: The interrupts flags of the specific channel.

Enumeration Type Documentation

Enumerator
kGDMA_TransferWidth1Byte 

1 byte.

kGDMA_TransferWidth2Byte 

2 bytes.

kGDMA_TransferWidth4Byte 

4 bytes.

Enumerator
kGDMA_BurstSize1 

Burst 1.

kGDMA_BurstSize4 

Burst 4.

kGDMA_BurstSize8 

Burst 8.

kGDMA_BurstSize16 

Burst 16.

kGDMA_BurstSizeWrap4 

Wrap 4.

kGDMA_BurstSizeWrap8 

Wrap 8.

kGDMA_BurstSizeWrap16 

Wrap 16.

Enumerator
kGDMA_ProtUserMode 

The access is in user mode.

kGDMA_ProtPrevilegedMode 

The access is in previleged mode.

kGDMA_ProtUnbufferable 

The access is not bufferable.

kGDMA_ProtBufferable 

The access is bufferable.

kGDMA_ProtUncacheable 

The access is not cacheable.

kGDMA_ProtCacheable 

The access is cacheable.

Enumerator
kGDMA_ChannelPriority0 

Lowest channel priority - priority 0.

kGDMA_ChannelPriority1 

Channel priority 1.

kGDMA_ChannelPriority2 

Channel priority 2.

kGDMA_ChannelPriority3 

Channel priority 3.

kGDMA_ChannelPriority4 

Channel priority 4.

kGDMA_ChannelPriority5 

Channel priority 5.

kGDMA_ChannelPriority6 

Channel priority 6.

kGDMA_ChannelPriority7 

Channel priority 7.

kGDMA_ChannelPriority8 

Channel priority 8.

kGDMA_ChannelPriority9 

Channel priority 9.

kGDMA_ChannelPriority10 

Channel priority 10.

kGDMA_ChannelPriority11 

Channel priority 11.

kGDMA_ChannelPriority12 

Channel priority 12.

kGDMA_ChannelPriority13 

Channel priority 13.

kGDMA_ChannelPriority14 

Channel priority 14.

kGDMA_ChannelPriority15 

Highest channel priority - priority 15.

Enumerator
kGDMA_DescriptorTransferDoneInterruptEnable 

Descriptor transfer done interrupt.

This happens when the descriptor is configured to generate interrupt when transfer done.

kGDMA_AddressErrorInterruptEnable 

Channel source or destination address is not aligned to corresponding transfer width.

kGDMA_BusErrorInterruptEnable 

AHB bus interrupt.

kGDMA_TransferDoneInterruptEnable 

DMA transfer done interrupt.

kGDMA_BlockTransferDoneInterruptEnable 

DMA block single/burst transfer done interrupt.

kGDMA_AllInterruptEnable 

All interrupt enable.

Enumerator
kGDMA_DescriptorTransferDoneFlag 

Descriptor transfer done interrupt.

This happens when the descriptor is configured to generate interrupt when transfer done.

kGDMA_ChannelInterruptFlag 

OR of the content of the respective unmasked interrupt of channel.

kGDMA_AddressErrorFlag 

Channel source or destination address is not aligned to corresponding transfer width.

kGDMA_BusErrorFlag 

AHB bus interrupt.

kGDMA_TransferDoneFlag 

DMA transfer done interrupt.

kGDMA_BlockTransferDoneFlag 

DMA block single/burst transfer done interrupt.

kGDMA_AllInterruptFlag 

All interrupt flags.

Function Documentation

struct __ALIGNED ( 16  )

< Source address.

< Destination address.

< Link list item.

< Transfer control.

void GDMA_Init ( GDMA_Type *  base)

It ungates the GDMA access clock, after this function, the GDMA module is ready to be used.

Parameters
baseGDMA peripheral base address.
void GDMA_Deinit ( GDMA_Type *  base)
Parameters
baseGDMA peripheral base address.
static void GDMA_SetChannelSourceAddress ( GDMA_Type *  base,
uint8_t  channel,
uint32_t  addr 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
addrSource address.
static void GDMA_SetChannelDestAddress ( GDMA_Type *  base,
uint8_t  channel,
uint32_t  addr 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
addrDestination address.
static void GDMA_StartChannel ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
static void GDMA_StopChannel ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
static bool GDMA_IsChannelBusy ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic

When GDMA_StopChannel is called, if the channel is on service, it does not stop immediately, application could call this API to check whether the channel is stopped.

Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
Returns
True if the channel is busy, false if not.
static void GDMA_EnableChannelInterrupts ( GDMA_Type *  base,
uint8_t  channel,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
interruptsThe interrupts to enable, it is OR'ed value of _gdma_interrupt_enable.
static void GDMA_DisableChannelInterrupts ( GDMA_Type *  base,
uint8_t  channel,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
interruptsThe interrupts to disable, it is OR'ed value of _gdma_interrupt_enable.
static uint32_t GDMA_GetChannelInterruptFlags ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
Returns
The interrupt flags, it is OR'ed value of _gdma_interrupt_flags.
static void GDMA_ClearChannelInterruptFlags ( GDMA_Type *  base,
uint8_t  channel,
uint32_t  flags 
)
inlinestatic

The kGDMA_ChannelInterruptFlag is OR'ed status of all other unmasked interrupt flags, it could not be clear directly, it should be cleared by clear all other flags.

Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
flagsThe interrupt flags to clear, it is OR'ed value of _gdma_interrupt_flags.
static uint32_t GDMA_GetChannelFinishedDescriptorNumber ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic

The counter increases when an item of descriptor is done in linklist mode.

Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
Returns
Number of finished descriptor.
static void GDMA_ClearChannelFinishedDescriptorNumber ( GDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
static void GDMA_SetChannelPriority ( GDMA_Type *  base,
uint8_t  channel,
gdma_priority_t  priority 
)
inlinestatic
Parameters
baseGDMA peripheral base address.
channelGDMA channel number.
priorityChannel priority value.
status_t GDMA_SetChannelTransferConfig ( GDMA_Type *  base,
uint8_t  channel,
const gdma_channel_xfer_config_t config 
)

This function configures the channel transfer, after configured, GDMA_StartChannel could be called to start the transfer.

This function must be called when previous transfer finished. Application can use GDMA_IsChannelBusy to check whether the channel has finished the previous work.

Note
The transfer configuration must follow the requirements:
  • SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
  • If wrap not used, the address should align with WIDTH
  • If wrap used, the address should align with WIDTH * BURST_SIZE.
Parameters
baseGDMA base address.
channelGDMA channel number. Pointer to the transfer configuration.
Return values
kStatus_FailGDMA is busy with previous transfer.
kStatus_SuccessConfiguration set successfully.
kStatus_InvalidArgumentConfiguration wrong.
void GDMA_CreateHandle ( gdma_handle_t handle,
GDMA_Type *  base,
uint8_t  channel 
)

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

Parameters
handleGDMA handle pointer. It stores callback function and parameters.
baseGDMA peripheral base address.
channelGDMA channel number.
void GDMA_SetCallback ( gdma_handle_t handle,
gdma_callback_t  callback,
void *  userData 
)

This callback is called in GDMA IRQ handler to inform user the interrupt status.

Parameters
handleGDMA handle pointer.
callbackGDMA callback function pointer.
userDataParameter for callback function.
status_t GDMA_SubmitTransfer ( gdma_handle_t handle,
gdma_channel_xfer_config_t config 
)

After this function, user could call GDMA_StartTransfer to start GDMA transfer.

This function must be called when previous transfer finished. Application can use GDMA_IsChannelBusy to check whether the channel has finished the previous work.

Note
The transfer configuration must follow the requirements:
  • SRCBSIZE * SRCWIDTH == DESTBSIZE * DESTWIDTH
  • If wrap not used, the address should align with WIDTH
  • If wrap used, the address should align with WIDTH * BURST_SIZE.
Parameters
handleGDMA handle pointer.
configPointer to GDMA transfer configuration structure.
Return values
kStatus_FailGDMA is busy with previous transfer.
kStatus_SuccessConfiguration set successfully.
kStatus_InvalidArgumentConfiguration wrong.
void GDMA_StartTransfer ( gdma_handle_t handle)

User can call this function after GDMA_SubmitTransfer.

Parameters
handleGDMA handle pointer.
void GDMA_AbortTransfer ( gdma_handle_t handle)

When this function is called, if the channel is on service, it only stops when service finished.

Parameters
handleGDMA handle pointer.
void GDMA_IRQHandle ( GDMA_Type *  base)

This function checks all GDMA channel interrupts and inform application the interrupt flags through user registered callback.

Parameters
baseGDMA peripheral.