High level interface for interacting with the Cypress DAC.
This block drives a pin with a firmware configurable voltage. See the device datasheet for details on which pins support DAC output.
The cyhal_dac_write and cyhal_dac_read APIs are defined relative to the DAC's output voltage range, which is device dependent.
◆ CYHAL_DAC_RSLT_BAD_ARGUMENT
◆ CYHAL_DAC_RSLT_FAILED_INIT
◆ cyhal_dac_init()
Initialize the DAC peripheral
Configures the pin used by dac.
- Parameters
-
| [in] | obj | The dac object to initialize |
| [in] | pin | The dac pin name |
- Returns
- The status of the init request
◆ cyhal_dac_free()
Release the dac object
- Parameters
-
| [in,out] | obj | The dac object |
◆ cyhal_dac_write()
| void cyhal_dac_write |
( |
const cyhal_dac_t * |
obj, |
|
|
uint16_t |
value |
|
) |
| |
Set the output voltage, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest)
- Parameters
-
| [in] | obj | The dac object |
| [in] | value | The 16-bit output value to set |
◆ cyhal_dac_read()
Read the current DAC output voltage setting, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest). Note: Depending on the precision of the underlying hardware, this may not precisely match the most recent value passed in to cyhal_dac_write.
- Parameters
-
- Returns
- The 16-bit output value