DMA library for the KL25Z

Dependents:   SimpleDMA_HelloWorld RTOS_SPI spiDMAtest Pinscape_Controller_v1 ... more

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 (uint32_t length)
 Start the transfer.
bool isBusy (int channel=-1)
 Is the DMA channel busy.
void attach (Callback< void(int)> func)
 Attach an interrupt upon completion of DMA transfer or error.

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 21 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_46.cpp.


Member Function Documentation

void attach ( Callback< void(int)>  func )

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 120 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 70 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 71 of file SimpleDMA_KL25_46.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 47 of file SimpleDMA.h.

int start ( uint32_t  length )

Start the transfer.

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

Definition at line 29 of file SimpleDMA_KL25_46.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 87 of file SimpleDMA.h.