MCUXpresso SDK API Reference Manual: SDMA: Smart Direct Memory Access (SDMA) Controller Driver

| MCUXpresso SDK API Reference Manual Rev 2.11.1 NXP Semiconductors

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Typedefs | Enumerations
SDMA: Smart Direct Memory Access (SDMA) Controller Driver

## Overview

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

# Typical use case

## SDMA Operation

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

## Data Structures
struct | sdma_config_t
| SDMA global configuration structure. More...
struct | sdma_multi_fifo_config_t
| SDMA multi fifo configurations. More...
struct | sdma_sw_done_config_t
| SDMA sw done configurations. More...
struct | sdma_p2p_config_t
| SDMA peripheral to peripheral R7 config. More...
struct | sdma_transfer_config_t
| SDMA transfer configuration. More...
struct | sdma_buffer_descriptor_t
| SDMA buffer descriptor structure. More...
struct | sdma_channel_control_t
| SDMA channel control descriptor structure. More...
struct | sdma_context_data_t
| SDMA context structure for each channel. More...
struct | sdma_handle_t
| SDMA transfer handle structure. More...

## Typedefs
typedef void(* | sdma_callback )(struct _sdma_handle *handle, void *userData, bool transferDone, uint32_t bdIndex)
| Define callback function for SDMA. More...

## Enumerations
enum | sdma_transfer_size_t { kSDMA_TransferSize1Bytes = 0x1U, kSDMA_TransferSize2Bytes = 0x2U, kSDMA_TransferSize3Bytes = 0x3U, kSDMA_TransferSize4Bytes = 0x0U }
| SDMA transfer configuration. More...
enum | sdma_bd_status_t { kSDMA_BDStatusDone = 0x1U, kSDMA_BDStatusWrap = 0x2U, kSDMA_BDStatusContinuous = 0x4U, kSDMA_BDStatusInterrupt = 0x8U, kSDMA_BDStatusError = 0x10U, kSDMA_BDStatusLast, kSDMA_BDStatusExtend = 0x80U }
| SDMA buffer descriptor status. More...
enum | sdma_bd_command_t { kSDMA_BDCommandSETDM = 0x1U, kSDMA_BDCommandGETDM = 0x2U, kSDMA_BDCommandSETPM = 0x4U, kSDMA_BDCommandGETPM = 0x6U, kSDMA_BDCommandSETCTX = 0x7U, kSDMA_BDCommandGETCTX = 0x3U }
| SDMA buffer descriptor command. More...
enum | sdma_context_switch_mode_t { kSDMA_ContextSwitchModeStatic = 0x0U, kSDMA_ContextSwitchModeDynamicLowPower, kSDMA_ContextSwitchModeDynamicWithNoLoop, kSDMA_ContextSwitchModeDynamic }
| SDMA context switch mode. More...
enum | sdma_clock_ratio_t { kSDMA_HalfARMClockFreq = 0x0U, kSDMA_ARMClockFreq }
| SDMA core clock frequency ratio to the ARM DMA interface. More...
enum | sdma_transfer_type_t { kSDMA_MemoryToMemory = 0x0U, kSDMA_PeripheralToMemory, kSDMA_MemoryToPeripheral, kSDMA_PeripheralToPeripheral }
| SDMA transfer type. More...
enum | sdma_peripheral_t { kSDMA_PeripheralTypeMemory = 0x0, kSDMA_PeripheralTypeUART, kSDMA_PeripheralTypeUART_SP, kSDMA_PeripheralTypeSPDIF, kSDMA_PeripheralNormal, kSDMA_PeripheralNormal_SP, kSDMA_PeripheralMultiFifoPDM, kSDMA_PeripheralMultiFifoSaiRX, kSDMA_PeripheralMultiFifoSaiTX, kSDMA_PeripheralASRCM2P, kSDMA_PeripheralASRCP2M, kSDMA_PeripheralASRCP2P }
| Peripheral type use SDMA. More...
enum | { kStatus_SDMA_ERROR = MAKE_STATUS(kStatusGroup_SDMA, 0), kStatus_SDMA_Busy = MAKE_STATUS(kStatusGroup_SDMA, 1) }
| _sdma_transfer_status SDMA transfer status More...
enum | { kSDMA_MultiFifoWatermarkLevelMask = 0xFFFU, kSDMA_MultiFifoNumsMask = 0xFU, kSDMA_MultiFifoOffsetMask = 0xFU, kSDMA_MultiFifoSwDoneMask = 0x1U, kSDMA_MultiFifoSwDoneSelectorMask = 0xFU }
| _sdma_multi_fifo_mask SDMA multi fifo mask More...
enum | { kSDMA_MultiFifoWatermarkLevelShift = 0U, kSDMA_MultiFifoNumsShift = 12U, kSDMA_MultiFifoOffsetShift = 16U, kSDMA_MultiFifoSwDoneShift = 23U, kSDMA_MultiFifoSwDoneSelectorShift = 24U }
| _sdma_multi_fifo_shift SDMA multi fifo shift More...
enum | { kSDMA_DoneChannel0 = 0U, kSDMA_DoneChannel1 = 1U, kSDMA_DoneChannel2 = 2U, kSDMA_DoneChannel3 = 3U, kSDMA_DoneChannel4 = 4U, kSDMA_DoneChannel5 = 5U, kSDMA_DoneChannel6 = 6U, kSDMA_DoneChannel7 = 7U }
| _sdma_done_channel SDMA done channel More...
enum | sdma_done_src_t { kSDMA_DoneSrcSW = 0U, kSDMA_DoneSrcHwEvent0U = 1U, kSDMA_DoneSrcHwEvent1U = 2U, kSDMA_DoneSrcHwEvent2U = 3U, kSDMA_DoneSrcHwEvent3U = 4U, kSDMA_DoneSrcHwEvent4U = 5U, kSDMA_DoneSrcHwEvent5U = 6U, kSDMA_DoneSrCHwEvent6U = 7U, kSDMA_DoneSrcHwEvent7U = 8U, kSDMA_DoneSrcHwEvent8U = 9U, kSDMA_DoneSrcHwEvent9U = 10U, kSDMA_DoneSrcHwEvent10U = 11U, kSDMA_DoneSrcHwEvent11U = 12U, kSDMA_DoneSrcHwEvent12U = 13U, kSDMA_DoneSrcHwEvent13U = 14U, kSDMA_DoneSrcHwEvent14U = 15U, kSDMA_DoneSrcHwEvent15U = 16U, kSDMA_DoneSrcHwEvent16U = 17U, kSDMA_DoneSrcHwEvent17U = 18U, kSDMA_DoneSrcHwEvent18U = 19U, kSDMA_DoneSrcHwEvent19U = 20U, kSDMA_DoneSrcHwEvent20U = 21U, kSDMA_DoneSrcHwEvent21U = 22U, kSDMA_DoneSrcHwEvent22U = 23U, kSDMA_DoneSrcHwEvent23U = 24U, kSDMA_DoneSrcHwEvent24U = 25U, kSDMA_DoneSrcHwEvent25U = 26U, kSDMA_DoneSrcHwEvent26U = 27U, kSDMA_DoneSrcHwEvent27U = 28U, kSDMA_DoneSrcHwEvent28U = 29U, kSDMA_DoneSrcHwEvent29U = 30U, kSDMA_DoneSrcHwEvent30U = 31U, kSDMA_DoneSrcHwEvent31U = 32U }
| SDMA done source. More...

## Driver version
#define | FSL_SDMA_DRIVER_VERSION (MAKE_VERSION(2, 3, 6))
| SDMA driver version. More...

## SDMA initialization and de-initialization
void | SDMA_Init (SDMAARM_Type *base, const sdma_config_t *config)
| Initializes the SDMA peripheral. More...
void | SDMA_Deinit (SDMAARM_Type *base)
| Deinitializes the SDMA peripheral. More...
void | SDMA_GetDefaultConfig (sdma_config_t *config)
| Gets the SDMA default configuration structure. More...
void | SDMA_ResetModule (SDMAARM_Type *base)
| Sets all SDMA core register to reset status. More...

## SDMA Channel Operation
static void | SDMA_EnableChannelErrorInterrupts (SDMAARM_Type *base, uint32_t channel)
| Enables the interrupt source for the SDMA error. More...
static void | SDMA_DisableChannelErrorInterrupts (SDMAARM_Type *base, uint32_t channel)
| Disables the interrupt source for the SDMA error. More...

## SDMA Buffer Descriptor Operation
void | SDMA_ConfigBufferDescriptor (sdma_buffer_descriptor_t *bd, uint32_t srcAddr, uint32_t destAddr, sdma_transfer_size_t busWidth, size_t bufferSize, bool isLast, bool enableInterrupt, bool isWrap, sdma_transfer_type_t type)
| Sets buffer descriptor contents. More...

## SDMA Channel Transfer Operation
static void | SDMA_SetChannelPriority (SDMAARM_Type *base, uint32_t channel, uint8_t priority)
| Set SDMA channel priority. More...
static void | SDMA_SetSourceChannel (SDMAARM_Type *base, uint32_t source, uint32_t channelMask)
| Set SDMA request source mapping channel. More...
static void | SDMA_StartChannelSoftware (SDMAARM_Type *base, uint32_t channel)
| Start a SDMA channel by software trigger. More...
static void | SDMA_StartChannelEvents (SDMAARM_Type *base, uint32_t channel)
| Start a SDMA channel by hardware events. More...
static void | SDMA_StopChannel (SDMAARM_Type *base, uint32_t channel)
| Stop a SDMA channel. More...
void | SDMA_SetContextSwitchMode (SDMAARM_Type *base, sdma_context_switch_mode_t mode)
| Set the SDMA context switch mode. More...

## SDMA Channel Status Operation
static uint32_t | SDMA_GetChannelInterruptStatus (SDMAARM_Type *base)
| Gets the SDMA interrupt status of all channels. More...
static void | SDMA_ClearChannelInterruptStatus (SDMAARM_Type *base, uint32_t mask)
| Clear the SDMA channel interrupt status of specific channels. More...
static uint32_t | SDMA_GetChannelStopStatus (SDMAARM_Type *base)
| Gets the SDMA stop status of all channels. More...
static void | SDMA_ClearChannelStopStatus (SDMAARM_Type *base, uint32_t mask)
| Clear the SDMA channel stop status of specific channels. More...
static uint32_t | SDMA_GetChannelPendStatus (SDMAARM_Type *base)
| Gets the SDMA channel pending status of all channels. More...
static void | SDMA_ClearChannelPendStatus (SDMAARM_Type *base, uint32_t mask)
| Clear the SDMA channel pending status of specific channels. More...
static uint32_t | SDMA_GetErrorStatus (SDMAARM_Type *base)
| Gets the SDMA channel error status. More...
bool | SDMA_GetRequestSourceStatus (SDMAARM_Type *base, uint32_t source)
| Gets the SDMA request source pending status. More...

## SDMA Transactional Operation
void | SDMA_CreateHandle (sdma_handle_t *handle, SDMAARM_Type *base, uint32_t channel, sdma_context_data_t *context)
| Creates the SDMA handle. More...
void | SDMA_InstallBDMemory (sdma_handle_t *handle, sdma_buffer_descriptor_t *BDPool, uint32_t BDCount)
| Installs the BDs memory pool into the SDMA handle. More...
void | SDMA_SetCallback (sdma_handle_t *handle, sdma_callback callback, void *userData)
| Installs a callback function for the SDMA transfer. More...
void | SDMA_SetMultiFifoConfig (sdma_transfer_config_t *config, uint32_t fifoNums, uint32_t fifoOffset)
| multi fifo configurations. More...
void | SDMA_EnableSwDone (SDMAARM_Type *base, sdma_transfer_config_t *config, uint8_t sel, sdma_peripheral_t type)
| enable sdma sw done feature. More...
void | SDMA_SetDoneConfig (SDMAARM_Type *base, sdma_transfer_config_t *config, sdma_peripheral_t type, sdma_done_src_t doneSrc)
| sdma channel done configurations. More...
void | SDMA_LoadScript (SDMAARM_Type *base, uint32_t destAddr, void *srcAddr, size_t bufferSizeBytes)
| load script to sdma program memory. More...
void | SDMA_DumpScript (SDMAARM_Type *base, uint32_t srcAddr, void *destAddr, size_t bufferSizeBytes)
| dump script from sdma program memory. More...
void | SDMA_PrepareTransfer (sdma_transfer_config_t *config, uint32_t srcAddr, uint32_t destAddr, uint32_t srcWidth, uint32_t destWidth, uint32_t bytesEachRequest, uint32_t transferSize, uint32_t eventSource, sdma_peripheral_t peripheral, sdma_transfer_type_t type)
| Prepares the SDMA transfer structure. More...
void | SDMA_PrepareP2PTransfer (sdma_transfer_config_t *config, uint32_t srcAddr, uint32_t destAddr, uint32_t srcWidth, uint32_t destWidth, uint32_t bytesEachRequest, uint32_t transferSize, uint32_t eventSource, uint32_t eventSource1, sdma_peripheral_t peripheral, sdma_p2p_config_t *p2p)
| Prepares the SDMA P2P transfer structure. More...
void | SDMA_SubmitTransfer (sdma_handle_t *handle, const sdma_transfer_config_t *config)
| Submits the SDMA transfer request. More...
void | SDMA_StartTransfer (sdma_handle_t *handle)
| SDMA starts transfer. More...
void | SDMA_StopTransfer (sdma_handle_t *handle)
| SDMA stops transfer. More...
void | SDMA_AbortTransfer (sdma_handle_t *handle)
| SDMA aborts transfer. More...
uint32_t | SDMA_GetTransferredBytes (sdma_handle_t *handle)
| Get transferred bytes while not using BD pools. More...
bool | SDMA_IsPeripheralInSPBA (uint32_t addr)
| Judge if address located in SPBA. More...
void | SDMA_HandleIRQ (sdma_handle_t *handle)
| SDMA IRQ handler for complete a buffer descriptor transfer. More...

## Data Structure Documentation

struct sdma_config_t

### Data Fields
bool | enableRealTimeDebugPin
| If enable real-time debug pin, default is closed to reduce power consumption. More...
bool | isSoftwareResetClearLock
| If software reset clears the LOCK bit which prevent writing SDMA scripts into SDMA. More...
sdma_clock_ratio_t | ratio
| SDMA core clock ratio to ARM platform DMA interface.

#### Field Documentation

bool sdma_config_t::enableRealTimeDebugPin

bool sdma_config_t::isSoftwareResetClearLock

struct sdma_multi_fifo_config_t

### Data Fields
uint8_t | fifoNums
| fifo numbers
uint8_t | fifoOffset
| offset between multi fifo data register address

struct sdma_sw_done_config_t

### Data Fields
bool | enableSwDone
| true is enable sw done, false is disable
uint8_t | swDoneSel
| sw done channel number per peripheral type

struct sdma_p2p_config_t

### Data Fields
uint8_t | sourceWatermark
| lower watermark value
uint8_t | destWatermark
| higher water makr value
bool | continuousTransfer
| 0: the amount of samples to be transferred is equal to the cont field of mode word 1: the amount of samples to be transferred is unknown and script will keep on transferring as long as both events are detected and script must be stopped by application. More...

#### Field Documentation

bool sdma_p2p_config_t::continuousTransfer

struct sdma_transfer_config_t

This structure configures the source/destination transfer attribute.

### Data Fields
uint32_t | srcAddr
| Source address of the transfer.
uint32_t | destAddr
| Destination address of the transfer.
sdma_transfer_size_t | srcTransferSize
| Source data transfer size. More...
sdma_transfer_size_t | destTransferSize
| Destination data transfer size. More...
uint32_t | bytesPerRequest
| Bytes to transfer in a minor loop.
uint32_t | transferSzie
| Bytes to transfer for this descriptor.
uint32_t | scriptAddr
| SDMA script address located in SDMA ROM. More...
uint32_t | eventSource
| Event source number for the channel. More...
uint32_t | eventSource1
| event source 1
bool | isEventIgnore
| True means software trigger, false means hardware trigger.
bool | isSoftTriggerIgnore
| If ignore the HE bit, 1 means use hardware events trigger, 0 means software trigger.
sdma_transfer_type_t | type
| Transfer type, transfer type used to decide the SDMA script. More...
sdma_multi_fifo_config_t | multiFifo
| multi fifo configurations
sdma_sw_done_config_t | swDone
| sw done selector
uint32_t | watermarkLevel
| watermark level
uint32_t | eventMask0
| event mask 0
uint32_t | eventMask1
| event mask 1

#### Field Documentation

sdma_transfer_size_t sdma_transfer_config_t::srcTransferSize

sdma_transfer_size_t sdma_transfer_config_t::destTransferSize

uint32_t sdma_transfer_config_t::scriptAddr

uint32_t sdma_transfer_config_t::eventSource

0 means no event, use software trigger

sdma_transfer_type_t sdma_transfer_config_t::type

struct sdma_buffer_descriptor_t

This structure is a buffer descriptor, this structure describes the buffer start address and other options

### Data Fields
uint32_t | count: 16
| Bytes of the buffer length for this buffer descriptor. More...
uint32_t | status: 8
| E,R,I,C,W,D status bits stored here.
uint32_t | command: 8
| command mostlky used for channel 0
uint32_t | bufferAddr
| Buffer start address for this descriptor. More...
uint32_t | extendBufferAddr
| External buffer start address, this is an optional for a transfer. More...

#### Field Documentation

uint32_t sdma_buffer_descriptor_t::count

uint32_t sdma_buffer_descriptor_t::bufferAddr

uint32_t sdma_buffer_descriptor_t::extendBufferAddr

struct sdma_channel_control_t

### Data Fields
uint32_t | currentBDAddr
| Address of current buffer descriptor processed.
uint32_t | baseBDAddr
| The start address of the buffer descriptor array.
uint32_t | channelDesc
| Optional for transfer.
uint32_t | status
| Channel status.

struct sdma_context_data_t

This structure can be load into SDMA core, with this structure, SDMA scripts can start work.

### Data Fields
uint32_t | GeneralReg [8]
| 8 general regsiters used for SDMA RISC core

struct sdma_handle_t

### Data Fields
sdma_callback | callback
| Callback function for major count exhausted. More...
void * | userData
| Callback function parameter. More...
SDMAARM_Type * | base
| SDMA peripheral base address. More...
sdma_buffer_descriptor_t * | BDPool
| Pointer to memory stored BD arrays. More...
uint32_t | bdCount
| How many buffer descriptor.
uint32_t | bdIndex
| How many buffer descriptor.
uint32_t | eventSource
| Event source count for the channel.
uint32_t | eventSource1
| Event source 1 count for the channel.
sdma_context_data_t * | context
| Channel context to exectute in SDMA.
uint8_t | channel
| SDMA channel number. More...
uint8_t | priority
| SDMA channel priority.
uint8_t | flags
| The status of the current channel. More...

#### Field Documentation

sdma_callback sdma_handle_t::callback

void* sdma_handle_t::userData

SDMAARM_Type* sdma_handle_t::base

sdma_buffer_descriptor_t* sdma_handle_t::BDPool

uint8_t sdma_handle_t::channel

uint8_t sdma_handle_t::flags

## Macro Definition Documentation

#define FSL_SDMA_DRIVER_VERSION (MAKE_VERSION(2, 3, 6))

Version 2.3.6.

## Typedef Documentation

typedef void(* sdma_callback)(struct _sdma_handle *handle, void *userData, bool transferDone, uint32_t bdIndex)

## Enumeration Type Documentation

enum sdma_transfer_size_t

Enumerator
kSDMA_TransferSize1Bytes | Source/Destination data transfer size is 1 byte every time.
kSDMA_TransferSize2Bytes | Source/Destination data transfer size is 2 bytes every time.
kSDMA_TransferSize3Bytes | Source/Destination data transfer size is 3 bytes every time.
kSDMA_TransferSize4Bytes | Source/Destination data transfer size is 4 bytes every time.

enum sdma_bd_status_t

Enumerator
kSDMA_BDStatusDone | BD ownership, 0 means ARM core owns the BD, while 1 means SDMA owns BD.
kSDMA_BDStatusWrap | While this BD is last one, the next BD will be the first one.
kSDMA_BDStatusContinuous | Buffer is allowed to transfer/receive to/from multiple buffers.
kSDMA_BDStatusInterrupt | While this BD finished, send an interrupt.
kSDMA_BDStatusError | Error occurred on buffer descriptor command.
kSDMA_BDStatusLast | This BD is the last BD in this array. It means the transfer ended after this buffer
kSDMA_BDStatusExtend | Buffer descriptor extend status for SDMA scripts.

enum sdma_bd_command_t

Enumerator
kSDMA_BDCommandSETDM | Load SDMA data memory from ARM core memory buffer.
kSDMA_BDCommandGETDM | Copy SDMA data memory to ARM core memory buffer.
kSDMA_BDCommandSETPM | Load SDMA program memory from ARM core memory buffer.
kSDMA_BDCommandGETPM | Copy SDMA program memory to ARM core memory buffer.
kSDMA_BDCommandSETCTX | Load context for one channel into SDMA RAM from ARM platform memory buffer.
kSDMA_BDCommandGETCTX | Copy context for one channel from SDMA RAM to ARM platform memory buffer.

enum sdma_context_switch_mode_t

Enumerator
kSDMA_ContextSwitchModeStatic | SDMA context switch mode static.
kSDMA_ContextSwitchModeDynamicLowPower | SDMA context switch mode dynamic with low power.
kSDMA_ContextSwitchModeDynamicWithNoLoop | SDMA context switch mode dynamic with no loop.
kSDMA_ContextSwitchModeDynamic | SDMA context switch mode dynamic.

enum sdma_clock_ratio_t

Enumerator
kSDMA_HalfARMClockFreq | SDMA core clock frequency half of ARM platform.
kSDMA_ARMClockFreq | SDMA core clock frequency equals to ARM platform.

enum sdma_transfer_type_t

Enumerator
kSDMA_MemoryToMemory | Transfer from memory to memory.
kSDMA_PeripheralToMemory | Transfer from peripheral to memory.
kSDMA_MemoryToPeripheral | Transfer from memory to peripheral.
kSDMA_PeripheralToPeripheral | Transfer from peripheral to peripheral.

enum sdma_peripheral_t

Enumerator
kSDMA_PeripheralTypeMemory | Peripheral DDR memory.
kSDMA_PeripheralTypeUART | UART use SDMA.
kSDMA_PeripheralTypeUART_SP | UART instance in SPBA use SDMA.
kSDMA_PeripheralTypeSPDIF | SPDIF use SDMA.
kSDMA_PeripheralNormal | Normal peripheral use SDMA.
kSDMA_PeripheralNormal_SP | Normal peripheral in SPBA use SDMA.
kSDMA_PeripheralMultiFifoPDM | multi fifo PDM
kSDMA_PeripheralMultiFifoSaiRX | multi fifo sai rx use SDMA
kSDMA_PeripheralMultiFifoSaiTX | multi fifo sai tx use SDMA
kSDMA_PeripheralASRCM2P | asrc m2p
kSDMA_PeripheralASRCP2M | asrc p2m
kSDMA_PeripheralASRCP2P | asrc p2p

anonymous enum

Enumerator
kStatus_SDMA_ERROR | SDMA context error.
kStatus_SDMA_Busy | Channel is busy and can't handle the transfer request.

anonymous enum

Enumerator
kSDMA_MultiFifoWatermarkLevelMask | multi fifo watermark level mask
kSDMA_MultiFifoNumsMask | multi fifo nums mask
kSDMA_MultiFifoOffsetMask | multi fifo offset mask
kSDMA_MultiFifoSwDoneMask | multi fifo sw done mask
kSDMA_MultiFifoSwDoneSelectorMask | multi fifo sw done selector mask

anonymous enum

Enumerator
kSDMA_MultiFifoWatermarkLevelShift | multi fifo watermark level shift
kSDMA_MultiFifoNumsShift | multi fifo nums shift
kSDMA_MultiFifoOffsetShift | multi fifo offset shift
kSDMA_MultiFifoSwDoneShift | multi fifo sw done shift
kSDMA_MultiFifoSwDoneSelectorShift | multi fifo sw done selector shift

anonymous enum

Enumerator
kSDMA_DoneChannel0 | SDMA done channel 0.
kSDMA_DoneChannel1 | SDMA done channel 1.
kSDMA_DoneChannel2 | SDMA done channel 2.
kSDMA_DoneChannel3 | SDMA done channel 3.
kSDMA_DoneChannel4 | SDMA done channel 4.
kSDMA_DoneChannel5 | SDMA done channel 5.
kSDMA_DoneChannel6 | SDMA done channel 6.
kSDMA_DoneChannel7 | SDMA done channel 7.

enum sdma_done_src_t

Enumerator
kSDMA_DoneSrcSW | software done
kSDMA_DoneSrcHwEvent0U | HW event 0 is used for DONE event.
kSDMA_DoneSrcHwEvent1U | HW event 1 is used for DONE event.
kSDMA_DoneSrcHwEvent2U | HW event 2 is used for DONE event.
kSDMA_DoneSrcHwEvent3U | HW event 3 is used for DONE event.
kSDMA_DoneSrcHwEvent4U | HW event 4 is used for DONE event.
kSDMA_DoneSrcHwEvent5U | HW event 5 is used for DONE event.
kSDMA_DoneSrCHwEvent6U | HW event 6 is used for DONE event.
kSDMA_DoneSrcHwEvent7U | HW event 7 is used for DONE event.
kSDMA_DoneSrcHwEvent8U | HW event 8 is used for DONE event.
kSDMA_DoneSrcHwEvent9U | HW event 9 is used for DONE event.
kSDMA_DoneSrcHwEvent10U | HW event 10 is used for DONE event.
kSDMA_DoneSrcHwEvent11U | HW event 11 is used for DONE event.
kSDMA_DoneSrcHwEvent12U | HW event 12 is used for DONE event.
kSDMA_DoneSrcHwEvent13U | HW event 13 is used for DONE event.
kSDMA_DoneSrcHwEvent14U | HW event 14 is used for DONE event.
kSDMA_DoneSrcHwEvent15U | HW event 15 is used for DONE event.
kSDMA_DoneSrcHwEvent16U | HW event 16 is used for DONE event.
kSDMA_DoneSrcHwEvent17U | HW event 17 is used for DONE event.
kSDMA_DoneSrcHwEvent18U | HW event 18 is used for DONE event.
kSDMA_DoneSrcHwEvent19U | HW event 19 is used for DONE event.
kSDMA_DoneSrcHwEvent20U | HW event 20 is used for DONE event.
kSDMA_DoneSrcHwEvent21U | HW event 21 is used for DONE event.
kSDMA_DoneSrcHwEvent22U | HW event 22 is used for DONE event.
kSDMA_DoneSrcHwEvent23U | HW event 23 is used for DONE event.
kSDMA_DoneSrcHwEvent24U | HW event 24 is used for DONE event.
kSDMA_DoneSrcHwEvent25U | HW event 25 is used for DONE event.
kSDMA_DoneSrcHwEvent26U | HW event 26 is used for DONE event.
kSDMA_DoneSrcHwEvent27U | HW event 27 is used for DONE event.
kSDMA_DoneSrcHwEvent28U | HW event 28 is used for DONE event.
kSDMA_DoneSrcHwEvent29U | HW event 29 is used for DONE event.
kSDMA_DoneSrcHwEvent30U | HW event 30 is used for DONE event.
kSDMA_DoneSrcHwEvent31U | HW event 31 is used for DONE event.

## Function Documentation

void SDMA_Init | ( | SDMAARM_Type * | base,
|  | const sdma_config_t * | config
| ) |  |

This function ungates the SDMA clock and configures the SDMA peripheral according to the configuration structure.

Parameters

  base | SDMA peripheral base address.
  config | A pointer to the configuration structure, see "sdma_config_t".

Note
  This function enables the minor loop map feature.

void SDMA_Deinit | ( | SDMAARM_Type * | base | ) |

This function gates the SDMA clock.

Parameters

  base | SDMA peripheral base address.

void SDMA_GetDefaultConfig | ( | sdma_config_t * | config | ) |

This function sets the configuration structure to default values. The default configuration is set to the following values.

* config.enableRealTimeDebugPin = false;
* config.isSoftwareResetClearLock = true;
* config.ratio = kSDMA_HalfARMClockFreq;
*

Parameters

  config | A pointer to the SDMA configuration structure.

void SDMA_ResetModule | ( | SDMAARM_Type * | base | ) |

If only reset ARM core, SDMA register cannot return to reset value, shall call this function to reset all SDMA register to reset value. But the internal status cannot be reset.

Parameters

  base | SDMA peripheral base address.

static void SDMA_EnableChannelErrorInterrupts | ( | SDMAARM_Type * | base,
|  | uint32_t | channel
| ) |  |
| inlinestatic

Enable this will trigger an interrupt while SDMA occurs error while executing scripts.

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.

static void SDMA_DisableChannelErrorInterrupts | ( | SDMAARM_Type * | base,
|  | uint32_t | channel
| ) |  |
| inlinestatic

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.

void SDMA_ConfigBufferDescriptor | ( | sdma_buffer_descriptor_t * | bd,
|  | uint32_t | srcAddr,
|  | uint32_t | destAddr,
|  | sdma_transfer_size_t | busWidth,
|  | size_t | bufferSize,
|  | bool | isLast,
|  | bool | enableInterrupt,
|  | bool | isWrap,
|  | sdma_transfer_type_t | type
| ) |  |

This function sets the descriptor contents such as source, dest address and status bits.

Parameters

  bd | Pointer to the buffer descriptor structure.
  srcAddr | Source address for the buffer descriptor.
  destAddr | Destination address for the buffer descriptor.
  busWidth | The transfer width, it only can be a member of sdma_transfer_size_t.
  bufferSize | Buffer size for this descriptor, this number shall less than 0xFFFF. If need to transfer a big size, shall divide into several buffer descriptors.
  isLast | Is the buffer descriptor the last one for the channel to transfer. If only one descriptor used for the channel, this bit shall set to TRUE.
  enableInterrupt | If trigger an interrupt while this buffer descriptor transfer finished.
  isWrap | Is the buffer descriptor need to be wrapped. While this bit set to true, it will automatically wrap to the first buffer descrtiptor to do transfer.
  type | Transfer type, memory to memory, peripheral to memory or memory to peripheral.

static void SDMA_SetChannelPriority | ( | SDMAARM_Type * | base,
|  | uint32_t | channel,
|  | uint8_t | priority
| ) |  |
| inlinestatic

This function sets the channel priority. The default value is 0 for all channels, priority 0 will prevents channel from starting, so the priority must be set before start a channel.

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.
  priority | SDMA channel priority.

static void SDMA_SetSourceChannel | ( | SDMAARM_Type * | base,
|  | uint32_t | source,
|  | uint32_t | channelMask
| ) |  |
| inlinestatic

This function sets which channel will be triggered by the dma request source.

Parameters

  base | SDMA peripheral base address.
  source | SDMA dma request source number.
  channelMask | SDMA channel mask. 1 means channel 0, 2 means channel 1, 4 means channel 3. SDMA supports an event trigger multi-channel. A channel can also be triggered by several source events.

static void SDMA_StartChannelSoftware | ( | SDMAARM_Type * | base,
|  | uint32_t | channel
| ) |  |
| inlinestatic

This function start a channel.

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.

static void SDMA_StartChannelEvents | ( | SDMAARM_Type * | base,
|  | uint32_t | channel
| ) |  |
| inlinestatic

This function start a channel.

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.

static void SDMA_StopChannel | ( | SDMAARM_Type * | base,
|  | uint32_t | channel
| ) |  |
| inlinestatic

This function stops a channel.

Parameters

  base | SDMA peripheral base address.
  channel | SDMA channel number.

void SDMA_SetContextSwitchMode | ( | SDMAARM_Type * | base,
|  | sdma_context_switch_mode_t | mode
| ) |  |

Parameters

  base | SDMA peripheral base address.
  mode | SDMA context switch mode.

static uint32_t SDMA_GetChannelInterruptStatus | ( | SDMAARM_Type * | base | ) |
| inlinestatic

Parameters

  base | SDMA peripheral base address.

Returns
  The interrupt status for all channels. Check the relevant bits for specific channel.

static void SDMA_ClearChannelInterruptStatus | ( | SDMAARM_Type * | base,
|  | uint32_t | mask
| ) |  |
| inlinestatic

Parameters

  base | SDMA peripheral base address.
  mask | The interrupt status need to be cleared.

static uint32_t SDMA_GetChannelStopStatus | ( | SDMAARM_Type * | base | ) |
| inlinestatic

Parameters

  base | SDMA peripheral base address.

Returns
  The stop status for all channels. Check the relevant bits for specific channel.

static void SDMA_ClearChannelStopStatus | ( | SDMAARM_Type * | base,
|  | uint32_t | mask
| ) |  |
| inlinestatic

Parameters

  base | SDMA peripheral base address.
  mask | The stop status need to be cleared.

static uint32_t SDMA_GetChannelPendStatus | ( | SDMAARM_Type * | base | ) |
| inlinestatic

Parameters

  base | SDMA peripheral base address.

Returns
  The pending status for all channels. Check the relevant bits for specific channel.

static void SDMA_ClearChannelPendStatus | ( | SDMAARM_Type * | base,
|  | uint32_t | mask
| ) |  |
| inlinestatic

Parameters

  base | SDMA peripheral base address.
  mask | The pending status need to be cleared.

static uint32_t SDMA_GetErrorStatus | ( | SDMAARM_Type * | base | ) |
| inlinestatic

SDMA channel error flag is asserted while an incoming DMA request was detected and it triggers a channel that is already pending or being serviced. This probably means there is an overflow of data for that channel.

Parameters

  base | SDMA peripheral base address.

Returns
  The error status for all channels. Check the relevant bits for specific channel.

bool SDMA_GetRequestSourceStatus | ( | SDMAARM_Type * | base,
|  | uint32_t | source
| ) |  |

Parameters

  base | SDMA peripheral base address.
  source | DMA request source number.

Returns
  True means the request source is pending, otherwise not pending.

void SDMA_CreateHandle | ( | sdma_handle_t * | handle,
|  | SDMAARM_Type * | base,
|  | uint32_t | channel,
|  | sdma_context_data_t * | context
| ) |  |

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

Parameters

  handle | SDMA handle pointer. The SDMA handle stores callback function and parameters.
  base | SDMA peripheral base address.
  channel | SDMA channel number.
  context | Context structure for the channel to download into SDMA. Users shall make sure the context located in a non-cacheable memory, or it will cause SDMA run fail. Users shall not touch the context contents, it only be filled by SDMA driver in SDMA_SubmitTransfer function.

void SDMA_InstallBDMemory | ( | sdma_handle_t * | handle,
|  | sdma_buffer_descriptor_t * | BDPool,
|  | uint32_t | BDCount
| ) |  |

This function is called after the SDMA_CreateHandle to use multi-buffer feature.

Parameters

  handle | SDMA handle pointer.
  BDPool | A memory pool to store BDs. It must be located in non-cacheable address.
  BDCount | The number of BD slots.

void SDMA_SetCallback | ( | sdma_handle_t * | handle,
|  | sdma_callback | callback,
|  | void * | userData
| ) |  |

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

Parameters

  handle | SDMA handle pointer.
  callback | SDMA callback function pointer.
  userData | A parameter for the callback function.

void SDMA_SetMultiFifoConfig | ( | sdma_transfer_config_t * | config,
|  | uint32_t | fifoNums,
|  | uint32_t | fifoOffset
| ) |  |

This api is used to support multi fifo for SDMA, if user want to get multi fifo data, then this api shoule be called before submit transfer.

Parameters

  config | transfer configurations.
  fifoNums | fifo numbers that multi fifo operation perform, support up to 15 fifo numbers.
  fifoOffset | fifoOffset = fifo address offset / sizeof(uint32_t) - 1.

void SDMA_EnableSwDone | ( | SDMAARM_Type * | base,
|  | sdma_transfer_config_t * | config,
|  | uint8_t | sel,
|  | sdma_peripheral_t | type
| ) |  |

Deprecated:
  Do not use this function. It has been superceded by SDMA_SetDoneConfig.

Parameters

  base | SDMA base.
  config | transfer configurations.
  sel | sw done selector.
  type | peripheral type is used to determine the corresponding peripheral sw done selector bit.

void SDMA_SetDoneConfig | ( | SDMAARM_Type * | base,
|  | sdma_transfer_config_t * | config,
|  | sdma_peripheral_t | type,
|  | sdma_done_src_t | doneSrc
| ) |  |

Parameters

  base | SDMA base.
  config | transfer configurations.
  type | peripheral type.
  doneSrc | reference sdma_done_src_t.

void SDMA_LoadScript | ( | SDMAARM_Type * | base,
|  | uint32_t | destAddr,
|  | void * | srcAddr,
|  | size_t | bufferSizeBytes
| ) |  |

Parameters

  base | SDMA base.
  destAddr | dest script address, should be SDMA program memory address.
  srcAddr | source address of target script.
  bufferSizeBytes | bytes size of script.

void SDMA_DumpScript | ( | SDMAARM_Type * | base,
|  | uint32_t | srcAddr,
|  | void * | destAddr,
|  | size_t | bufferSizeBytes
| ) |  |

Parameters

  base | SDMA base.
  srcAddr | should be SDMA program memory address.
  destAddr | address to store scripts.
  bufferSizeBytes | bytes size of script.

void SDMA_PrepareTransfer | ( | sdma_transfer_config_t * | config,
|  | uint32_t | srcAddr,
|  | uint32_t | destAddr,
|  | uint32_t | srcWidth,
|  | uint32_t | destWidth,
|  | uint32_t | bytesEachRequest,
|  | uint32_t | transferSize,
|  | uint32_t | eventSource,
|  | sdma_peripheral_t | peripheral,
|  | sdma_transfer_type_t | type
| ) |  |

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

Parameters

  config | The user configuration structure of type sdma_transfer_t.
  srcAddr | SDMA transfer source address.
  destAddr | SDMA transfer destination address.
  srcWidth | SDMA transfer source address width(bytes).
  destWidth | SDMA transfer destination address width(bytes).
  bytesEachRequest | SDMA transfer bytes per channel request.
  transferSize | SDMA transfer bytes to be transferred.
  eventSource | Event source number for the transfer, if use software trigger, just write 0.
  peripheral | Peripheral type, used to decide if need to use some special scripts.
  type | SDMA transfer type. Used to decide the correct SDMA script address in SDMA ROM.

Note
  The data address and the data width must be consistent. For example, if the SRC is 4 bytes, the source address must be 4 bytes aligned, or it results in source address error.

void SDMA_PrepareP2PTransfer | ( | sdma_transfer_config_t * | config,
|  | uint32_t | srcAddr,
|  | uint32_t | destAddr,
|  | uint32_t | srcWidth,
|  | uint32_t | destWidth,
|  | uint32_t | bytesEachRequest,
|  | uint32_t | transferSize,
|  | uint32_t | eventSource,
|  | uint32_t | eventSource1,
|  | sdma_peripheral_t | peripheral,
|  | sdma_p2p_config_t * | p2p
| ) |  |

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

Parameters

  config | The user configuration structure of type sdma_transfer_t.
  srcAddr | SDMA transfer source address.
  destAddr | SDMA transfer destination address.
  srcWidth | SDMA transfer source address width(bytes).
  destWidth | SDMA transfer destination address width(bytes).
  bytesEachRequest | SDMA transfer bytes per channel request.
  transferSize | SDMA transfer bytes to be transferred.
  eventSource | Event source number for the transfer.
  eventSource1 | Event source1 number for the transfer.
  peripheral | Peripheral type, used to decide if need to use some special scripts.
  p2p | sdma p2p configuration pointer.

Note
  The data address and the data width must be consistent. For example, if the SRC is 4 bytes, the source address must be 4 bytes aligned, or it results in source address error.

void SDMA_SubmitTransfer | ( | sdma_handle_t * | handle,
|  | const sdma_transfer_config_t * | config
| ) |  |

This function submits the SDMA transfer request according to the transfer configuration structure.

Parameters

  handle | SDMA handle pointer.
  config | Pointer to SDMA transfer configuration structure.

void SDMA_StartTransfer | ( | sdma_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

  handle | SDMA handle pointer.

void SDMA_StopTransfer | ( | sdma_handle_t * | handle | ) |

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

Parameters

  handle | SDMA handle pointer.

void SDMA_AbortTransfer | ( | sdma_handle_t * | handle | ) |

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

Parameters

  handle | DMA handle pointer.

uint32_t SDMA_GetTransferredBytes | ( | sdma_handle_t * | handle | ) |

This function returns the buffer descriptor count value if not using buffer descriptor. While do a simple transfer, which only uses one descriptor, the SDMA driver inside handle the buffer descriptor. In uart receive case, it can tell users how many data already received, also it can tells users how many data transfferd while error occurred. Notice, the count would not change while transfer is on-going using default SDMA script.

Parameters

  handle | DMA handle pointer.

Returns
  Transferred bytes.

bool SDMA_IsPeripheralInSPBA | ( | uint32_t | addr | ) |

Parameters

  addr | Address which need to judge.

Return values

  True | means located in SPBA, false means not.

void SDMA_HandleIRQ | ( | sdma_handle_t * | handle | ) |

This function clears the interrupt flags and also handle the CCB for the channel.

Parameters

  handle | SDMA handle pointer.