gossamer 0.0.0
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Enumerations | Functions
dac.h File Reference

Digital to Analog Converter. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

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. More...
 
void dac_enable (dac_channel_mask_t channelmask)
 Enables the DAC channels specified in the mask, and disables others. More...
 
void dac_set_analog_value (uint16_t channel, uint16_t value)
 Set the analog value of the DAC. More...
 
void dac_disable (uint16_t channel)
 Disables the given DAC channel. More...
 

Detailed Description

Digital to Analog Converter.

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.