Functions for configuring and using the DAC peripheral.
More...
|
enum | dac_channel_mask_t { DAC_CHANNEL_NONE = 0
, DAC_CHANNEL_0 = 1
, DAC_CHANNEL_1 = 2
, DAC_CHANNEL_BOTH = 3
} |
|
|
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.
|
|
Functions for configuring and using the DAC peripheral.
◆ 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
-
channelmask | A 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()
Initializes the DAC peripheral, but does not enable it.
- Parameters
-
channel | The DAC channel to enable. |
- Warning
- Currently only supports the DAC on VOUT[0]
TODO: Figure out appropriate clock setup on SAM D51
◆ 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
-
channel | The DAC channel to set. |
value | The 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.
|