gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Digital to Analog Converter

Functions for configuring and using the DAC peripheral. More...

Enumerations

enum  dac_channel_mask_t { DAC_CHANNEL_NONE = 0 , DAC_CHANNEL_0 = 1 , DAC_CHANNEL_1 = 2 , DAC_CHANNEL_BOTH = 3 }
 

Functions

void dac_init (void)
 Initializes the DAC peripheral, but does not enable it.
 
void dac_enable (dac_channel_mask_t channelmask)
 Enables the DAC channels specified in the mask, and disables others.
 
bool dac_is_enabled (void)
 Checks if the DAC peripheral is currently enabled.
 
void dac_set_analog_value (uint16_t channel, uint16_t value)
 Set the analog value of the DAC.
 
void dac_disable (uint16_t channel)
 Disables the given DAC channel.
 
void dac_enable_start_event (uint16_t channel, bool enabled)
 Enables or disables event-triggered DAC conversion.
 
void dac_enable_empty_event_output (uint16_t channel, bool enabled)
 Enables or disables the data buffer empty event output.
 

Detailed Description

Functions for configuring and using the DAC peripheral.

Function Documentation

◆ dac_disable()

void dac_disable ( uint16_t channel)

Disables the given DAC channel.

Warning
Currently only supports the DAC on VOUT[0]

◆ dac_enable()

void dac_enable ( dac_channel_mask_t channelmask)

Enables the DAC channels specified in the mask, and disables others.

Parameters
channelmaskA bitmask of the channels to enable: 1 for channel 0, 2 for channel 1, 3 for both channels. For MCUs with only one DAC channel, this parameter is ignored.

◆ dac_enable_empty_event_output()

void dac_enable_empty_event_output ( uint16_t channel,
bool enabled )

Enables or disables the data buffer empty event output.

Parameters
channelThe DAC channel. Ignored on single-channel chips (D11, D21).
enabledtrue to enable empty event output, false to disable.
Note
Must be called before dac_enable() (EVCTRL is enable-protected).

◆ dac_enable_start_event()

void dac_enable_start_event ( uint16_t channel,
bool enabled )

Enables or disables event-triggered DAC conversion.

When enabled, the DAC converts on a START event from the event system instead of immediately on data write. DMA transfers should target the DATABUF register (not DATA) when start events are enabled.

Parameters
channelThe DAC channel. Ignored on single-channel chips (D11, D21).
enabledtrue to enable start event input, false to disable.
Note
Must be called before dac_enable() (EVCTRL is enable-protected).

◆ dac_init()

void dac_init ( void )

Initializes the DAC peripheral, but does not enable it.

Parameters
channelThe DAC channel to enable.
Warning
Currently only supports the DAC on VOUT[0]

◆ dac_is_enabled()

bool dac_is_enabled ( void )

Checks if the DAC peripheral is currently enabled.

Returns
true if the DAC is enabled, false if it is not.

◆ dac_set_analog_value()

void dac_set_analog_value ( uint16_t channel,
uint16_t value )

Set the analog value of the DAC.

Parameters
channelThe DAC channel to set.
valueThe value to set the DAC to. The range is platform-dependent:
  • On SAM L21, the valid range is from 0 to 4095.
  • On SAM D21 and D11, the valid range is from 0 to 1023. In both cases, 0 is 0V and the maximum value is VDDANA.