dac16  2.1.0.0
Modules | Functions
DAC 16 Click Driver

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

Modules

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

Functions

void dac16_cfg_setup (dac16_cfg_t *cfg)
 DAC 16 configuration object setup function. More...
 
void dac16_drv_interface_sel (dac16_cfg_t *cfg, dac16_drv_t drv_sel)
 DAC 16 driver interface setup function. More...
 
err_t dac16_init (dac16_t *ctx, dac16_cfg_t *cfg)
 DAC 16 initialization function. More...
 
err_t dac16_default_cfg (dac16_t *ctx)
 DAC 16 default configuration function. More...
 
err_t dac16_write_register (dac16_t *ctx, uint8_t reg, uint16_t data_in)
 DAC 16 write register function. More...
 
err_t dac16_read_register (dac16_t *ctx, uint8_t reg, uint16_t *data_out)
 DAC 16 read register function. More...
 
uint8_t dac16_get_gp_pin (dac16_t *ctx)
 DAC 16 get GP pin function. More...
 
err_t dac16_check_communication (dac16_t *ctx)
 DAC 16 check communication function. More...
 
err_t dac16_set_dac_vout_enable (dac16_t *ctx, uint8_t dac, uint8_t vout_pdn)
 DAC 16 set dac vout enable function. More...
 
err_t dac16_set_dac_vref (dac16_t *ctx, uint8_t dac, uint8_t vref)
 DAC 16 set dac vref function. More...
 
err_t dac16_set_dac_margins (dac16_t *ctx, uint8_t dac, uint16_t margin_l, uint16_t margin_h)
 DAC 16 set dac margins function. More...
 
err_t dac16_set_dac_data (dac16_t *ctx, uint8_t dac, uint16_t dac_data)
 DAC 16 set dac data function. More...
 
err_t dac16_start_function_gen (dac16_t *ctx, uint8_t dac)
 DAC 16 start function gen function. More...
 
err_t dac16_stop_function_gen (dac16_t *ctx, uint8_t dac)
 DAC 16 stop function gen function. More...
 
err_t dac16_config_function_gen (dac16_t *ctx, uint8_t dac, uint8_t waveform, uint8_t code_step, uint8_t slew_rate)
 DAC 16 config function gen function. More...
 

Detailed Description

API for configuring and manipulating DAC 16 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

◆ dac16_cfg_setup()

void dac16_cfg_setup ( dac16_cfg_t cfg)

DAC 16 configuration object setup function.

This function initializes Click configuration structure to initial values.

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

◆ dac16_check_communication()

err_t dac16_check_communication ( dac16_t ctx)

DAC 16 check communication function.

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

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

◆ dac16_config_function_gen()

err_t dac16_config_function_gen ( dac16_t ctx,
uint8_t  dac,
uint8_t  waveform,
uint8_t  code_step,
uint8_t  slew_rate 
)

DAC 16 config function gen function.

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

Parameters
[in]ctx: Click context object. See dac16_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1,
  • 2 - DAC2,
  • 3 - DAC3.
[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 DAC16_CODE_STEP_x macro definitions for more details.
[in]slew_rate: Slew rate setting. Refer to DAC16_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.

◆ dac16_default_cfg()

err_t dac16_default_cfg ( dac16_t ctx)

DAC 16 default configuration function.

This function executes a default configuration of DAC 16 Click board.

Parameters
[in]ctx: Click context object. See dac16_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.

◆ dac16_drv_interface_sel()

void dac16_drv_interface_sel ( dac16_cfg_t cfg,
dac16_drv_t  drv_sel 
)

DAC 16 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 dac16_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See dac16_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be called 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.

◆ dac16_get_gp_pin()

uint8_t dac16_get_gp_pin ( dac16_t ctx)

DAC 16 get GP pin function.

This function returns the GP pin logic state.

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

◆ dac16_init()

err_t dac16_init ( dac16_t ctx,
dac16_cfg_t cfg 
)

DAC 16 initialization function.

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

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

◆ dac16_read_register()

err_t dac16_read_register ( dac16_t ctx,
uint8_t  reg,
uint16_t *  data_out 
)

DAC 16 read register function.

This function reads data word from the selected register.

Parameters
[in]ctx: Click context object. See dac16_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.

◆ dac16_set_dac_data()

err_t dac16_set_dac_data ( dac16_t ctx,
uint8_t  dac,
uint16_t  dac_data 
)

DAC 16 set dac data function.

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

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

◆ dac16_set_dac_margins()

err_t dac16_set_dac_margins ( dac16_t ctx,
uint8_t  dac,
uint16_t  margin_l,
uint16_t  margin_h 
)

DAC 16 set dac margins function.

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

Parameters
[in]ctx: Click context object. See dac16_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1,
  • 2 - DAC2,
  • 3 - DAC3.
[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.

◆ dac16_set_dac_vout_enable()

err_t dac16_set_dac_vout_enable ( dac16_t ctx,
uint8_t  dac,
uint8_t  vout_pdn 
)

DAC 16 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 dac16_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1,
  • 2 - DAC2,
  • 3 - DAC3.
[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.

◆ dac16_set_dac_vref()

err_t dac16_set_dac_vref ( dac16_t ctx,
uint8_t  dac,
uint8_t  vref 
)

DAC 16 set dac vref function.

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

Parameters
[in]ctx: Click context object. See dac16_t object definition for detailed explanation.
[in]dac: DAC channel:
  • 0 - DAC0,
  • 1 - DAC1,
  • 2 - DAC2,
  • 3 - DAC3.
[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.

◆ dac16_start_function_gen()

err_t dac16_start_function_gen ( dac16_t ctx,
uint8_t  dac 
)

DAC 16 start function gen function.

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

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

◆ dac16_stop_function_gen()

err_t dac16_stop_function_gen ( dac16_t ctx,
uint8_t  dac 
)

DAC 16 stop function gen function.

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

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

◆ dac16_write_register()

err_t dac16_write_register ( dac16_t ctx,
uint8_t  reg,
uint16_t  data_in 
)

DAC 16 write register function.

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

Parameters
[in]ctx: Click context object. See dac16_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.