DMADRV - DMA Driver#

Direct Memory Access Driver.


Introduction#

The DMADRV driver supports writing code using DMA which will work regardless of the type of the DMA controller on the underlying microcontroller. Additionally, DMA can be used in several modules that are completely unaware of each other. The driver does not preclude use of the native emlib or peripheral API of the underlying DMA controller. On the contrary, it will often result in more efficient code and is necessary for complex DMA operations. The housekeeping functions of this driver are valuable even in this use-case.

The dmadrv.c and dmadrv.h source files are in the emdrv/dmadrv folder.

Note

  • DMA transfer completion callback functions are called from within the DMA interrupt handler. On versions of the DMA controller with one interrupt per channel, the callback function is called from its respective channel interrupt handler.


Configuration Options#

Some properties of the DMADRV driver are compile-time configurable. These properties are stored in a file named dmadrv_config.h. A template for this file, containing default values, is in the emdrv/config folder. IC specific versions of dmadrv_config.h files are available in config/sx_xch directories. Currently the configuration options are as follows:

  • The interrupt priority of the DMA peripheral.

  • A number of DMA channels to support.

  • Use the native emlib/peripheral API belonging to the underlying DMA hardware in combination with the DMADRV API.

Both configuration options will help reduce the driver's RAM footprint.

To configure DMADRV, provide a custom configuration file. This is an example dmadrv_config.h file:

#ifndef __SILICON_LABS_DMADRV_CONFIG_H__
#define __SILICON_LABS_DMADRV_CONFIG_H__

  // DMADRV DMA interrupt priority configuration option.
  // Set DMA interrupt priority. Range is 0..7, 0 is the highest priority.
#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 4

  // DMADRV channel count configuration option.
  // A number of DMA channels to support. A lower DMA channel count will reduce
  // RAM footprint.
#define EMDRV_DMADRV_DMA_CH_COUNT 4

#endif


The API#

This section contains brief descriptions of the API functions. For more information about input and output parameters and return values, click on the hyperlinked function names. Most functions return an error code, ECODE_EMDRV_DMADRV_OK is returned on success, see ECODE - Error Codes and Error Codes for other error codes.

The application code must include dmadrv.h header file.

DMADRV_Init(), DMADRV_DeInit()
These functions initialize or deinitialize the DMADRV driver. Typically, DMADRV_Init() is called once in the startup code.

DMADRV_AllocateChannel(), DMADRV_AllocateChannelById(), DMADRV_FreeChannel()
DMA channel reserve and release functions. It is recommended that application code checks that DMADRV_AllocateChannel() returns ECODE_EMDRV_DMADRV_OK before starting a DMA transfer.

DMADRV_MemoryPeripheral()
Start a DMA transfer from memory to a peripheral.

DMADRV_PeripheralMemory()
Start a DMA transfer from a peripheral to memory.

DMADRV_MemoryPeripheralPingPong()
Start a DMA ping-pong transfer from memory to a peripheral.

DMADRV_PeripheralMemoryPingPong()
Start a DMA ping-pong transfer from a peripheral to memory.

DMADRV_LdmaStartTransfer()
Start a DMA transfer on an LDMA controller.

DMADRV_PauseTransfer()
Pause an ongoing DMA transfer.

DMADRV_ResumeTransfer()
Resume paused DMA transfer.

DMADRV_StopTransfer()
Stop an ongoing DMA transfer.

DMADRV_TransferActive()
Check if a transfer is ongoing.

DMADRV_TransferCompletePending()
Check if a transfer completion is pending.

DMADRV_TransferDone()
Check if a transfer has completed.

DMADRV_TransferRemainingCount()
Get number of items remaining in a transfer.


Example#

Transfer a text string to USART1.

#include "dmadrv.h"

  char str[] = "Hello DMA !";
  unsigned int channel;

  int main( void )
  {
  // Initialize DMA.
  DMADRV_Init();

  // Request a DMA channel.
  DMADRV_AllocateChannel( &channel, NULL );

  // Start the DMA transfer.
  DMADRV_MemoryPeripheral( channel,
                          dmadrvPeripheralSignal_USART1_TXBL,
                          (void*)&(USART1->TXDATA),
                          str,
                          true,
                          sizeof( str ),
                          dmadrvDataSize1,
                          NULL,
                          NULL );

  return 0;
  }

Warnings

  • This API is deprecated. For new designs, use the DMA Channel Driver (DMA Channel Driver) and the DMA Manager service (dma_manager).

The DMA driver is used to configure and control the DMA and LDMA peripherals to perform data transfers between memory regions and/or peripherals. It also provides central management of DMA channels and the interrupt vector so that DMA resources could be shared between several users.

These responsibilities are now split between two newer components:

  • The dma_manager service owns DMA peripheral initialization, channel/sync-bit allocation, channel prioritization and IRQ dispatch.

  • The DMA Channel Driver driver provides the per-channel transfer submission, queuing, ping-pong / triple-buffered transfers and completion notifications.

For the full API mapping table and step-by-step migration instructions, refer to the DMADRV Migration Guide.

Coexistence with DMA Manager and DMA Channel Driver#

DMADRV is fully compatible with the dma_manager service and the DMA Channel Driver driver: an application may keep using DMADRV on some channels while the new components drive other channels in the same application. This is the recommended path for incremental migration.

Be aware that linking both stacks pulls in two largely overlapping DMA implementations, so coexistence comes at a measurable code-size cost. Once migration is complete, remove the DMADRV component to recover the footprint.

Note

  • To keep a project building cleanly with -Werror while migration is still in progress, the deprecation warnings emitted for the DMADRV API can be suppressed by defining SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_2026_6 at the project or translation-unit level. This affects only warnings introduced by this deprecation cycle, and is intended as a temporary measure; the DMADRV API will be removed in a future major release.

Modules#

Error Codes

Typedefs#

typedef bool(*
DMADRV_Callback_t)(unsigned int channel, unsigned int sequenceNo, void *userParam)

DMADRV transfer completion callback function.

Functions#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_AllocateChannel(unsigned int *channelId, void *capabilities)

Allocate (reserve) a DMA channel.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_AllocateChannelById(unsigned int channelId, void *capabilities)

Allocate (reserve) the given DMA channel if it is free.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t

Deinitialize DMADRV.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_FreeChannel(unsigned int channelId)

Free an allocated (reserved) DMA channel.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t

Initialize DMADRV.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_MemoryPeripheral(unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void *dst, void *src, bool srcInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void *cbUserParam)

Start a memory to a peripheral DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_PeripheralMemory(unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void *dst, void *src, bool dstInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void *cbUserParam)

Start a peripheral to memory DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_MemoryPeripheralPingPong(unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void *dst, void *src0, void *src1, bool srcInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void *cbUserParam)

Start a memory to a peripheral ping-pong DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_PeripheralMemoryPingPong(unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void *dst0, void *dst1, void *src, bool dstInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void *cbUserParam)

Start a peripheral to memory ping-pong DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_LdmaStartTransfer(int channelId, LDMA_TransferCfg_t *transfer, LDMA_Descriptor_t *descriptor, DMADRV_Callback_t callback, void *cbUserParam)

Start an LDMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_PauseTransfer(unsigned int channelId)

Pause an ongoing DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_ResumeTransfer(unsigned int channelId)

Resume an ongoing DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_StopTransfer(unsigned int channelId)

Stop an ongoing DMA transfer.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_TransferActive(unsigned int channelId, bool *active)

Check if a transfer is running.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_TransferCompletePending(unsigned int channelId, bool *pending)

Check if a transfer complete is pending.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_TransferDone(unsigned int channelId, bool *done)

Check if a transfer has completed.

SL_DEPRECATED_API_SDK_2026_6 Ecode_t
DMADRV_TransferRemainingCount(unsigned int channelId, int *remaining)

Get number of items remaining in a transfer.

Typedef Documentation#

DMADRV_Callback_t#

typedef bool(* DMADRV_Callback_t) (unsigned int channel, unsigned int sequenceNo, void *userParam) )(unsigned int channel, unsigned int sequenceNo, void *userParam)

DMADRV transfer completion callback function.

Parameters
TypeDirectionArgument NameDescription
[in]channel

The DMA channel number.

[in]sequenceNo

The number of times the callback was called. Useful on long chains of linked transfers or on endless ping-pong type transfers.

[in]userParam

Optional user parameter supplied on DMA invocation.

The callback function is called when a transfer is complete.

Returns

  • When doing ping-pong transfers, return true to continue or false to stop transfers.


Function Documentation#

DMADRV_AllocateChannel#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_AllocateChannel (unsigned int * channelId, void * capabilities)

Allocate (reserve) a DMA channel.

Parameters
TypeDirectionArgument NameDescription
unsigned int *[out]channelId

The channel ID assigned by DMADRV.

void *[in]capabilities

Not used.

Returns


DMADRV_AllocateChannelById#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_AllocateChannelById (unsigned int channelId, void * capabilities)

Allocate (reserve) the given DMA channel if it is free.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to be assigned by DMADRV.

void *[in]capabilities

Not used.

Returns


DMADRV_DeInit#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_DeInit (void )

Deinitialize DMADRV.

Parameters
TypeDirectionArgument NameDescription
voidN/A

If DMA channels are not currently allocated, it will disable DMA hardware and mask associated interrupts.

Returns


DMADRV_FreeChannel#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_FreeChannel (unsigned int channelId)

Free an allocated (reserved) DMA channel.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to free.

Returns


DMADRV_Init#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_Init (void )

Initialize DMADRV.

Parameters
TypeDirectionArgument NameDescription
voidN/A

The DMA hardware is initialized.

Returns


DMADRV_MemoryPeripheral#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_MemoryPeripheral (unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void * dst, void * src, bool srcInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void * cbUserParam)

Start a memory to a peripheral DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to use for the transfer.

DMADRV_PeripheralSignal_t[in]peripheralSignal

Selects which peripheral/peripheralsignal to use.

void *[in]dst

A destination (peripheral register) memory address.

void *[in]src

A source memory address.

bool[in]srcInc

Set to true to enable source address increment (increments according to size parameter).

int[in]len

A number of items (of size size) to transfer.

DMADRV_DataSize_t[in]size

An item size, byte, halfword or word.

DMADRV_Callback_t[in]callback

A function to call on DMA completion, use NULL if not needed.

void *[in]cbUserParam

An optional user parameter to feed to the callback function. Use NULL if not needed.

Returns


DMADRV_PeripheralMemory#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_PeripheralMemory (unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void * dst, void * src, bool dstInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void * cbUserParam)

Start a peripheral to memory DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to use for the transfer.

DMADRV_PeripheralSignal_t[in]peripheralSignal

Selects which peripheral/peripheralsignal to use.

void *[in]dst

A destination memory address.

void *[in]src

A source memory (peripheral register) address.

bool[in]dstInc

Set to true to enable destination address increment (increments according to size parameter).

int[in]len

A number of items (of size size) to transfer.

DMADRV_DataSize_t[in]size

An item size, byte, halfword or word.

DMADRV_Callback_t[in]callback

A function to call on DMA completion, use NULL if not needed.

void *[in]cbUserParam

An optional user parameter to feed to the callback function. Use NULL if not needed.

Returns


DMADRV_MemoryPeripheralPingPong#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_MemoryPeripheralPingPong (unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void * dst, void * src0, void * src1, bool srcInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void * cbUserParam)

Start a memory to a peripheral ping-pong DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to use for the transfer.

DMADRV_PeripheralSignal_t[in]peripheralSignal

Selects which peripheral/peripheralsignal to use.

void *[in]dst

A destination (peripheral register) memory address.

void *[in]src0

A source memory address of the first (ping) buffer.

void *[in]src1

A source memory address of the second (pong) buffer.

bool[in]srcInc

Set to true to enable source address increment (increments according to size parameter).

int[in]len

A number of items (of size size) to transfer.

DMADRV_DataSize_t[in]size

An item size, byte, halfword or word.

DMADRV_Callback_t[in]callback

A function to call on DMA completion, use NULL if not needed.

void *[in]cbUserParam

An optional user parameter to feed to the callback function. Use NULL if not needed.

Returns


DMADRV_PeripheralMemoryPingPong#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_PeripheralMemoryPingPong (unsigned int channelId, DMADRV_PeripheralSignal_t peripheralSignal, void * dst0, void * dst1, void * src, bool dstInc, int len, DMADRV_DataSize_t size, DMADRV_Callback_t callback, void * cbUserParam)

Start a peripheral to memory ping-pong DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID to use for the transfer.

DMADRV_PeripheralSignal_t[in]peripheralSignal

Selects which peripheral/peripheralsignal to use.

void *[in]dst0

A destination memory address of the first (ping) buffer.

void *[in]dst1

A destination memory address of the second (pong) buffer.

void *[in]src

A source memory (peripheral register) address.

bool[in]dstInc

Set to true to enable destination address increment (increments according to size parameter).

int[in]len

A number of items (of size size) to transfer.

DMADRV_DataSize_t[in]size

An item size, byte, halfword or word.

DMADRV_Callback_t[in]callback

A function to call on DMA completion, use NULL if not needed.

void *[in]cbUserParam

An optional user parameter to feed to the callback function. Use NULL if not needed.

Returns


DMADRV_LdmaStartTransfer#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_LdmaStartTransfer (int channelId, LDMA_TransferCfg_t * transfer, LDMA_Descriptor_t * descriptor, DMADRV_Callback_t callback, void * cbUserParam)

Start an LDMA transfer.

Parameters
TypeDirectionArgument NameDescription
int[in]channelId

The channel ID to use.

LDMA_TransferCfg_t *[in]transfer

A DMA transfer configuration data structure.

LDMA_Descriptor_t *[in]descriptor

A DMA transfer descriptor, can be an array of descriptors linked together.

DMADRV_Callback_t[in]callback

An optional callback function for signalling completion. May be NULL if not needed.

void *[in]cbUserParam

An optional user parameter to feed to the callback function. May be NULL if not needed.

This function is similar to the emlib LDMA function.

Returns


DMADRV_PauseTransfer#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_PauseTransfer (unsigned int channelId)

Pause an ongoing DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to pause.

Returns


DMADRV_ResumeTransfer#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_ResumeTransfer (unsigned int channelId)

Resume an ongoing DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to resume.

Returns


DMADRV_StopTransfer#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_StopTransfer (unsigned int channelId)

Stop an ongoing DMA transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to stop.

Returns


DMADRV_TransferActive#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_TransferActive (unsigned int channelId, bool * active)

Check if a transfer is running.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to check.

bool *[out]active

True if transfer is running, false otherwise.

Returns


DMADRV_TransferCompletePending#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_TransferCompletePending (unsigned int channelId, bool * pending)

Check if a transfer complete is pending.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to check.

bool *[out]pending

True if a transfer complete is pending, false otherwise.

Will check the channel interrupt flag. This assumes that the DMA is configured to give a completion interrupt.

Returns


DMADRV_TransferDone#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_TransferDone (unsigned int channelId, bool * done)

Check if a transfer has completed.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to check.

bool *[out]done

True if a transfer has completed, false otherwise.

Note

  • This function should be used in a polled environment. Will only work reliably for transfers NOT using the completion interrupt. On UDMA, it will only work on basic transfers on the primary channel.

Returns


DMADRV_TransferRemainingCount#

SL_DEPRECATED_API_SDK_2026_6 Ecode_t DMADRV_TransferRemainingCount (unsigned int channelId, int * remaining)

Get number of items remaining in a transfer.

Parameters
TypeDirectionArgument NameDescription
unsigned int[in]channelId

The channel ID of the transfer to check.

int *[out]remaining

A number of items remaining in the transfer.

Note

  • This function does not take into account that a DMA transfer with a chain of linked transfers might be ongoing. It will only check the count for the current transfer. On UDMA, it will only work on the primary channel.

Returns