A simple library to access the DMA functionality.

Fork of SimpleDMA by Erik -

Embed: (wiki syntax)

« Back to documentation index

SimpleDMA Class Reference

SimpleDMA Class Reference

SimpleDMA, DMA made simple! (Okay that was bad) More...

#include <SimpleDMA.h>

Public Member Functions

 SimpleDMA (int channel=-1)
 Constructor.
template<typename Type >
void source (Type *pointer, bool autoinc, int size=sizeof(Type)*8)
 Set the source of the DMA transfer.
template<typename Type >
void destination (Type *pointer, bool autoinc, int size=sizeof(Type)*8)
 Set the destination of the DMA transfer.
void trigger (SimpleDMA_Trigger trig)
 Set the trigger for the DMA operation.
void channel (int chan)
 Set the DMA channel.
int start (int length)
 Start the transfer.
bool isBusy (int channel=-1)
 Is the DMA channel busy.
void attach (void(*function)(void))
 Attach an interrupt upon completion of DMA transfer or error.
void wait (int length)
 Start a DMA transfer similar to start, however block current Thread until the transfer is finished.

Detailed Description

SimpleDMA, DMA made simple! (Okay that was bad)

A class to easily make basic DMA operations happen. Not all features of the DMA peripherals are used, but the main ones are: From and to memory and peripherals, either continiously or triggered

Definition at line 20 of file SimpleDMA.h.


Constructor & Destructor Documentation

SimpleDMA ( int  channel = -1 )

Constructor.

Parameters:
channel- optional parameter which channel should be used, default is automatic channel selection

Definition at line 8 of file SimpleDMA_KL25.cpp.


Member Function Documentation

void attach ( void(*)(void)  function )

Attach an interrupt upon completion of DMA transfer or error.

Parameters:
function- function to call upon completion (may be a member function)

Definition at line 119 of file SimpleDMA.h.

void channel ( int  chan )

Set the DMA channel.

Generally you will not need to call this function, the constructor does so for you

Parameters:
chan- DMA channel to use, -1 = variable channel (highest priority channel which is available)

Definition at line 3 of file SimpleDMA_common.cpp.

void destination ( Type *  pointer,
bool  autoinc,
int  size = sizeof(Type) * 8 
)

Set the destination of the DMA transfer.

Autoincrement increments the pointer after each transfer. If the source is an array this should be true, if it is a peripheral or a single memory location it should be false.

The destination can be any pointer to any memory location. Automatically the wordsize is calculated depending on the type, if required you can also override this.

Parameters:
pointer- pointer to the memory location
autoinc- should the pointer be incremented by the DMA module
size- wordsize in bits (optional, generally can be omitted)
Returns:
- 0 on success

Definition at line 69 of file SimpleDMA.h.

bool isBusy ( int  channel = -1 )

Is the DMA channel busy.

Parameters:
channel- channel to check, -1 = current channel
Returns:
- true if it is busy

Definition at line 70 of file SimpleDMA_KL25.cpp.

void source ( Type *  pointer,
bool  autoinc,
int  size = sizeof(Type) * 8 
)

Set the source of the DMA transfer.

Autoincrement increments the pointer after each transfer. If the source is an array this should be true, if it is a peripheral or a single memory location it should be false.

The source can be any pointer to any memory location. Automatically the wordsize is calculated depending on the type, if required you can also override this.

Parameters:
pointer- pointer to the memory location
autoinc- should the pointer be incremented by the DMA module
size- wordsize in bits (optional, generally can be omitted)
Returns:
- 0 on success

Definition at line 46 of file SimpleDMA.h.

int start ( int  length )

Start the transfer.

Parameters:
length- number of BYTES to be moved by the DMA

Definition at line 28 of file SimpleDMA_KL25.cpp.

void trigger ( SimpleDMA_Trigger  trig )

Set the trigger for the DMA operation.

In SimpleDMA_[yourdevice].h you can find the names of the different triggers. Trigger_ALWAYS is defined for all devices, it will simply move the data as fast as possible. Used for memory-memory transfers. If nothing else is set that will be used by default.

Parameters:
trig- trigger to use
return- 0 on success

Definition at line 86 of file SimpleDMA.h.

void wait ( int  length )

Start a DMA transfer similar to start, however block current Thread until the transfer is finished.

When using this function only the current Thread is halted. The Thread is moved to Waiting state: other Threads will continue to run normally.

This function is only available if you included rtos.h before including SimpleDMA.h.

Parameters:
length- number of BYTES to be moved by the DMA

Definition at line 142 of file SimpleDMA.h.