Pico-Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PicoDMA< T > Class Template Reference

We can use the Pico DMA to copy data "in the background" while the processor is doing some other work. One PicoDMA object represents a single DMA channel which is reserved the first time it is needed. You can release it explicity after you are done with the processing. More...

#include <PicoDMA.h>

Public Member Functions

 PicoDMA ()
 Default constructor.
 
 ~PicoDMA ()
 Destructor: releases the DMA channel if necessary - if some processing is still going on, it is aborted.
 
bool releaseChannel (bool abortProcessing=false)
 Releases the DMA channel and makes it available again.
 
int channel ()
 provides the used DMA channel - returns -1 if no channel has been set up so far
 
void copy (T *dst, T *src, int len, boolean start=true)
 Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. The copying is done in the background. More...
 
void copy (T *dst, T *src, int len, void(*completion_handler)(), bool startCopy=true)
 Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. The copying is done in the background. More...
 
bool set (T *dst, T src, int len, boolean start=true)
 Sets a destination array with a fixed value We support only data of the size of uint_8, uint16_t and uint_32_t. More...
 
void set (T *dst, T src, int len, void(*completion_handler)(), bool startCopy=true)
 Sets a destination array with a fixed value. More...
 
void start ()
 starts the copy
 
void abort ()
 aborts the copy
 
void wait ()
 a blocking wait for the copy to complete
 
bool isBusy ()
 checks if the copy is still in process
 
void clearInterrupt ()
 You need to call this method in the completion handler.
 

Protected Member Functions

dma_channel_transfer_size transferSize ()
 
void setupChannel ()
 Provides the next available DMA channel.
 

Protected Attributes

int channel_no = -1
 

Detailed Description

template<class T>
class PicoDMA< T >

We can use the Pico DMA to copy data "in the background" while the processor is doing some other work. One PicoDMA object represents a single DMA channel which is reserved the first time it is needed. You can release it explicity after you are done with the processing.

Member Function Documentation

◆ copy() [1/2]

template<class T >
void PicoDMA< T >::copy ( T *  dst,
T *  src,
int  len,
boolean  start = true 
)
inline

Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. The copying is done in the background.

Parameters
dstcopy destination
srccopy source
lennumber of entries
startif true the copy starts immediatly - if set to thrue you need to call start()
Returns
dma channel

◆ copy() [2/2]

template<class T >
void PicoDMA< T >::copy ( T *  dst,
T *  src,
int  len,
void(*)()  completion_handler,
bool  startCopy = true 
)
inline

Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. The copying is done in the background.

Parameters
tocopy destination
fromcopy source
lennumber of entries
completion_handlerinterrupt handler which is executed when the copy terminates
Returns
dma channel

◆ set() [1/2]

template<class T >
bool PicoDMA< T >::set ( T *  dst,
src,
int  len,
boolean  start = true 
)
inline

Sets a destination array with a fixed value We support only data of the size of uint_8, uint16_t and uint_32_t.

Parameters
dstdestination
srcvalue
lenlength of destination array
startif true we start immediatly
Returns
dma channel

◆ set() [2/2]

template<class T >
void PicoDMA< T >::set ( T *  dst,
src,
int  len,
void(*)()  completion_handler,
bool  startCopy = true 
)
inline

Sets a destination array with a fixed value.

Parameters
tocopy destination array
fromsource value
lenlength of array
completion_handlerinterrupt handler which is executed when the copy terminates
Returns
dma channel

The documentation for this class was generated from the following file: