DMADRV

Detailed Description

DMADRV 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 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.


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. 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 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
// DMADRV native API configuration option.
// Use the native emlib API of the DMA controller in addition to DMADRV
// housekeeping functions, such as AllocateChannel/FreeChannel, and so on.
#define EMDRV_DMADRV_USE_NATIVE_API
#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.h and dmadrv.h 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_FreeChannel()
DMA channel reserve and release functions. It is recommended that application code check 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. This function can only be used when configuration option EMDRV_DMADRV_USE_NATIVE_API is defined. It is a wrapper similar to the emlib LDMA function, but adds support for completion callback and user-defined callback function parameter.

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.
// Request a DMA channel.
DMADRV_AllocateChannel ( &channel, NULL );
// Start the DMA transfer.
dmadrvPeripheralSignal_USART1_TXBL,
( void *)&(USART1->TXDATA),
str,
true ,
sizeof ( str ),
NULL,
NULL );
return 0;
}

Macros

#define DMADRV_MAX_XFER_COUNT ((int)((_LDMA_CH_CTRL_XFERCNT_MASK >> _LDMA_CH_CTRL_XFERCNT_SHIFT) + 1))
Maximum length of one DMA transfer.
#define ECODE_EMDRV_DMADRV_ALREADY_FREED ( ECODE_EMDRV_DMADRV_BASE | 0x00000006)
A DMA channel was free.
#define ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED ( ECODE_EMDRV_DMADRV_BASE | 0x00000003)
DMA has already been initialized.
#define ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED ( ECODE_EMDRV_DMADRV_BASE | 0x00000007)
A channel is not reserved.
#define ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED ( ECODE_EMDRV_DMADRV_BASE | 0x00000004)
No DMA channels available.
#define ECODE_EMDRV_DMADRV_IN_USE ( ECODE_EMDRV_DMADRV_BASE | 0x00000005)
DMA is in use.
#define ECODE_EMDRV_DMADRV_NOT_INITIALIZED ( ECODE_EMDRV_DMADRV_BASE | 0x00000002)
DMA is not initialized.
#define ECODE_EMDRV_DMADRV_OK ( ECODE_OK )
A successful return value.
#define ECODE_EMDRV_DMADRV_PARAM_ERROR ( ECODE_EMDRV_DMADRV_BASE | 0x00000001)
An illegal input parameter.

Typedefs

typedef bool(* DMADRV_Callback_t ) (unsigned int channel, unsigned int sequenceNo, void *userParam)
DMADRV transfer completion callback function.

Enumerations

enum DMADRV_DataSize_t {
dmadrvDataSize1 = ldmaCtrlSizeByte,
dmadrvDataSize2 = ldmaCtrlSizeHalf,
dmadrvDataSize4 = ldmaCtrlSizeWord
}
Data size of one LDMA transfer item.
enum DMADRV_PeripheralSignal_t {
dmadrvPeripheralSignal_NONE = LDMAXBAR_CH_REQSEL_SOURCESEL_NONE,
dmadrvPeripheralSignal_TIMER0_CC0 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER0CC0 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER0,
dmadrvPeripheralSignal_TIMER0_CC1 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER0CC1 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER0,
dmadrvPeripheralSignal_TIMER0_CC2 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER0CC2 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER0,
dmadrvPeripheralSignal_TIMER0_UFOF = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER0UFOF | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER0,
dmadrvPeripheralSignal_TIMER1_CC0 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER1CC0 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER1,
dmadrvPeripheralSignal_TIMER1_CC1 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER1CC1 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER1,
dmadrvPeripheralSignal_TIMER1_CC2 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER1CC2 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER1,
dmadrvPeripheralSignal_TIMER1_UFOF = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER1UFOF | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER1,
dmadrvPeripheralSignal_USART0_RXDATAV = LDMAXBAR_CH_REQSEL_SIGSEL_USART0RXDATAV | LDMAXBAR_CH_REQSEL_SOURCESEL_USART0,
dmadrvPeripheralSignal_USART0_RXDATAVRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART0RXDATAVRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART0,
dmadrvPeripheralSignal_USART0_TXBL = LDMAXBAR_CH_REQSEL_SIGSEL_USART0TXBL | LDMAXBAR_CH_REQSEL_SOURCESEL_USART0,
dmadrvPeripheralSignal_USART0_TXBLRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART0TXBLRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART0,
dmadrvPeripheralSignal_USART0_TXEMPTY = LDMAXBAR_CH_REQSEL_SIGSEL_USART0TXEMPTY | LDMAXBAR_CH_REQSEL_SOURCESEL_USART0,
dmadrvPeripheralSignal_USART1_RXDATAV = LDMAXBAR_CH_REQSEL_SIGSEL_USART1RXDATAV | LDMAXBAR_CH_REQSEL_SOURCESEL_USART1,
dmadrvPeripheralSignal_USART1_RXDATAVRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART1RXDATAVRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART1,
dmadrvPeripheralSignal_USART1_TXBL = LDMAXBAR_CH_REQSEL_SIGSEL_USART1TXBL | LDMAXBAR_CH_REQSEL_SOURCESEL_USART1,
dmadrvPeripheralSignal_USART1_TXBLRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART1TXBLRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART1,
dmadrvPeripheralSignal_USART1_TXEMPTY = LDMAXBAR_CH_REQSEL_SIGSEL_USART1TXEMPTY | LDMAXBAR_CH_REQSEL_SOURCESEL_USART1,
dmadrvPeripheralSignal_USART2_RXDATAV = LDMAXBAR_CH_REQSEL_SIGSEL_USART2RXDATAV | LDMAXBAR_CH_REQSEL_SOURCESEL_USART2,
dmadrvPeripheralSignal_USART2_RXDATAVRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART2RXDATAVRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART2,
dmadrvPeripheralSignal_USART2_TXBL = LDMAXBAR_CH_REQSEL_SIGSEL_USART2TXBL | LDMAXBAR_CH_REQSEL_SOURCESEL_USART2,
dmadrvPeripheralSignal_USART2_TXBLRIGHT = LDMAXBAR_CH_REQSEL_SIGSEL_USART2TXBLRIGHT | LDMAXBAR_CH_REQSEL_SOURCESEL_USART2,
dmadrvPeripheralSignal_USART2_TXEMPTY = LDMAXBAR_CH_REQSEL_SIGSEL_USART2TXEMPTY | LDMAXBAR_CH_REQSEL_SOURCESEL_USART2,
dmadrvPeripheralSignal_I2C0_RXDATAV = LDMAXBAR_CH_REQSEL_SIGSEL_I2C0RXDATAV | LDMAXBAR_CH_REQSEL_SOURCESEL_I2C0,
dmadrvPeripheralSignal_I2C0_TXBL = LDMAXBAR_CH_REQSEL_SIGSEL_I2C0TXBL | LDMAXBAR_CH_REQSEL_SOURCESEL_I2C0,
dmadrvPeripheralSignal_I2C1_RXDATAV = LDMAXBAR_CH_REQSEL_SIGSEL_I2C1RXDATAV | LDMAXBAR_CH_REQSEL_SOURCESEL_I2C1,
dmadrvPeripheralSignal_I2C1_TXBL = LDMAXBAR_CH_REQSEL_SIGSEL_I2C1TXBL | LDMAXBAR_CH_REQSEL_SOURCESEL_I2C1,
dmadrvPeripheralSignal_AGC_RSSI = LDMAXBAR_CH_REQSEL_SIGSEL_AGCRSSI | LDMAXBAR_CH_REQSEL_SOURCESEL_AGC,
dmadrvPeripheralSignal_PROTIMER_BOF = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERBOF | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_CC0 = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERCC0 | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_CC1 = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERCC1 | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_CC2 = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERCC2 | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_CC3 = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERCC3 | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_CC4 = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERCC4 | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_POF = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERPOF | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_PROTIMER_WOF = LDMAXBAR_CH_REQSEL_SIGSEL_PROTIMERWOF | LDMAXBAR_CH_REQSEL_SOURCESEL_PROTIMER,
dmadrvPeripheralSignal_MODEM_DEBUG = LDMAXBAR_CH_REQSEL_SIGSEL_MODEMDEBUG | LDMAXBAR_CH_REQSEL_SOURCESEL_MODEM,
dmadrvPeripheralSignal_IADC0_IADC_SCAN = LDMAXBAR_CH_REQSEL_SIGSEL_IADC0IADC_SCAN | LDMAXBAR_CH_REQSEL_SOURCESEL_IADC0,
dmadrvPeripheralSignal_IADC0_IADC_SINGLE = LDMAXBAR_CH_REQSEL_SIGSEL_IADC0IADC_SINGLE | LDMAXBAR_CH_REQSEL_SOURCESEL_IADC0,
dmadrvPeripheralSignal_TIMER2_CC0 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER2CC0 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER2,
dmadrvPeripheralSignal_TIMER2_CC1 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER2CC1 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER2,
dmadrvPeripheralSignal_TIMER2_CC2 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER2CC2 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER2,
dmadrvPeripheralSignal_TIMER2_UFOF = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER2UFOF | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER2,
dmadrvPeripheralSignal_TIMER3_CC0 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER3CC0 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER3,
dmadrvPeripheralSignal_TIMER3_CC1 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER3CC1 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER3,
dmadrvPeripheralSignal_TIMER3_CC2 = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER3CC2 | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER3,
dmadrvPeripheralSignal_TIMER3_UFOF = LDMAXBAR_CH_REQSEL_SIGSEL_TIMER3UFOF | LDMAXBAR_CH_REQSEL_SOURCESEL_TIMER3
}
Peripherals that can trigger LDMA transfers.

Functions

Ecode_t DMADRV_AllocateChannel (unsigned int *channelId, void *capabilities)
Allocate (reserve) a DMA channel.
Ecode_t DMADRV_DeInit (void)
Deinitialize DMADRV.
Ecode_t DMADRV_FreeChannel (unsigned int channelId)
Free an allocated (reserved) DMA channel.
Ecode_t DMADRV_Init (void)
Initialize DMADRV.
Ecode_t DMADRV_LdmaStartTransfer (int channelId, LDMA_TransferCfg_t *transfer, LDMA_Descriptor_t *descriptor, DMADRV_Callback_t callback, void *cbUserParam)
Start an LDMA transfer.
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.
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.
Ecode_t DMADRV_PauseTransfer (unsigned int channelId)
Pause an ongoing DMA transfer.
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.
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.
Ecode_t DMADRV_ResumeTransfer (unsigned int channelId)
Resume an ongoing DMA transfer.
Ecode_t DMADRV_StopTransfer (unsigned int channelId)
Stop an ongoing DMA transfer.
Ecode_t DMADRV_TransferActive (unsigned int channelId, bool *active)
Check if a transfer is running.
Ecode_t DMADRV_TransferCompletePending (unsigned int channelId, bool *pending)
Check if a transfer complete is pending.
Ecode_t DMADRV_TransferDone (unsigned int channelId, bool *done)
Check if a transfer has completed.
Ecode_t DMADRV_TransferRemainingCount (unsigned int channelId, int *remaining)
Get number of items remaining in a transfer.

Typedef Documentation

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

DMADRV transfer completion callback function.

The callback function is called when a transfer is complete.

Parameters
[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.
Returns
When doing ping-pong transfers, return true to continue or false to stop transfers.

Definition at line 95 of file dmadrv.h .

Enumeration Type Documentation

Data size of one LDMA transfer item.

Enumerator
dmadrvDataSize1

Byte.

dmadrvDataSize2

Halfword.

dmadrvDataSize4

Word.

Definition at line 922 of file dmadrv.h .

Peripherals that can trigger LDMA transfers.

Enumerator
dmadrvPeripheralSignal_NONE

No peripheral selected for DMA triggering.

Definition at line 328 of file dmadrv.h .

Function Documentation

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

Allocate (reserve) a DMA channel.

Parameters
[out] channelId The channel ID assigned by DMADRV.
[in] capabilities Not used.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 123 of file dmadrv.c .

References CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , and initialized .

Referenced by MIC_init() , and SPIDRV_Init() .

Ecode_t DMADRV_DeInit ( void )

Deinitialize DMADRV.

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

Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 163 of file dmadrv.c .

References CMU_ClockEnable() , CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_DMADRV_IN_USE , ECODE_EMDRV_DMADRV_OK , initialized , and LDMA_DeInit() .

Referenced by SPIDRV_DeInit() , and UARTDRV_DeInit() .

Ecode_t DMADRV_FreeChannel ( unsigned int channelId )

Free an allocated (reserved) DMA channel.

Parameters
[in] channelId The channel ID to free.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 208 of file dmadrv.c .

References CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_DMADRV_ALREADY_FREED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , and initialized .

Referenced by MIC_deInit() , SPIDRV_DeInit() , and UARTDRV_DeInit() .

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

Start an LDMA transfer.

This function is similar to the emlib LDMA function.

Parameters
[in] channelId The channel ID to use.
[in] transfer A DMA transfer configuration data structure.
[in] descriptor A DMA transfer descriptor, can be an array of descriptors linked together.
[in] callback An optional callback function for signalling completion. May be NULL if not needed.
[in] cbUserParam An optional user parameter to feed to the callback function. May be NULL if not needed.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 311 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_StartTransfer() .

Referenced by MIC_init() .

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
[in] channelId The channel ID to use for the transfer.
[in] peripheralSignal Selects which peripheral/peripheralsignal to use.
[in] dst A destination (peripheral register) memory address.
[in] src A source memory address.
[in] srcInc Set to true to enable source address increment (increments according to size parameter).
[in] len A number of items (of size size) to transfer.
[in] size An item size, byte, halfword or word.
[in] callback A function to call on DMA completion, use NULL if not needed.
[in] cbUserParam An optional user parameter to feed to the callback function. Use NULL if not needed.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 378 of file dmadrv.c .

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
[in] channelId The channel ID to use for the transfer.
[in] peripheralSignal Selects which peripheral/peripheralsignal to use.
[in] dst A destination (peripheral register) memory address.
[in] src0 A source memory address of the first (ping) buffer.
[in] src1 A source memory address of the second (pong) buffer.
[in] srcInc Set to true to enable source address increment (increments according to size parameter).
[in] len A number of items (of size size) to transfer.
[in] size An item size, byte, halfword or word.
[in] callback A function to call on DMA completion, use NULL if not needed.
[in] cbUserParam An optional user parameter to feed to the callback function. Use NULL if not needed.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 443 of file dmadrv.c .

Ecode_t DMADRV_PauseTransfer ( unsigned int channelId )

Pause an ongoing DMA transfer.

Parameters
[in] channelId The channel ID of the transfer to pause.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 610 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_EnableChannelRequest() .

Referenced by UARTDRV_PauseTransmit() .

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
[in] channelId The channel ID to use for the transfer.
[in] peripheralSignal Selects which peripheral/peripheralsignal to use.
[in] dst A destination memory address.
[in] src A source memory (peripheral register) address.
[in] dstInc Set to true to enable destination address increment (increments according to size parameter).
[in] len A number of items (of size size) to transfer.
[in] size An item size, byte, halfword or word.
[in] callback A function to call on DMA completion, use NULL if not needed.
[in] cbUserParam An optional user parameter to feed to the callback function. Use NULL if not needed.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 507 of file dmadrv.c .

Referenced by MIC_start() .

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
[in] channelId The channel ID to use for the transfer.
[in] peripheralSignal Selects which peripheral/peripheralsignal to use.
[in] dst0 A destination memory address of the first (ping) buffer.
[in] dst1 A destination memory address of the second (pong) buffer.
[in] src A source memory (peripheral register) address.
[in] dstInc Set to true to enable destination address increment (increments according to size parameter).
[in] len A number of items (of size size) to transfer.
[in] size An item size, byte, halfword or word.
[in] callback A function to call on DMA completion, use NULL if not needed.
[in] cbUserParam An optional user parameter to feed to the callback function. Use NULL if not needed.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 572 of file dmadrv.c .

Ecode_t DMADRV_ResumeTransfer ( unsigned int channelId )

Resume an ongoing DMA transfer.

Parameters
[in] channelId The channel ID of the transfer to resume.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 644 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_EnableChannelRequest() .

Referenced by UARTDRV_ResumeTransmit() .

Ecode_t DMADRV_StopTransfer ( unsigned int channelId )

Stop an ongoing DMA transfer.

Parameters
[in] channelId The channel ID of the transfer to stop.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 678 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_StopTransfer() .

Referenced by MIC_deInit() , SPIDRV_AbortTransfer() , SPIDRV_DeInit() , and UARTDRV_Abort() .

Ecode_t DMADRV_TransferActive ( unsigned int channelId,
bool * active
)

Check if a transfer is running.

Parameters
[in] channelId The channel ID of the transfer to check.
[out] active True if transfer is running, false otherwise.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 715 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_ChannelEnabled() .

Ecode_t DMADRV_TransferCompletePending ( unsigned int channelId,
bool * pending
)

Check if a transfer complete is pending.

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

Parameters
[in] channelId The channel ID of the transfer to check.
[out] pending True if a transfer complete is pending, false otherwise.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 762 of file dmadrv.c .

References ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , and initialized .

Ecode_t DMADRV_TransferDone ( unsigned int channelId,
bool * done
)

Check if a transfer has completed.

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.
Parameters
[in] channelId The channel ID of the transfer to check.
[out] done True if a transfer has completed, false otherwise.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 810 of file dmadrv.c .

References CORE_ATOMIC_SECTION , ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_TransferDone() .

Ecode_t DMADRV_TransferRemainingCount ( unsigned int channelId,
int * remaining
)

Get number of items remaining in a 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.
Parameters
[in] channelId The channel ID of the transfer to check.
[out] remaining A number of items remaining in the transfer.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate DMADRV Ecode_t is returned.

Definition at line 870 of file dmadrv.c .

References CORE_ATOMIC_SECTION , ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED , ECODE_EMDRV_DMADRV_NOT_INITIALIZED , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_DMADRV_PARAM_ERROR , initialized , and LDMA_TransferRemainingCount() .

Referenced by SPIDRV_AbortTransfer() , UARTDRV_Abort() , UARTDRV_GetReceiveStatus() , and UARTDRV_GetTransmitStatus() .