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

Overview

The MCUXpresso SDK provides a driver for the GPDMA.

GPDMA driver provides two types of APIs:

The first type is functional APIs, or the basic channel operation APIs. Such as GPDMA_SetTransferConfig, GPDMA_EnableChannel. Generally, functional APIs use the GPDMA_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 GPDMA_SubmitTransfer. Generally these APIs uses the parameter gpdma_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  gpdma_transfer_config_t
 GPDMA structure using for GPDMA configuration. More...
 
struct  gpdma_descriptor_t
 Transfer Descriptor structure typedef. More...
 
struct  gpdma_handle_t
 GPDMA transfer handle structure. More...
 

Typedefs

typedef void(* gpdma_callback )(struct _gpdma_handle *handle, void *userData, uint32_t status)
 Define callback function for GPDMA. More...
 

Enumerations

enum  gpdma_status_clear_t {
  kGPDMA_StatusClearInterruptTerminalCountRequest = 0x0,
  kGPDMA_StatusClearInterruptError
}
 GPDMA Interrupt Clear Status. More...
 
enum  gpdma_status_t {
  kGPDMA_StatusInterrupt = 0x0,
  kGPDMA_StatusInterruptTerminalCountRequest,
  kGPDMA_StatusInterruptError,
  kGPDMA_StatusRawInterruptTerminalCount,
  kGPDMA_StatusRawErrorInterrupt,
  kGPDMA_StatusEnabledChannel
}
 GPDMA Type of Status. More...
 
enum  gpdma_transfer_type_t {
  kGPDMA_TransferM2MControllerDma = 0UL,
  kGPDMA_TransferM2PControllerDma = 1UL,
  kGPDMA_TransferP2MControllerDma = 2UL,
  kGPDMA_TransferP2PControllerDma = 3UL,
  kGPDMA_TransferP2PControllerDestPeripheral = 4UL,
  kGPDMA_TransferM2PControllerPeripheral = 5UL,
  kGPDMA_TransferP2MControllerPeripheral = 6UL,
  kGPDMA_TransferP2PControllerSrcPeripheral = 7UL
}
 GPDMA transfer type. More...
 
enum  gpdma_transfer_width_t {
  kGPDMA_TransferWidth1Bytes = 0U,
  kGPDMA_TransferWidth2Bytes = 1U,
  kGPDMA_TransferWidth4Bytes = 2U
}
 GPDMA transfer width configuration. More...
 
enum  gpdma_burst_size_t {
  kGPDMA_BurstSize1 = 0U,
  kGPDMA_BurstSize4 = 1U,
  kGPDMA_BurstSize8 = 2U,
  kGPDMA_BurstSize16 = 3U,
  kGPDMA_BurstSize32 = 4U,
  kGPDMA_BurstSize64 = 5U,
  kGPDMA_BurstSize128 = 6U,
  kGPDMA_BurstSize256 = 7U
}
 GPDMA transfer configuration. More...
 

Driver version

#define FSL_GPDMA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 GPDMA driver version. More...
 

GPDMA initialization and de-initialization

status_t GPDMA_Init (GPDMA_Type *base)
 Initializes the GPDMA peripheral. More...
 
void GPDMA_Deinit (GPDMA_Type *base)
 Deinitializes the GPDMA peripheral. More...
 

GPDMA Channel Transfer Operation

static void GPDMA_EnableChannelInterrupts (GPDMA_Type *base, uint8_t channel)
 Enables the interrupt source for the GPDMA transfer. More...
 
static void GPDMA_DisableChannelInterrupts (GPDMA_Type *base, uint8_t channel)
 Disables the interrupt source for the GPDMA transfer. More...
 
static void GPDMA_SetChannelSourcePeripheral (GPDMA_Type *base, uint8_t channel, gpdma_request_source_t srcPeripheral)
 Set the GPDMA request source peripheral. More...
 
static void GPDMA_SetChannelDestinationPeripheral (GPDMA_Type *base, uint8_t channel, gpdma_request_source_t destPeripheral)
 Set the GPDMA request destination peripheral. More...
 
void GPDMA_EnableChannel (GPDMA_Type *base, uint8_t channel, bool enable)
 Enable or Disable the GPDMA Channel. More...
 
void GPDMA_StopChannel (GPDMA_Type *base, uint8_t channel)
 Stop a stream GPDMA transfer. More...
 
status_t GPDMA_CheckChannelInterrupts (GPDMA_Type *base, uint8_t channel)
 The GPDMA stream interrupt status checking. More...
 
bool GPDMA_GetChannelStatus (GPDMA_Type *base, uint8_t channel, gpdma_status_t flag)
 Read the status from different registers according to the flag. More...
 
void GPDMA_ClearChannelStatus (GPDMA_Type *base, uint8_t channel, gpdma_status_clear_t flag)
 Clear the Interrupt status from different registers according to the flag. More...
 
status_t GPDMA_PrepareDescriptor (gpdma_descriptor_t *descriptor, void *srcAddr, gpdma_burst_size_t srcBurstSize, gpdma_transfer_width_t srcTransferWidth, void *destAddr, gpdma_burst_size_t destBurstSize, gpdma_transfer_width_t destTransferWidth, uint32_t totalBytes, gpdma_transfer_type_t transferType, uint32_t linkListItem)
 Prepares the GPDMA transfer descriptor. More...
 
void GPDMA_PrepareTransferConfig (gpdma_transfer_config_t *config, void *srcAddr, gpdma_burst_size_t srcBurstSize, gpdma_transfer_width_t srcTransferWidth, void *destAddr, gpdma_burst_size_t destBurstSize, gpdma_transfer_width_t destTransferWidth, uint32_t totalBytes, gpdma_transfer_type_t transferType, uint32_t linkListItem)
 Prepares the GPDMA transfer structure configurations. More...
 
status_t GPDMA_SetTransferConfig (GPDMA_Type *base, uint8_t channel, const gpdma_transfer_config_t *config)
 Configures the GPDMA transfer attribute. More...
 
uint8_t GPDMA_GetFreeChannel (GPDMA_Type *base)
 Get a free GPDMA channel. More...
 

GPDMA Transactional Operation

void GPDMA_CreateHandle (gpdma_handle_t *handle, GPDMA_Type *base, uint8_t channel)
 Creates the GPDMA handle. More...
 
void GPDMA_SetCallback (gpdma_handle_t *handle, gpdma_callback callback, void *userData)
 Installs a callback function for the GPDMA transfer. More...
 
status_t GPDMA_SubmitTransfer (gpdma_handle_t *handle, const gpdma_transfer_config_t *config)
 Submits the GPDMA transfer request. More...
 
void GPDMA_AbortTransfer (gpdma_handle_t *handle)
 Abort running transfer by handle. More...
 
void GPDMA_StartTransfer (gpdma_handle_t *handle)
 GPDMA start transfer. More...
 
void GPDMA_HandleIRQ (GPDMA_Type *base)
 GPDMA IRQ Handler. More...
 

Data Structure Documentation

struct gpdma_transfer_config_t

Data Fields

uint32_t srcAddr
 Source data address. More...
 
uint32_t destAddr
 Destination data address. More...
 
gpdma_burst_size_t srcBurstSize
 Source data transfer size. More...
 
gpdma_burst_size_t destBurstSize
 Destination data transfer size. More...
 
gpdma_transfer_width_t srcTransferWidth
 Source data transfer width.
 
gpdma_transfer_width_t destTransferWidth
 Destination transfer width.
 
gpdma_transfer_type_t transferType
 Transfer Type.
 
uint32_t totalBytes
 Length/Size of transfer.
 
uint32_t linkListItem
 Next descriptor address, use 0 means disable. More...
 

Field Documentation

uint32_t gpdma_transfer_config_t::srcAddr
uint32_t gpdma_transfer_config_t::destAddr
gpdma_burst_size_t gpdma_transfer_config_t::srcBurstSize
gpdma_burst_size_t gpdma_transfer_config_t::destBurstSize
uint32_t gpdma_transfer_config_t::linkListItem
struct gpdma_descriptor_t

Data Fields

uint32_t srcAddr
 Source address.
 
uint32_t destAddr
 Destination address.
 
uint32_t lli
 Link to next descriptor. More...
 
uint32_t control
 Control word that has transfer size, trasnfer type etc. More...
 

Field Documentation

uint32_t gpdma_descriptor_t::lli
uint32_t gpdma_descriptor_t::control
struct gpdma_handle_t

Data Fields

gpdma_callback callback
 Callback function.
 
void * userData
 Callback function parameter. More...
 
uint8_t channel
 GPDMA channel number. More...
 
GPDMA_Type * base
 GPDMA peripheral base address. More...
 

Field Documentation

void* gpdma_handle_t::userData
uint8_t gpdma_handle_t::channel
GPDMA_Type* gpdma_handle_t::base

Macro Definition Documentation

#define FSL_GPDMA_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))

Version 2.0.1.

Typedef Documentation

typedef void(* gpdma_callback)(struct _gpdma_handle *handle, void *userData, uint32_t status)

This callback function is called in the GPDMA interrupt handle. Run into callback function means the transfer users need is done.

Parameters
handleGPDMA 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 GPDMA callback function.
statusGPDMA trasnfer status

Enumeration Type Documentation

Enumerator
kGPDMA_StatusClearInterruptTerminalCountRequest 

GPDMA Interrupt Terminal Count Request Clear.

kGPDMA_StatusClearInterruptError 

GPDMA Interrupt Error Clear.

Enumerator
kGPDMA_StatusInterrupt 

GPDMA Interrupt Status.

kGPDMA_StatusInterruptTerminalCountRequest 

GPDMA Interrupt Terminal Count Request Status.

kGPDMA_StatusInterruptError 

GPDMA Interrupt Error Status.

kGPDMA_StatusRawInterruptTerminalCount 

GPDMA Raw Interrupt Terminal Count Status.

kGPDMA_StatusRawErrorInterrupt 

GPDMA Raw Error Interrupt Status.

kGPDMA_StatusEnabledChannel 

GPDMA Enabled Channel Status.

Enumerator
kGPDMA_TransferM2MControllerDma 

Memory to memory, GPDMA control.

kGPDMA_TransferM2PControllerDma 

Memory to peripheral, GPDMA control.

kGPDMA_TransferP2MControllerDma 

Peripheral to memory, GPDMA control.

kGPDMA_TransferP2PControllerDma 

Source peripheral to destination peripheral, GPDMA control.

kGPDMA_TransferP2PControllerDestPeripheral 

Source peripheral to destination peripheral, destination peripheral control.

kGPDMA_TransferM2PControllerPeripheral 

Memory to peripheral, peripheral control.

kGPDMA_TransferP2MControllerPeripheral 

Peripheral to memory, peripheral control.

kGPDMA_TransferP2PControllerSrcPeripheral 

Source peripheral to destination peripheral, source peripheral control.

Enumerator
kGPDMA_TransferWidth1Bytes 

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

kGPDMA_TransferWidth2Bytes 

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

kGPDMA_TransferWidth4Bytes 

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

Enumerator
kGPDMA_BurstSize1 

Source/Destination data burst size is 1 every time.

kGPDMA_BurstSize4 

Source/Destination data burst size is 4 every time.

kGPDMA_BurstSize8 

Source/Destination data burst size is 8 every time.

kGPDMA_BurstSize16 

Source/Destination data burst size is 16 every time.

kGPDMA_BurstSize32 

Source/Destination data burst size is 32 every time.

kGPDMA_BurstSize64 

Source/Destination data burst size is 64 every time.

kGPDMA_BurstSize128 

Source/Destination data burst size is 128 every time.

kGPDMA_BurstSize256 

Source/Destination data burst size is 256 every time.

Function Documentation

status_t GPDMA_Init ( GPDMA_Type *  base)
Parameters
baseGPDMA peripheral base address.
Return values
kStatus_SuccessInitialiation succeed.
kStatus_TimeoutTimeout during initialization.
void GPDMA_Deinit ( GPDMA_Type *  base)
Parameters
baseGPDMA peripheral base address.
static void GPDMA_EnableChannelInterrupts ( GPDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
static void GPDMA_DisableChannelInterrupts ( GPDMA_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
static void GPDMA_SetChannelSourcePeripheral ( GPDMA_Type *  base,
uint8_t  channel,
gpdma_request_source_t  srcPeripheral 
)
inlinestatic
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
srcPeripheralGPDMA hardware service request source for the channel.
static void GPDMA_SetChannelDestinationPeripheral ( GPDMA_Type *  base,
uint8_t  channel,
gpdma_request_source_t  destPeripheral 
)
inlinestatic
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
destPeripheralGPDMA hardware service request source for the channel.
void GPDMA_EnableChannel ( GPDMA_Type *  base,
uint8_t  channel,
bool  enable 
)
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
enabletrue to enable GPDMA or false to disable GPDMA channel.
void GPDMA_StopChannel ( GPDMA_Type *  base,
uint8_t  channel 
)
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
status_t GPDMA_CheckChannelInterrupts ( GPDMA_Type *  base,
uint8_t  channel 
)
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
Returns
status: kStatus_Success It means succeed. kStatus_Fail It means failed.
bool GPDMA_GetChannelStatus ( GPDMA_Type *  base,
uint8_t  channel,
gpdma_status_t  flag 
)
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
flagThe GPDMA interrupt flag.
Returns
status: true It means flag is set. false It means flag is not set.
void GPDMA_ClearChannelStatus ( GPDMA_Type *  base,
uint8_t  channel,
gpdma_status_clear_t  flag 
)
Parameters
baseBase address of GPDMA module.
channelThe GPDMA channel (0 to 7).
flagThe GPDMA interrupt flag.
status_t GPDMA_PrepareDescriptor ( gpdma_descriptor_t descriptor,
void *  srcAddr,
gpdma_burst_size_t  srcBurstSize,
gpdma_transfer_width_t  srcTransferWidth,
void *  destAddr,
gpdma_burst_size_t  destBurstSize,
gpdma_transfer_width_t  destTransferWidth,
uint32_t  totalBytes,
gpdma_transfer_type_t  transferType,
uint32_t  linkListItem 
)
Parameters
descriptorThe transfer descriptor.
srcAddrGPDMA transfer source address.
srcBurstSizesource address offset.
srcTransferWidthSource data trasnfer size every time.
destAddrGPDMA transfer destination address.
destBurstSizedestination address offset.
destTransferWidthDestination data trasnfer size every time.
totalBytesGPDMA transfer bytes to be transferred.
transferTypeGPDMA transfer type.
linkListItemPointer to next transfer descriptor.
retvalkStatus_Success Prepared successfully.
retvalkStatus_InvalidArgument Failed because invalid argument.
void GPDMA_PrepareTransferConfig ( gpdma_transfer_config_t config,
void *  srcAddr,
gpdma_burst_size_t  srcBurstSize,
gpdma_transfer_width_t  srcTransferWidth,
void *  destAddr,
gpdma_burst_size_t  destBurstSize,
gpdma_transfer_width_t  destTransferWidth,
uint32_t  totalBytes,
gpdma_transfer_type_t  transferType,
uint32_t  linkListItem 
)
Parameters
configThe user configuration structure of type.
srcAddrGPDMA transfer source address.
srcBurstSizesource address offset.
srcTransferWidthSource data trasnfer size every time.
destAddrGPDMA transfer destination address.
destBurstSizedestination address offset.
destTransferWidthDestination data trasnfer size every time.
totalBytesGPDMA transfer bytes to be transferred.
transferTypeGPDMA transfer type.
linkListItemPointer to next transfer descriptor.
status_t GPDMA_SetTransferConfig ( GPDMA_Type *  base,
uint8_t  channel,
const gpdma_transfer_config_t config 
)
Parameters
baseGPDMA peripheral base address.
channelThe GPDMA channel (0 to 7).
configPointer to GPDMA transfer configuration structure.
Return values
kStatus_BusyThe channel is busy.
kStatus_SuccessSet succeed.
uint8_t GPDMA_GetFreeChannel ( GPDMA_Type *  base)
Parameters
baseBase address of GPDMA module.
Returns
The channel number which is selected in case of success (0 to 7).
Maximum channel number (8) in case channel is not available.
void GPDMA_CreateHandle ( gpdma_handle_t handle,
GPDMA_Type *  base,
uint8_t  channel 
)
Parameters
handleGPDMA handle pointer. The GPDMA handle stores callback function and parameters.
baseGPDMA peripheral base address.
channelThe GPDMA channel (0 to 7).
void GPDMA_SetCallback ( gpdma_handle_t handle,
gpdma_callback  callback,
void *  userData 
)
Parameters
handleGPDMA handle pointer.
callbackGPDMA callback function pointer.
userDataA parameter for the callback function.
status_t GPDMA_SubmitTransfer ( gpdma_handle_t handle,
const gpdma_transfer_config_t config 
)
Parameters
handleGPDMA handle pointer.
configPointer to GPDMA transfer configuration structure.
Return values
kStatus_BusyThe channel is busy.
kStatus_SuccessSet succeed.
void GPDMA_AbortTransfer ( gpdma_handle_t handle)

This function aborts GPDMA transfer specified by handle.

handle GPDMA handle pointer.

void GPDMA_StartTransfer ( gpdma_handle_t handle)

User can call this function after GPDMA_SubmitTransfer.

Parameters
handleGPDMA handle pointer.
void GPDMA_HandleIRQ ( GPDMA_Type *  base)
Parameters
baseBase address of GPDMA module.