File syn_dac.h¶
FileList > drivers > syn_dac.h
Go to the source code of this file
DAC (Digital-to-Analog Converter) driver. More...
#include "../common/syn_defs.h"#include "../port/syn_port_dac.h"#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_DAC DAC channel handle. Caller allocates; zero heap. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_dac_init (SYN_DAC * dac, uint8_t channel) Initialize a DAC channel. |
| uint16_t | syn_dac_max_raw (const SYN_DAC * dac) Return the maximum raw value for this DAC (2^resolution - 1). |
| SYN_Status | syn_dac_write_mv (const SYN_DAC * dac, uint16_t mv) Write a millivolt target to the DAC. |
| SYN_Status | syn_dac_write_percent (const SYN_DAC * dac, uint8_t percent) Write a percentage of full scale to the DAC. |
| SYN_Status | syn_dac_write_raw (const SYN_DAC * dac, uint16_t raw) Write a raw count value to the DAC. |
Detailed Description¶
Thin wrapper over syn_port_dac.h, mirroring the pattern of syn_adc.h. Provides raw-count, millivolt, and percent write helpers.
Usage:
SYN_DAC dac;
syn_dac_init(&dac, 0); // channel 0
syn_dac_write_mv(&dac, 1650); // 1.65 V (half of 3.3 V ref)
Public Functions Documentation¶
function syn_dac_init¶
Initialize a DAC channel.
Parameters:
dacHandle to initialize. Must not be NULL.channelPlatform DAC channel index.
Returns:
SYN_OK on success, SYN_ERROR on hardware failure.
function syn_dac_max_raw¶
Return the maximum raw value for this DAC (2^resolution - 1).
Parameters:
dacInitialized DAC handle (channel field used to query port).
Returns:
Maximum raw count (e.g. 4095 for 12-bit).
function syn_dac_write_mv¶
Write a millivolt target to the DAC.
Clamps to the reference voltage automatically.
Parameters:
dacInitialized DAC handle.mvDesired output voltage in millivolts.
Returns:
SYN_OK on success.
function syn_dac_write_percent¶
Write a percentage of full scale to the DAC.
Parameters:
dacInitialized DAC handle.percent0 = 0 V, 100 = full reference voltage. Values > 100 are clamped to 100.
Returns:
SYN_OK on success.
function syn_dac_write_raw¶
Write a raw count value to the DAC.
Parameters:
dacInitialized DAC handle.rawValue in range [0, syn_dac_max_raw(dac)].
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/drivers/syn_dac.h