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

Overview

The MCUXpresso SDK provides a peripheral driver for the Direct Memory Access (DMAC) of MCUXpresso SDK devices.

Typical use case

DMAC Operation

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dmac

Data Structures

struct  dmac_channel_transfer_config_t
 dmac channel transfer configuration More...
 
struct  dmac_config_t
 dmac configuration structure More...
 
struct  dmac_handle_t
 DMAC transfer handle structure. More...
 

Typedefs

typedef void(* dmac_transfer_callback_t )(dmac_handle_t *handle, void *userData, uint32_t status)
 Define Callback function for DMAC. More...
 

Enumerations

enum  dmac_channel_transfer_type_t {
  kDMAC_ChannelTransferMemoryToMemory = 0x0U,
  kDMAC_ChannelTransferPeripheralToMemory,
  kDMAC_ChannelTransferMemoryToPeripheral
}
 DMAC transfer type. More...
 
enum  _dmac_channel_interrupt_flag {
  kDMAC_ChannelInterruptFlagTransferComplete = 1U,
  kDMAC_ChannelInterruptBlockTransferComplete = 2U,
  kDMAC_ChannelInterruptFlagBusError = 4U,
  kDMAC_ChannelInterruptFlagAdressError = 8U
}
 DMAC interrupt source. More...
 
enum  dmac_channel_t {
  kDMAC_Channel0 = 0U,
  kDMAC_Channel1 = 1U,
  kDMAC_Channel2 = 2U,
  kDMAC_Channel3 = 3U,
  kDMAC_Channel4 = 4U,
  kDMAC_Channel5 = 5U,
  kDMAC_Channel6 = 6U,
  kDMAC_Channel7 = 7U,
  kDMAC_Channel8 = 8U,
  kDMAC_Channel9 = 9U,
  kDMAC_Channel10 = 10U,
  kDMAC_Channel11 = 11U,
  kDMAC_Channel12 = 12U,
  kDMAC_Channel13 = 13U,
  kDMAC_Channel14 = 14U,
  kDMAC_Channel15 = 15U,
  kDMAC_Channel16 = 16U,
  kDMAC_Channel17 = 17U,
  kDMAC_Channel18 = 18U,
  kDMAC_Channel19 = 19U,
  kDMAC_Channel20 = 20U,
  kDMAC_Channel21 = 21U,
  kDMAC_Channel22 = 22U,
  kDMAC_Channel23 = 23U,
  kDMAC_Channel24 = 24U,
  kDMAC_Channel25 = 25U,
  kDMAC_Channel26 = 26U,
  kDMAC_Channel27 = 27U,
  kDMAC_Channel28 = 28U,
  kDMAC_Channel29 = 29U,
  kDMAC_Channel30 = 30U,
  kDMAC_Channel31 = 31U
}
 dmac channel index More...
 
enum  dmac_channel_address_increment_type_t {
  kDMAC_ChannelAddressFix = 0U,
  kDMAC_ChannelAddressIncrement
}
 DMAC transfer address increment definition. More...
 
enum  dmac_channel_transfer_width_t {
  kDMAC_ChannelTransferWidth8Bits = 1U,
  kDMAC_ChannelTransferWidth16Bits = 2U,
  kDMAC_ChannelTransferWidth32Bits = 4U
}
 DMAC transfer width configuration. More...
 
enum  dmac_channel_burst_length_t {
  kDMAC_ChannelBurstLength1DataWidth = 0U,
  kDMAC_ChannelBurstLength4DataWidth,
  kDMAC_ChannelBurstLength8DataWidth,
  kDMAC_ChannelBurstLength16DataWidth
}
 DMAC transfer burst length definition. More...
 

DMAC Initialization and De-initialization interfaces

void DMAC_GetDefaultConfig (dmac_config_t *config)
 Get default dmac configuration. More...
 
void DMAC_Init (DMAC_Type *base, dmac_config_t *config)
 DMAC initialization. More...
 
void DMAC_Deinit (DMAC_Type *base)
 DMAC De-initialization. More...
 

DMAC channel functional interfaces

void DMAC_GetChannelDefaultTransferConfig (dmac_channel_transfer_config_t *transfer, void *srcAddr, void *destAddr, dmac_channel_transfer_width_t transferWidth, dmac_channel_burst_length_t burstLength, uint32_t transferTotalBytes, dmac_channel_transfer_type_t transferType)
 Get channel default transfer configuration. More...
 
void DMAC_SetChannelTransferConfig (DMAC_Type *base, dmac_channel_t channel, dmac_channel_transfer_config_t *transfer)
 DMAC set channel transfer configurations. More...
 
static void DMAC_StartChannel (DMAC_Type *base, dmac_channel_t channel)
 start the dmac channel More...
 
static void DMAC_StopChannel (DMAC_Type *base, dmac_channel_t channel)
 stop the dmac channel More...
 
void DMAC_SetAckDelayCycle (DMAC_Type *base, uint32_t m2pAckDelayCycle)
 DMAC ack delay cycle for single transfer in M2P transfer type.Only called when the transfer type is M2P. More...
 
void DMAC_SetPeripheralNumber (DMAC_Type *base, dmac_channel_t channel, dmac_peripheral_number_t peripheralNumber)
 DMAC set peripheral number. More...
 

DMAC channel interrupt Interfaces

void DMAC_EnableChannelInterrupts (DMAC_Type *base, dmac_channel_t channel, uint32_t interruptsMask)
 enables the dmac channel interrupts More...
 
void DMAC_DisableChannelInterrupts (DMAC_Type *base, dmac_channel_t channel, uint32_t interruptsMask)
 disables the dmac channel interrupts More...
 

DMAC channel Status Interfaces

uint32_t DMAC_GetChannelInterruptStatus (DMAC_Type *base, dmac_channel_t channel)
 Gets the DMAC channel status. More...
 
void DMAC_ClearChannelInterruptStatus (DMAC_Type *base, dmac_channel_t channel, uint32_t status)
 Clears the DMAC channel status. More...
 

DMAC Transactional Interfaces

void DMAC_TransferCreateHandle (DMAC_Type *base, dmac_handle_t *handle, dmac_channel_t channel)
 Creates the DMAC channel handle. More...
 
void DMAC_TransferSetCallback (dmac_handle_t *handle, dmac_transfer_callback_t callback, void *userData)
 Sets the DMAC Callback function. More...
 
status_t DMAC_TransferSubmit (dmac_handle_t *handle, dmac_channel_transfer_config_t *transfer)
 Submits the DMAC transfer configurations. More...
 
void DMAC_TransferStart (dmac_handle_t *handle)
 DMAC starts transfer. More...
 
void DMAC_TransferStop (dmac_handle_t *handle)
 DMAC stops transfer. More...
 
void DMAC_TransferHandleIRQ (DMAC_Type *base)
 DMAC IRQ handler for the transfer completion. More...
 

Data Structure Documentation

struct dmac_channel_transfer_config_t

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

Data Fields

void * srcAddr
 source address
 
void * destAddr
 destination address
 
dmac_channel_address_increment_type_t srcAddrIncrementType
 
       Source address increment

kDMAC_ChannelAddressFix: No change kDMAC_ChannelAddressIncrement: Increment

 
dmac_channel_address_increment_type_t destAddrIncrementType
 
       Destination address increment

kDMAC_ChannelAddressFix: No change kDMAC_ChannelAddressIncrement: Increment

 
dmac_channel_transfer_type_t transferType
 Transfer type and flow control kDMAC_ChannelTransferMemoryToMemory: Memory to Memory kDMAC_ChannelTransferPeripheralToMemory: Memory to peripheral kDMAC_ChannelTransferMemoryToPeripheral: Peripheral to memory.
 
dmac_channel_burst_length_t burstLength
 
   Burst transaction length

kDMAC_ChannelBurstLength1DataWidth: 1 Data Width kDMAC_ChannelBurstLength4DataWidth: 4 Data Width kDMAC_ChannelBurstLength8DataWidth: 8 Data Width kDMAC_ChannelBurstLength16DataWidth: 16 Data Width

 
dmac_channel_transfer_width_t transferWidth
 Transfer width kDMAC_ChannelTransferWidth8Bits: 8 bits kDMAC_ChannelTransferWidth16Bits: 16 bits kDMAC_ChannelTransferWidth32Bits: 32 bits.
 
uint32_t transferTotalBytes
 Transfer totalbytes 0~8191bytes maximum transfer length (8k-1) bytes.
 
uint32_t interruptMask
 Interrupt Mask.
 
struct dmac_config_t

Data Fields

uint32_t m2pAckDelayCycle
 m2pAckDelayCycle for single write transaction to peripheral. More...
 
dmac_channel_transfer_config_tchannelTransferConfig [FSL_FEATURE_MW_DMAC_MODULE_CHANNEL]
 channel transfer configuration pointer
 
dmac_peripheral_number_t peripheralNumber [FSL_FEATURE_MW_DMAC_MODULE_CHANNEL]
 
                      Peripheral Number

Indicates the valid peripheral request number.The default value kDMAC_PeriphNum_None. More...

 

Field Documentation

uint32_t dmac_config_t::m2pAckDelayCycle

The value should be less than 1023, default value 12.

dmac_peripheral_number_t dmac_config_t::peripheralNumber[FSL_FEATURE_MW_DMAC_MODULE_CHANNEL]
struct _dmac_handle

handler for DMAC

Data Fields

volatile uint32_t state
 channel transfer state
 
dmac_transfer_callback_t callback
 callback function
 
void * userData
 Callback function parameter. More...
 
DMAC_Type * base
 DMAC peripheral base address. More...
 
dmac_channel_t channel
 DMAC channel number. More...
 

Field Documentation

void* dmac_handle_t::userData
DMAC_Type* dmac_handle_t::base
dmac_channel_t dmac_handle_t::channel

Typedef Documentation

typedef void(* dmac_transfer_callback_t)(dmac_handle_t *handle, void *userData, uint32_t status)
Parameters
handleDMAC 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 DMAC Callback function.
statusThe mask of channel status . Users need to use the _dmac_channel_interrupt_status type. If the current loaded transfer done. In normal mode it means if all transfer done. In scatter gather mode, this parameter shows is the current transfer block in DMAC register is done.

Enumeration Type Documentation

Enumerator
kDMAC_ChannelTransferMemoryToMemory 

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

kDMAC_ChannelTransferPeripheralToMemory 

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

kDMAC_ChannelTransferMemoryToPeripheral 

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

Enumerator
kDMAC_ChannelInterruptFlagTransferComplete 

Dmac transfer complete interrupt.

kDMAC_ChannelInterruptBlockTransferComplete 

Block transfer complete interrupt.

kDMAC_ChannelInterruptFlagBusError 

Bus Error interrupt.

kDMAC_ChannelInterruptFlagAdressError 

Address Error interrupt.

Enumerator
kDMAC_Channel0 

channel 0 define, priority level 0, the highest priority

kDMAC_Channel1 

channel 1 define, priority level 0, the highest priority

kDMAC_Channel2 

channel 2 define, priority level 0, the highest priority

kDMAC_Channel3 

channel 3 define, priority level 0, the highest priority

kDMAC_Channel4 

channel 4 define, priority level 1

kDMAC_Channel5 

channel 5 define, priority level 1

kDMAC_Channel6 

channel 6 define, priority level 1

kDMAC_Channel7 

channel 7 define, priority level 1

kDMAC_Channel8 

channel 8 define, priority level 2

kDMAC_Channel9 

channel 9 define, priority level 2

kDMAC_Channel10 

channel 10 define, priority level 2

kDMAC_Channel11 

channel 11 define, priority level 2

kDMAC_Channel12 

channel 12 define, priority level 3, the lowest priority

kDMAC_Channel13 

channel 13 define, priority level 3, the lowest priority

kDMAC_Channel14 

channel 14 define, priority level 3, the lowest priority

kDMAC_Channel15 

channel 15 define, priority level 3, the lowest priority

kDMAC_Channel16 

channel 16 define, priority level 0, the highest priority

kDMAC_Channel17 

channel 17 define, priority level 0, the highest priority

kDMAC_Channel18 

channel 18 define, priority level 0, the highest priority

kDMAC_Channel19 

channel 19 define, priority level 0, the highest priority

kDMAC_Channel20 

channel 20 define, priority level 1

kDMAC_Channel21 

channel 21 define, priority level 1

kDMAC_Channel22 

channel 22 define, priority level 1

kDMAC_Channel23 

channel 23 define, priority level 1

kDMAC_Channel24 

channel 24 define, priority level 2

kDMAC_Channel25 

channel 25 define, priority level 2

kDMAC_Channel26 

channel 26 define, priority level 2

kDMAC_Channel27 

channel 27 define, priority level 2

kDMAC_Channel28 

channel 28 define, priority level 3, the lowest priority

kDMAC_Channel29 

channel 29 define, priority level 3, the lowest priority

kDMAC_Channel30 

channel 30 define, priority level 3, the lowest priority

kDMAC_Channel31 

channel 31 define, priority level 3, the lowest priority

Enumerator
kDMAC_ChannelAddressFix 

Address Fix.

kDMAC_ChannelAddressIncrement 

Address increment.

Enumerator
kDMAC_ChannelTransferWidth8Bits 

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

kDMAC_ChannelTransferWidth16Bits 

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

kDMAC_ChannelTransferWidth32Bits 

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

Enumerator
kDMAC_ChannelBurstLength1DataWidth 

Maximum burst transaction length 1 data width.

kDMAC_ChannelBurstLength4DataWidth 

Maximum burst transaction length 4 data width.

kDMAC_ChannelBurstLength8DataWidth 

Maximum burst transaction length 8 data width.

kDMAC_ChannelBurstLength16DataWidth 

Maximum burst transaction length 16 data width.

Function Documentation

void DMAC_GetDefaultConfig ( dmac_config_t config)
Note
This function will reset all of the configuration structure members to zero firstly, then apply default configurations to the structure.
Parameters
configpointer to user's DMAC configure structure, see dmac_config_t for detail.
void DMAC_Init ( DMAC_Type *  base,
dmac_config_t config 
)
Parameters
baseDMAC peripheral base address.
configpointer to user's DMAC config structure, see dmac_config_t for detail.
void DMAC_Deinit ( DMAC_Type *  base)
Parameters
baseDMAC peripheral base address.
void DMAC_GetChannelDefaultTransferConfig ( dmac_channel_transfer_config_t transfer,
void *  srcAddr,
void *  destAddr,
dmac_channel_transfer_width_t  transferWidth,
dmac_channel_burst_length_t  burstLength,
uint32_t  transferTotalBytes,
dmac_channel_transfer_type_t  transferType 
)
Parameters
transferpointer to user's DMAC channel configure structure, see dmac_channel_transfer_config_t for detail.
srcAddrsource address, must be byte address.
destAddrdestination address, must be byte address.
transferWidththe number of bits are transferred in each read/write.
burstLengthburst transaction length.
transferTotalBytestransfer totalbytes 0~8191bytes maximum transfer length (8k-1) bytes.
transferTypeDMAC channel transfer type.
void DMAC_SetChannelTransferConfig ( DMAC_Type *  base,
dmac_channel_t  channel,
dmac_channel_transfer_config_t transfer 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
transferpointer to user's DMAC channel configure structure,see dmac_channel_transfer_config_t for detail.
static void DMAC_StartChannel ( DMAC_Type *  base,
dmac_channel_t  channel 
)
inlinestatic
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
static void DMAC_StopChannel ( DMAC_Type *  base,
dmac_channel_t  channel 
)
inlinestatic
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
void DMAC_SetAckDelayCycle ( DMAC_Type *  base,
uint32_t  m2pAckDelayCycle 
)
Parameters
baseDMAC peripheral base address.
m2pAckDelayCyclefor single write transaction to peripheral. The value should be less than 1023, default value 12.
void DMAC_SetPeripheralNumber ( DMAC_Type *  base,
dmac_channel_t  channel,
dmac_peripheral_number_t  peripheralNumber 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
peripheralNumberIndicates the valid peripheral request number, default value kDMAC_PeriphNum_None, see dmac_peripheral_number_t for detail.
void DMAC_EnableChannelInterrupts ( DMAC_Type *  base,
dmac_channel_t  channel,
uint32_t  interruptsMask 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
interruptsMaskthe mask is a logical OR of enumerator members see _dmac_channel_interrupt_flag.
void DMAC_DisableChannelInterrupts ( DMAC_Type *  base,
dmac_channel_t  channel,
uint32_t  interruptsMask 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
interruptsMaskthe mask is a logical OR of enumerator members see _dmac_channel_interrupt_flag.
uint32_t DMAC_GetChannelInterruptStatus ( DMAC_Type *  base,
dmac_channel_t  channel 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
Return values
Themask of channel status. Users need to use the _dmac_channel_interrupt_flag type to decode the return variables.
void DMAC_ClearChannelInterruptStatus ( DMAC_Type *  base,
dmac_channel_t  channel,
uint32_t  status 
)
Parameters
baseDMAC peripheral base address.
channelDMAC channel number.
statusThe mask of channel status to be cleared. Users need to use the defined _dmac_channel_interrupt_flag type.
void DMAC_TransferCreateHandle ( DMAC_Type *  base,
dmac_handle_t *  handle,
dmac_channel_t  channel 
)

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

Parameters
baseDMAC peripheral base address.
handleDMAC handle pointer. The DMAC handle stores Callback function and parameters.
channelDMAC channel number.
void DMAC_TransferSetCallback ( dmac_handle_t *  handle,
dmac_transfer_callback_t  callback,
void *  userData 
)

This callback is called in the DMAC IRQ handler. Use the callback to do something after the current transfer complete.

Parameters
handleDMAC handle pointer.
callbackDMAC callback function pointer.
userDataParameter for callback function. If it is not needed, just set to NULL.
status_t DMAC_TransferSubmit ( dmac_handle_t *  handle,
dmac_channel_transfer_config_t transfer 
)
Parameters
handleDMAC handle pointer
transferpointer to user's DMAC channel configure structure,see dmac_channel_transfer_config_t for detail.
Return values
kStatus_SuccessIt means submit transfer request succeed
kStatus_FailIt means submit transfer request failed
void DMAC_TransferStart ( dmac_handle_t *  handle)

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

Parameters
handleDMAC handle pointer.
void DMAC_TransferStop ( dmac_handle_t *  handle)

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

Parameters
handleDMAC handle pointer.
void DMAC_TransferHandleIRQ ( DMAC_Type *  base)
Parameters
baseDMAC peripheral base address.