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.
 
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.
 

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_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]

TODO: Figure out appropriate clock setup on SAM D51

◆ 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.