Pico-Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pico_arduino::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.
 
void abort ()
 aborts the copy
 
int channel ()
 provides the used DMA channel - returns -1 if no channel has been set up so far
 
void clearInterrupt ()
 You need to call this method in the completion handler.
 
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 isBusy ()
 checks if the copy is still in process
 
bool releaseChannel (bool abortProcessing=false)
 Releases the DMA channel and makes it available again.
 
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 wait ()
 a blocking wait for the copy to complete
 

Protected Member Functions

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

Protected Attributes

int channel_no = -1
 

Detailed Description

template<class T>
class pico_arduino::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 pico_arduino::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 pico_arduino::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 pico_arduino::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 pico_arduino::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: