Skip to content

File syn_dac.c

FileList > drivers > syn_dac.c

Go to the source code of this file

DAC driver implementation.

  • #include "../util/syn_assert.h"
  • #include "syn_dac.h"

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.

Public Functions Documentation

function syn_dac_init

Initialize a DAC channel.

SYN_Status syn_dac_init (
    SYN_DAC * dac,
    uint8_t channel
) 

Parameters:

  • dac Handle to initialize. Must not be NULL.
  • channel Platform 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).

uint16_t syn_dac_max_raw (
    const SYN_DAC * dac
) 

Parameters:

  • dac Initialized 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.

SYN_Status syn_dac_write_mv (
    const SYN_DAC * dac,
    uint16_t mv
) 

Clamps to the reference voltage automatically.

Parameters:

  • dac Initialized DAC handle.
  • mv Desired output voltage in millivolts.

Returns:

SYN_OK on success.


function syn_dac_write_percent

Write a percentage of full scale to the DAC.

SYN_Status syn_dac_write_percent (
    const SYN_DAC * dac,
    uint8_t percent
) 

Parameters:

  • dac Initialized DAC handle.
  • percent 0 = 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.

SYN_Status syn_dac_write_raw (
    const SYN_DAC * dac,
    uint16_t raw
) 

Parameters:

  • dac Initialized DAC handle.
  • raw Value 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.c