Mischa Megens / DMAFuncGen

Dependents:   DACDMAfuncgenlib

Embed: (wiki syntax)

« Back to documentation index

DMAFuncGen Class Reference

DMAFuncGen Class Reference

DMAFuncGen class generates a waveform on Analog output using Direct Memory Access alone. More...

#include <DMAFuncGen.h>

Public Member Functions

 DMAFuncGen (MODDMA &dma, MODDMA::CHANNELS channel)
 Create DMAFucGen instance.
void set (int idx, uint16_t x)
 Set waveform value for a specified data point.
uint16_t operator[] (const uint16_t idx)
 Get waveform value for a specified data point.
void Connect ()
 Connect the D/A converter pin (enable output)
void Disconnect ()
 Disconnect the D/A converter pin (pin becomes tri-state)
void Setup (void)
 Set up the dma.
void SetFrequency (float f)
 Set waveform frequency.
float Frequency ()
 Read the actual waveform frequency that will be generated.
void Start ()
 Start generating the waveform (start dma)
void Stop ()
 Stop generating the waveform (but waits for the current cycle to complete)

Data Fields

int buffer_size
 Number of data points in the waveform. Must be set by client.
uint32_t * buffer
 Buffer for the binary data that will be transferred by DMA. Must be allocated by client.
MODDMA & dma
 Reference to the DMA instance.

Detailed Description

DMAFuncGen class generates a waveform on Analog output using Direct Memory Access alone.

Definition at line 8 of file DMAFuncGen.h.


Constructor & Destructor Documentation

DMAFuncGen ( MODDMA &  dma,
MODDMA::CHANNELS  channel 
)

Create DMAFucGen instance.

Parameters:
dmaThe dma to use.
channelThe dma channel to use for transferring data to the D/A converter.

Definition at line 6 of file DMAFuncGen.cpp.


Member Function Documentation

void Connect (  )

Connect the D/A converter pin (enable output)

Definition at line 25 of file DMAFuncGen.cpp.

void Disconnect (  )

Disconnect the D/A converter pin (pin becomes tri-state)

Definition at line 34 of file DMAFuncGen.cpp.

float Frequency (  )

Read the actual waveform frequency that will be generated.

Definition at line 70 of file DMAFuncGen.cpp.

uint16_t operator[] ( const uint16_t  idx )

Get waveform value for a specified data point.

Parameters:
idxThe index of the data point in the buffer, in the range 0..buffer_size-1.
Returns:
The value for the data point, in the range 0..65535.

Definition at line 14 of file DMAFuncGen.cpp.

void set ( int  idx,
uint16_t  x 
)

Set waveform value for a specified data point.

Parameters:
idxThe index of the data point in buffer, must be in range 0..buffer_size-1.
xThe value for the D/A, in the range 0..65535.

Definition at line 20 of file DMAFuncGen.cpp.

void SetFrequency ( float  f )

Set waveform frequency.

Note:
Must set buffer_size first.
Parameters:
fFrequency of a complete cycle of the waveform (in Hz).

Definition at line 80 of file DMAFuncGen.cpp.

void Setup ( void   )

Set up the dma.

Must set buffer and buffer_size first.

Definition at line 42 of file DMAFuncGen.cpp.

void Start (  )

Start generating the waveform (start dma)

Definition at line 94 of file DMAFuncGen.cpp.

void Stop (  )

Stop generating the waveform (but waits for the current cycle to complete)

Definition at line 101 of file DMAFuncGen.cpp.


Field Documentation

uint32_t* buffer

Buffer for the binary data that will be transferred by DMA. Must be allocated by client.

Definition at line 18 of file DMAFuncGen.h.

Number of data points in the waveform. Must be set by client.

Definition at line 16 of file DMAFuncGen.h.

MODDMA& dma

Reference to the DMA instance.

Definition at line 35 of file DMAFuncGen.h.