dac14 2.1.0.0
DAC 14 Click Driver

API for configuring and manipulating DAC 14 Click driver. More...

Topics

 DAC 14 Registers List
 List of registers of DAC 14 Click driver.
 
 DAC 14 Registers Settings
 Settings for registers of DAC 14 Click driver.
 
 DAC 14 MikroBUS Map
 MikroBUS pin mapping of DAC 14 Click driver.
 

Functions

void dac14_cfg_setup (dac14_cfg_t *cfg)
 DAC 14 configuration object setup function.
 
void dac14_drv_interface_selection (dac14_cfg_t *cfg, dac14_drv_t drv_sel)
 DAC 14 driver interface setup function.
 
err_t dac14_init (dac14_t *ctx, dac14_cfg_t *cfg)
 DAC 14 initialization function.
 
err_t dac14_default_cfg (dac14_t *ctx)
 DAC 14 default configuration function.
 
err_t dac14_write_register (dac14_t *ctx, uint8_t reg, uint16_t data_in)
 DAC 14 write register function.
 
err_t dac14_read_register (dac14_t *ctx, uint8_t reg, uint16_t *data_out)
 DAC 14 read register function.
 
uint8_t dac14_get_int_pin (dac14_t *ctx)
 DAC 14 get int pin function.
 
err_t dac14_check_communication (dac14_t *ctx)
 DAC 14 check communication function.
 
err_t dac14_set_dac_vout_enable (dac14_t *ctx, uint8_t dac, uint8_t vout_pdn)
 DAC 14 set dac vout enable function.
 
err_t dac14_set_dac_vref (dac14_t *ctx, uint8_t dac, uint8_t vref)
 DAC 14 set dac vref function.
 
err_t dac14_set_dac_margins (dac14_t *ctx, uint8_t dac, uint16_t margin_l, uint16_t margin_h)
 DAC 14 set dac margins function.
 
err_t dac14_set_dac_data (dac14_t *ctx, uint8_t dac, uint16_t dac_data)
 DAC 14 set dac data function.
 
err_t dac14_start_function_gen (dac14_t *ctx, uint8_t dac)
 DAC 14 start function gen function.
 
err_t dac14_stop_function_gen (dac14_t *ctx, uint8_t dac)
 DAC 14 stop function gen function.
 
err_t dac14_config_function_gen (dac14_t *ctx, uint8_t dac, uint8_t waveform, uint8_t code_step, uint8_t slew_rate)
 DAC 14 config function gen function.
 

Detailed Description

API for configuring and manipulating DAC 14 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ dac14_cfg_setup()

void dac14_cfg_setup ( dac14_cfg_t * cfg)

DAC 14 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See dac14_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ dac14_check_communication()

err_t dac14_check_communication ( dac14_t * ctx)

DAC 14 check communication function.

This function checks the communication by reading and verifying the device ID.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_config_function_gen()

err_t dac14_config_function_gen ( dac14_t * ctx,
uint8_t dac,
uint8_t waveform,
uint8_t code_step,
uint8_t slew_rate )

DAC 14 config function gen function.

This function configures the function generator for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
[in]waveform: Waveform signal:
  • 0 - Triangular wave,
  • 1 - Sawtooth wave,
  • 2 - Inverse sawtooth wave,
  • 4 - Sine wave,
  • 7 - Disable function generation.
[in]code_step: Code step setting. Refer to DAC14_CODE_STEP_x macro definitions for more details.
[in]slew_rate: Slew rate setting. Refer to DAC14_SLEW_RATE_x macro definitions for more details.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Each wave has its own output frequency calculation which relies on CODE_STEP, SLEW_RATE, and MARGIN LOW/HIGH settings. It should be calculated as follows: TRIANGLE_FREQUENCY = 1 / ( 2 * SLEW_RATE_US * ( MARGIN_HIGH - MARGIN_LOW + 1 ) / CODE_STEP ) SAWTOOTH_FREQUENCY = 1 / ( SLEW_RATE_US * ( MARGIN_HIGH - MARGIN_LOW + 1 ) / CODE_STEP ) SINE_FREQUENCY = 1 / ( 24 * SLEW_RATE_US ) By default, those parameters are set for DAC1 to output triangular wave at about 4kHz.

◆ dac14_default_cfg()

err_t dac14_default_cfg ( dac14_t * ctx)

DAC 14 default configuration function.

This function executes a default configuration of DAC 14 click board.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ dac14_drv_interface_selection()

void dac14_drv_interface_selection ( dac14_cfg_t * cfg,
dac14_drv_t drv_sel )

DAC 14 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See dac14_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See dac14_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ dac14_get_int_pin()

uint8_t dac14_get_int_pin ( dac14_t * ctx)

DAC 14 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
Returns
Pin logic state.
Note
This pin is available only in I2C mode.

◆ dac14_init()

err_t dac14_init ( dac14_t * ctx,
dac14_cfg_t * cfg )

DAC 14 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See dac14_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_read_register()

err_t dac14_read_register ( dac14_t * ctx,
uint8_t reg,
uint16_t * data_out )

DAC 14 read register function.

This function reads data word from the selected register.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_set_dac_data()

err_t dac14_set_dac_data ( dac14_t * ctx,
uint8_t dac,
uint16_t dac_data )

DAC 14 set dac data function.

This function sets the raw DAC data for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
[in]dac_data: Raw DAC data (0-1023).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_set_dac_margins()

err_t dac14_set_dac_margins ( dac14_t * ctx,
uint8_t dac,
uint16_t margin_l,
uint16_t margin_h )

DAC 14 set dac margins function.

This function sets the DAC margin levels for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
[in]margin_l: Margin LOW (must be <= Margin HIGH) in a range of DAC data (0-1023).
[in]margin_h: Margin HIGH (must be >= Margin LOW) in a range of DAC data (0-1023).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_set_dac_vout_enable()

err_t dac14_set_dac_vout_enable ( dac14_t * ctx,
uint8_t dac,
uint8_t vout_pdn )

DAC 14 set dac vout enable function.

This function sets the VOUT power enable bits for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
[in]vout_pdn: VOUT PDN bits:
  • 0 - Power-up VOUT-X,
  • 1 - Power-down VOUT-X with 10 kOhm to AGND,
  • 2 - Power-down VOUT-X with 100 kOhm to AGND,
  • 3 - Power-down VOUT-X with Hi-Z to AGND.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_set_dac_vref()

err_t dac14_set_dac_vref ( dac14_t * ctx,
uint8_t dac,
uint8_t vref )

DAC 14 set dac vref function.

This function sets the voltage reference for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
[in]vref: Voltage reference:
  • 0 - Gain = 1x, external reference on VREF pin,
  • 1 - Gain = 1x, VDD as reference,
  • 2 - Gain = 1.5x, internal reference,
  • 3 - Gain = 2x, internal reference,
  • 4 - Gain = 3x, internal reference,
  • 5 - Gain = 4x, internal reference.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_start_function_gen()

err_t dac14_start_function_gen ( dac14_t * ctx,
uint8_t dac )

DAC 14 start function gen function.

This function starts the function generator for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_stop_function_gen()

err_t dac14_stop_function_gen ( dac14_t * ctx,
uint8_t dac )

DAC 14 stop function gen function.

This function stops the function generator for the selected DAC channel.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ dac14_write_register()

err_t dac14_write_register ( dac14_t * ctx,
uint8_t reg,
uint16_t data_in )

DAC 14 write register function.

This function writes a desired data word to the selected register.

Parameters
[in]ctx: Click context object. See dac14_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.