Class daisy::DacHandle¶
DAC handle for Built-in DAC Peripheral. More...
#include <dac.h>
Classes¶
Type | Name |
---|---|
struct | Config |
Public Types¶
Type | Name |
---|---|
enum | BitDepth |
enum | BufferState |
enum | Channel |
typedef void(* | DacCallback |
enum | Mode |
enum | Result |
Public Functions¶
Type | Name |
---|---|
DacHandle () |
|
DacHandle (const DacHandle & other) = default |
|
const Config & | GetConfig () const |
Result | Init (const Config & config) |
Result | Start (uint16_t * buffer, size_t size, DacCallback cb) |
Result | Start (uint16_t * buffer_1, uint16_t * buffer_2, size_t size, DacCallback cb) |
Result | Stop () |
Result | WriteValue (Channel chn, uint16_t val) |
DacHandle & | operator= (const DacHandle & other) = default |
Detailed Description¶
For now only Normal Mode is supported, Sample and hold mode provides reduced power consumption, but requires a bit more setup.
For now connecting the DAC through other internal peripherals is also not supported.
Since the DAC channels have dedicated pins we don't need to pass in a pin config like with other modules. However, it is still important to not try to use the DAC pins for anything else. DAC Channel 1 is on PA4, and DAC Channel 2 is on PA5
Public Types Documentation¶
enum BitDepth¶
Sets the number of bits per sample transmitted out of the DAC. The output range will be: 0V - VDDA The resolution will be roughly: bitdepth / (VDDA - 0V)
enum BufferState¶
Sets whether the DAC output is buffered for higher drive ability.
enum Channel¶
Selects which channel(s) will be configured for use.
typedef DacCallback¶
Callback for DMA transfers. This is called every time half of the samples of the buffer are transmitted, and the buffer is ready to be filled again.
The data is organized in arrays per channel, for example if both channels are in use: { {ch1-0, ch1-1, ch1-2 . . . ch1-N}, {ch2-0, ch2-1, ch2-2 . . . ch2N} }
enum Mode¶
Sets the Mode for the DAC channels.
Polling mode uses the blocking mode to transmit a single value at a time.
DMA mode uses a buffer, and periodically transmits it triggering a callback to fill the buffer when it is ready for more samples.
enum Result¶
Return Values for the DacHandle class
Public Functions Documentation¶
function DacHandle [½]¶
function DacHandle [2/2]¶
function GetConfig¶
function Init¶
Initialize the DAC Peripheral
function Start [½]¶
Starts the DAC conversion on the DMA calling the user callback whenever new samples are ready to be filled.
This will return Result::ERR if used when configured to BOTH channels.
function Start [2/2]¶
Result daisy::DacHandle::Start (
uint16_t * buffer_1,
uint16_t * buffer_2,
size_t size,
DacCallback cb
)
If using both channels, use this function to start the DMA transfer for both. The callback will provide an array per-channel to fill.
function Stop¶
Stops the DAC channel(s).
function WriteValue¶
Sets and Writes value in Polling Mode Has no effect in DMA mode.
function operator=¶
The documentation for this class was generated from the following file external-docs/libDaisy/src/per/dac.h