EFM32 Gecko Software Documentation  efm32g-doc-4.2.1

DMADRV Direct Memory Access Driver.

. More...

Macros

#define ECODE_EMDRV_DMADRV_OK   ( ECODE_OK )
 Success return value.
 
#define ECODE_EMDRV_DMADRV_PARAM_ERROR   ( ECODE_EMDRV_DMADRV_BASE | 0x00000001 )
 Illegal input parameter.
 
#define ECODE_EMDRV_DMADRV_NOT_INITIALIZED   ( ECODE_EMDRV_DMADRV_BASE | 0x00000002 )
 DMA is not initialized.
 
#define ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED   ( ECODE_EMDRV_DMADRV_BASE | 0x00000003 )
 DMA has already been initialized.
 
#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_ALREADY_FREED   ( ECODE_EMDRV_DMADRV_BASE | 0x00000006 )
 DMA channel was free.
 
#define ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED   ( ECODE_EMDRV_DMADRV_BASE | 0x00000007 )
 The channel is not reserved.
 
#define DMADRV_MAX_XFER_COUNT   ((int)((_DMA_CTRL_N_MINUS_1_MASK >> _DMA_CTRL_N_MINUS_1_SHIFT) + 1))
 Maximum length of one DMA transfer.
 

Typedefs

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

Enumerations

enum  DMADRV_Peripheralsignal_t {
  dmadrvPeripheralSignal_NONE = 0,
  dmadrvPeripheralSignal_ADC0_SCAN = DMAREQ_ADC0_SCAN,
  dmadrvPeripheralSignal_ADC0_SINGLE = DMAREQ_ADC0_SINGLE,
  dmadrvPeripheralSignal_AES_DATARD = DMAREQ_AES_DATARD,
  dmadrvPeripheralSignal_AES_DATAWR = DMAREQ_AES_DATAWR,
  dmadrvPeripheralSignal_AES_KEYWR = DMAREQ_AES_KEYWR,
  dmadrvPeripheralSignal_AES_XORDATAWR = DMAREQ_AES_XORDATAWR,
  dmadrvPeripheralSignal_DAC0_CH0 = DMAREQ_DAC0_CH0,
  dmadrvPeripheralSignal_DAC0_CH1 = DMAREQ_DAC0_CH1,
  dmadrvPeripheralSignal_I2C0_RXDATAV = DMAREQ_I2C0_RXDATAV,
  dmadrvPeripheralSignal_I2C0_TXBL = DMAREQ_I2C0_TXBL,
  dmadrvPeripheralSignal_LEUART0_RXDATAV = DMAREQ_LEUART0_RXDATAV,
  dmadrvPeripheralSignal_LEUART0_TXBL = DMAREQ_LEUART0_TXBL,
  dmadrvPeripheralSignal_LEUART0_TXEMPTY = DMAREQ_LEUART0_TXEMPTY,
  dmadrvPeripheralSignal_LEUART1_RXDATAV = DMAREQ_LEUART1_RXDATAV,
  dmadrvPeripheralSignal_LEUART1_TXBL = DMAREQ_LEUART1_TXBL,
  dmadrvPeripheralSignal_LEUART1_TXEMPTY = DMAREQ_LEUART1_TXEMPTY,
  dmadrvPeripheralSignal_MSC_WDATA = DMAREQ_MSC_WDATA,
  dmadrvPeripheralSignal_TIMER0_CC0 = DMAREQ_TIMER0_CC0,
  dmadrvPeripheralSignal_TIMER0_CC1 = DMAREQ_TIMER0_CC1,
  dmadrvPeripheralSignal_TIMER0_CC2 = DMAREQ_TIMER0_CC2,
  dmadrvPeripheralSignal_TIMER0_UFOF = DMAREQ_TIMER0_UFOF,
  dmadrvPeripheralSignal_TIMER1_CC0 = DMAREQ_TIMER1_CC0,
  dmadrvPeripheralSignal_TIMER1_CC1 = DMAREQ_TIMER1_CC1,
  dmadrvPeripheralSignal_TIMER1_CC2 = DMAREQ_TIMER1_CC2,
  dmadrvPeripheralSignal_TIMER1_UFOF = DMAREQ_TIMER1_UFOF,
  dmadrvPeripheralSignal_TIMER2_CC0 = DMAREQ_TIMER2_CC0,
  dmadrvPeripheralSignal_TIMER2_CC1 = DMAREQ_TIMER2_CC1,
  dmadrvPeripheralSignal_TIMER2_CC2 = DMAREQ_TIMER2_CC2,
  dmadrvPeripheralSignal_TIMER2_UFOF = DMAREQ_TIMER2_UFOF,
  dmadrvPeripheralSignal_UART0_RXDATAV = DMAREQ_UART0_RXDATAV,
  dmadrvPeripheralSignal_UART0_TXBL = DMAREQ_UART0_TXBL,
  dmadrvPeripheralSignal_UART0_TXEMPTY = DMAREQ_UART0_TXEMPTY,
  dmadrvPeripheralSignal_USART0_RXDATAV = DMAREQ_USART0_RXDATAV,
  dmadrvPeripheralSignal_USART0_TXBL = DMAREQ_USART0_TXBL,
  dmadrvPeripheralSignal_USART0_TXEMPTY = DMAREQ_USART0_TXEMPTY,
  dmadrvPeripheralSignal_USART1_RXDATAV = DMAREQ_USART1_RXDATAV,
  dmadrvPeripheralSignal_USART1_TXBL = DMAREQ_USART1_TXBL,
  dmadrvPeripheralSignal_USART1_TXEMPTY = DMAREQ_USART1_TXEMPTY,
  dmadrvPeripheralSignal_USART2_RXDATAV = DMAREQ_USART2_RXDATAV,
  dmadrvPeripheralSignal_USART2_TXBL = DMAREQ_USART2_TXBL,
  dmadrvPeripheralSignal_USART2_TXEMPTY = DMAREQ_USART2_TXEMPTY
}
 Peripherals that can trigger UDMA transfers. More...
 
enum  DMADRV_Datasize_t {
  dmadrvDataSize1 = dmaDataSize1,
  dmadrvDataSize2 = dmaDataSize2,
  dmadrvDataSize4 = dmaDataSize4
}
 Data size of one UDMA transfer item. More...
 

Functions

Ecode_t DMADRV_AllocateChannel (unsigned int *channelId, void *capabilities)
 Allocate (reserve) a DMA channel. More...
 
Ecode_t DMADRV_DeInit (void)
 Deinitialize DMADRV. More...
 
Ecode_t DMADRV_FreeChannel (unsigned int channelId)
 Free an allocate (reserved) DMA channel. More...
 
Ecode_t DMADRV_Init (void)
 Initialize DMADRV. More...
 
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 peripheral DMA transfer. More...
 
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. More...
 
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 peripheral ping-pong DMA transfer. More...
 
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. More...
 
Ecode_t DMADRV_StopTransfer (unsigned int channelId)
 Stop an ongoing DMA transfer. More...
 
Ecode_t DMADRV_TransferActive (unsigned int channelId, bool *active)
 Check if a transfer is running. More...
 
Ecode_t DMADRV_TransferCompletePending (unsigned int channelId, bool *pending)
 Check if a transfer complete is pending. More...
 
Ecode_t DMADRV_TransferDone (unsigned int channelId, bool *done)
 Check if a transfer has completed. More...
 
Ecode_t DMADRV_TransferRemainingCount (unsigned int channelId, int *remaining)
 Get number of items remaining in a transfer. More...
 

Detailed Description

DMADRV Direct Memory Access


Introduction

The DMADRV driver makes it possible to write code using DMA which will work regardless of the type of DMA controller on the underlying microcontroller. It will also make it possible to use DMA in several modules, without the modules knowing of each others existence. The driver does not preclude use of the native emlib API of the underlying DMA controller, on the contrary, this will often result in more efficient code and is a necessity when doing complex DMA operations. The housekeeping functions of this driver will be valuable even in this use-case.

The source files for the DMA driver library resides in the emdrv/dmadrv folder, and are named dmadrv.c and dmadrv.h.

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, resides in the emdrv/config folder. Currently the configuration options are:

  • The interrupt priority of the DMA peripheral.
  • 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 drivers ram memory footprint.

To configure DMADRV, provide your own configuration file. Here is a sample 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 highest priority.
#define EMDRV_DMADRV_DMA_IRQ_PRIORITY 4

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

// DMADRV native API configuration option.
// Use the native emlib api of the DMA controller, but still use DMADRV
// housekeeping functions as AllocateChannel/FreeChannel etc.
#define EMDRV_DMADRV_USE_NATIVE_API

#endif


The API

This section contain brief descriptions of the functions in the API. You will find detailed information on input and output parameters and return values by clicking 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.

Your application code must include one header file: dmadrv.h.

DMADRV_Init(), DMADRV_DeInit()
These functions initializes or deinitializes the DMADRV driver. Typically DMADRV_Init() is called once in your 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 a LDMA controller. This function can only be used when configuration option EMDRV_DMADRV_USE_NATIVE_API is defined. It is a wrapper around similar 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.
  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;
}

Typedef Documentation

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

The callback function is called when a transfer has completed.

Parameters
[in]channelThe DMA channel number.
[in]sequenceNoThe number of times the callback had been called. Useful on long chains of linked transfers or on endless ping-pong type transfers.
[in]userParamOptional user parameter supplied on DMA invocation.
Returns
When doing ping-pong transfers, return true to continue or false to stop transfers.

Definition at line 81 of file dmadrv.h.

Enumeration Type Documentation

Enumerator
dmadrvPeripheralSignal_NONE 

No peripheral selected for DMA triggering.

dmadrvPeripheralSignal_ADC0_SCAN 

Trig on ADC0_SCAN.

dmadrvPeripheralSignal_ADC0_SINGLE 

Trig on ADC0_SINGLE.

dmadrvPeripheralSignal_AES_DATARD 

Trig on AES_DATARD.

dmadrvPeripheralSignal_AES_DATAWR 

Trig on AES_DATAWR.

dmadrvPeripheralSignal_AES_KEYWR 

Trig on AES_KEYWR.

dmadrvPeripheralSignal_AES_XORDATAWR 

Trig on AES_XORDATAWR.

dmadrvPeripheralSignal_DAC0_CH0 

Trig on DAC0_CH0.

dmadrvPeripheralSignal_DAC0_CH1 

Trig on DAC0_CH1.

dmadrvPeripheralSignal_I2C0_RXDATAV 

Trig on I2C0_RXDATAV.

dmadrvPeripheralSignal_I2C0_TXBL 

Trig on I2C0_TXBL.

dmadrvPeripheralSignal_LEUART0_RXDATAV 

Trig on LEUART0_RXDATAV.

dmadrvPeripheralSignal_LEUART0_TXBL 

Trig on LEUART0_TXBL.

dmadrvPeripheralSignal_LEUART0_TXEMPTY 

Trig on LEUART0_TXEMPTY.

dmadrvPeripheralSignal_LEUART1_RXDATAV 

Trig on LEUART1_RXDATAV.

dmadrvPeripheralSignal_LEUART1_TXBL 

Trig on LEUART1_TXBL.

dmadrvPeripheralSignal_LEUART1_TXEMPTY 

Trig on LEUART1_TXEMPTY.

dmadrvPeripheralSignal_MSC_WDATA 

Trig on MSC_WDATA.

dmadrvPeripheralSignal_TIMER0_CC0 

Trig on TIMER0_CC0.

dmadrvPeripheralSignal_TIMER0_CC1 

Trig on TIMER0_CC1.

dmadrvPeripheralSignal_TIMER0_CC2 

Trig on TIMER0_CC2.

dmadrvPeripheralSignal_TIMER0_UFOF 

Trig on TIMER0_UFOF.

dmadrvPeripheralSignal_TIMER1_CC0 

Trig on TIMER1_CC0.

dmadrvPeripheralSignal_TIMER1_CC1 

Trig on TIMER1_CC1.

dmadrvPeripheralSignal_TIMER1_CC2 

Trig on TIMER1_CC2.

dmadrvPeripheralSignal_TIMER1_UFOF 

Trig on TIMER1_UFOF.

dmadrvPeripheralSignal_TIMER2_CC0 

Trig on TIMER2_CC0.

dmadrvPeripheralSignal_TIMER2_CC1 

Trig on TIMER2_CC1.

dmadrvPeripheralSignal_TIMER2_CC2 

Trig on TIMER2_CC2.

dmadrvPeripheralSignal_TIMER2_UFOF 

Trig on TIMER2_UFOF.

dmadrvPeripheralSignal_UART0_RXDATAV 

Trig on UART0_RXDATAV.

dmadrvPeripheralSignal_UART0_TXBL 

Trig on UART0_TXBL.

dmadrvPeripheralSignal_UART0_TXEMPTY 

Trig on UART0_TXEMPTY.

dmadrvPeripheralSignal_USART0_RXDATAV 

Trig on USART0_RXDATAV.

dmadrvPeripheralSignal_USART0_TXBL 

Trig on USART0_TXBL.

dmadrvPeripheralSignal_USART0_TXEMPTY 

Trig on USART0_TXEMPTY.

dmadrvPeripheralSignal_USART1_RXDATAV 

Trig on USART1_RXDATAV.

dmadrvPeripheralSignal_USART1_TXBL 

Trig on USART1_TXBL.

dmadrvPeripheralSignal_USART1_TXEMPTY 

Trig on USART1_TXEMPTY.

dmadrvPeripheralSignal_USART2_RXDATAV 

Trig on USART2_RXDATAV.

dmadrvPeripheralSignal_USART2_TXBL 

Trig on USART2_TXBL.

dmadrvPeripheralSignal_USART2_TXEMPTY 

Trig on USART2_TXEMPTY.

Definition at line 91 of file dmadrv.h.

Enumerator
dmadrvDataSize1 

Byte.

dmadrvDataSize2 

Halfword.

dmadrvDataSize4 

Word.

Definition at line 296 of file dmadrv.h.

Function Documentation

Ecode_t DMADRV_AllocateChannel ( unsigned int *  channelId,
void *  capabilities 
)
Parameters
[out]channelIdThe channel Id assigned by DMADRV.
[in]capabilitiesNot used.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure an appropriate DMADRV Ecode_t is returned.

Definition at line 131 of file dmadrv.c.

References ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED, ECODE_EMDRV_DMADRV_NOT_INITIALIZED, ECODE_EMDRV_DMADRV_OK, ECODE_EMDRV_DMADRV_PARAM_ERROR, initialized, INT_Disable(), and INT_Enable().

Referenced by SPIDRV_Init(), and UARTDRV_Init().

Ecode_t DMADRV_DeInit ( void  )

If no DMA channels are 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 176 of file dmadrv.c.

References _DMA_CONFIG_RESETVALUE, _DMA_IEN_RESETVALUE, CMU_ClockEnable(), cmuClock_DMA, DMA, DMA_IRQn, ECODE_EMDRV_DMADRV_IN_USE, ECODE_EMDRV_DMADRV_OK, initialized, INT_Disable(), and INT_Enable().

Referenced by SPIDRV_DeInit(), and UARTDRV_DeInit().

Ecode_t DMADRV_FreeChannel ( unsigned int  channelId)
Parameters
[in]channelIdThe channel Id to free.
Returns
ECODE_EMDRV_DMADRV_OK on success. On failure an appropriate DMADRV Ecode_t is returned.

Definition at line 223 of file dmadrv.c.

References ECODE_EMDRV_DMADRV_ALREADY_FREED, ECODE_EMDRV_DMADRV_NOT_INITIALIZED, ECODE_EMDRV_DMADRV_OK, ECODE_EMDRV_DMADRV_PARAM_ERROR, initialized, INT_Disable(), and INT_Enable().

Referenced by SPIDRV_DeInit(), and UARTDRV_DeInit().

Ecode_t DMADRV_Init ( void  )

The DMA hw is initialized.

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

Definition at line 258 of file dmadrv.c.

References DMA_Init(), DMA_IRQn, dmaControlBlock, ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED, ECODE_EMDRV_DMADRV_OK, ECODE_EMDRV_DMADRV_PARAM_ERROR, initialized, INT_Disable(), and INT_Enable().

Referenced by SPIDRV_Init(), and UARTDRV_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 
)
Parameters
[in]channelIdNot used
[in]peripheralSignalSelects which peripheral/peripheralsignal to use.
[in]dstDestination (peripheral register) memory address.
[in]srcSource memory address.
[in]srcIncSet to true to enable source address increment (increment is according to size parameter).
[in]lenNumber if items (of size size) to transfer.
[in]sizeItem size, byte, halfword or word.
[in]callbackFunction to call on dma completion, use NULL if not needed.
[in]cbUserParamOptional 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 402 of file dmadrv.c.

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 
)
Parameters
[in]channelIdNot used
[in]peripheralSignalSelects which peripheral/peripheralsignal to use.
[in]dstDestination memory address.
[in]srcSource memory (peripheral register) address.
[in]dstIncSet to true to enable destination address increment (increment is according to size parameter).
[in]lenNumber if items (of size size) to transfer.
[in]sizeItem size, byte, halfword or word.
[in]callbackFunction to call on dma completion, use NULL if not needed.
[in]cbUserParamOptional 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 535 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 
)
Parameters
[in]channelIdNot used
[in]peripheralSignalSelects which peripheral/peripheralsignal to use.
[in]dstDestination (peripheral register) memory address.
[in]src0Source memory address of first (ping) buffer.
[in]src1Source memory address of second (pong) buffer.
[in]srcIncSet to true to enable source address increment (increment is according to size parameter).
[in]lenNumber if items (of size size) to transfer.
[in]sizeItem size, byte, halfword or word.
[in]callbackFunction to call on dma completion, use NULL if not needed.
[in]cbUserParamOptional 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 469 of file dmadrv.c.

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 
)
Parameters
[in]channelIdNot used
[in]peripheralSignalSelects which peripheral/peripheralsignal to use.
[in]dst0Destination memory address of first (ping) buffer.
[in]dst1Destination memory address of second (pong) buffer.
[in]srcSource memory (peripheral register) address.
[in]dstIncSet to true to enable destination address increment (increment is according to size parameter).
[in]lenNumber if items (of size size) to transfer.
[in]sizeItem size, byte, halfword or word.
[in]callbackFunction to call on dma completion, use NULL if not needed.
[in]cbUserParamOptional 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 602 of file dmadrv.c.

Ecode_t DMADRV_StopTransfer ( unsigned int  channelId)
Parameters
[in]channelIdThe 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 641 of file dmadrv.c.

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

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

Ecode_t DMADRV_TransferActive ( unsigned int  channelId,
bool *  active 
)
Parameters
[in]channelIdThe channel Id of the transfer to check.
[out]activeTrue 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 681 of file dmadrv.c.

References DMA_ChannelEnabled(), 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_TransferCompletePending ( unsigned int  channelId,
bool *  pending 
)

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

Parameters
[in]channelIdThe channel Id of the transfer to check.
[out]pendingTrue 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 733 of file dmadrv.c.

References DMA, 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 
)
Note
This function is meant to be used in a polled environment. Will only work reliable for transfers NOT using completion interrupt. On UDMA it will only work on basic transfers on primary channel.
Parameters
[in]channelIdThe channel Id of the transfer to check.
[out]doneTrue 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 786 of file dmadrv.c.

References _DMA_CTRL_N_MINUS_1_MASK, _DMA_CTRL_N_MINUS_1_SHIFT, DMA_DESCRIPTOR_TypeDef::CTRL, DMA, dmaControlBlock, ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED, ECODE_EMDRV_DMADRV_NOT_INITIALIZED, ECODE_EMDRV_DMADRV_OK, ECODE_EMDRV_DMADRV_PARAM_ERROR, initialized, INT_Disable(), and INT_Enable().

Ecode_t DMADRV_TransferRemainingCount ( unsigned int  channelId,
int *  remaining 
)
Note
This function is does not take into account that a DMA transfers 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]channelIdThe channel Id of the transfer to check.
[out]remainingNumber 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 852 of file dmadrv.c.

References _DMA_CTRL_N_MINUS_1_MASK, _DMA_CTRL_N_MINUS_1_SHIFT, DMA_DESCRIPTOR_TypeDef::CTRL, DMA, dmaControlBlock, ECODE_EMDRV_DMADRV_CH_NOT_ALLOCATED, ECODE_EMDRV_DMADRV_NOT_INITIALIZED, ECODE_EMDRV_DMADRV_OK, ECODE_EMDRV_DMADRV_PARAM_ERROR, initialized, INT_Disable(), and INT_Enable().

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