adac2 2.1.0.0
ADAC 2 Click Driver

API for configuring and manipulating ADAC 2 Click driver. More...

Topics

 ADAC 2 Registers List
 List of registers of ADAC 2 Click driver.
 
 ADAC 2 Registers Settings
 Settings for registers of ADAC 2 Click driver.
 
 ADAC 2 MikroBUS Map
 MikroBUS pin mapping of ADAC 2 Click driver.
 

Functions

void adac2_cfg_setup (adac2_cfg_t *cfg)
 ADAC 2 configuration object setup function.
 
err_t adac2_init (adac2_t *ctx, adac2_cfg_t *cfg)
 ADAC 2 initialization function.
 
err_t adac2_default_cfg (adac2_t *ctx)
 ADAC 2 default configuration function.
 
err_t adac2_write_register (adac2_t *ctx, uint8_t reg, uint32_t data_in)
 ADAC 2 write register function.
 
err_t adac2_read_register (adac2_t *ctx, uint8_t reg, uint32_t *data_out)
 ADAC 2 read register function.
 
err_t adac2_enable_spi_crc (adac2_t *ctx)
 ADAC 2 enable spi crc function.
 
err_t adac2_disable_spi_crc (adac2_t *ctx)
 ADAC 2 disable spi crc function.
 
err_t adac2_check_communication (adac2_t *ctx)
 ADAC 2 check communication function.
 
void adac2_reset_device (adac2_t *ctx)
 ADAC 2 reset device function.
 
uint8_t adac2_get_rdy_pin (adac2_t *ctx)
 ADAC 2 get rdy pin function.
 
uint8_t adac2_get_int_pin (adac2_t *ctx)
 ADAC 2 get int pin function.
 
err_t adac2_start_conversion (adac2_t *ctx, uint8_t data_rate)
 ADAC 2 start conversion function.
 
err_t adac2_stop_conversion (adac2_t *ctx)
 ADAC 2 stop conversion function.
 
err_t adac2_set_conversion_mode (adac2_t *ctx, uint8_t mode)
 ADAC 2 set conversion mode function.
 
err_t adac2_set_active_ain_channel (adac2_t *ctx, uint8_t channel)
 ADAC 2 set active ain channel function.
 
err_t adac2_read_raw_adc (adac2_t *ctx, int32_t *raw_adc)
 ADAC 2 read raw adc function.
 
err_t adac2_read_voltage (adac2_t *ctx, float fsr, float *voltage)
 ADAC 2 read voltage function.
 
err_t adac2_write_dac (adac2_t *ctx, int32_t dac)
 ADAC 2 write dac function.
 

Detailed Description

API for configuring and manipulating ADAC 2 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

◆ adac2_cfg_setup()

void adac2_cfg_setup ( adac2_cfg_t * cfg)

ADAC 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ adac2_check_communication()

err_t adac2_check_communication ( adac2_t * ctx)

ADAC 2 check communication function.

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

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

◆ adac2_default_cfg()

err_t adac2_default_cfg ( adac2_t * ctx)

ADAC 2 default configuration function.

This function executes a default configuration of ADAC 2 click board.

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

◆ adac2_disable_spi_crc()

err_t adac2_disable_spi_crc ( adac2_t * ctx)

ADAC 2 disable spi crc function.

This function disables SPI CRC.

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

◆ adac2_enable_spi_crc()

err_t adac2_enable_spi_crc ( adac2_t * ctx)

ADAC 2 enable spi crc function.

This function enables SPI CRC.

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

◆ adac2_get_int_pin()

uint8_t adac2_get_int_pin ( adac2_t * ctx)

ADAC 2 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ adac2_get_rdy_pin()

uint8_t adac2_get_rdy_pin ( adac2_t * ctx)

ADAC 2 get rdy pin function.

This function returns the RDY pin logic state.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ adac2_init()

err_t adac2_init ( adac2_t * ctx,
adac2_cfg_t * cfg )

ADAC 2 initialization function.

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

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

◆ adac2_read_raw_adc()

err_t adac2_read_raw_adc ( adac2_t * ctx,
int32_t * raw_adc )

ADAC 2 read raw adc function.

This function reads RAW ADC value of previous conversion.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[out]raw_adc: 24-bit RAW ADC value (signed).
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_read_register()

err_t adac2_read_register ( adac2_t * ctx,
uint8_t reg,
uint32_t * data_out )

ADAC 2 read register function.

This function reads a 24-bit data from the selected register by using SPI serial interface.

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

◆ adac2_read_voltage()

err_t adac2_read_voltage ( adac2_t * ctx,
float fsr,
float * voltage )

ADAC 2 read voltage function.

This function reads RAW ADC value of previous conversion and converts it to voltage.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[in]fsr: Full scale range for analog input.
[out]voltage: Voltage in fsr range.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_reset_device()

void adac2_reset_device ( adac2_t * ctx)

ADAC 2 reset device function.

This function resets the device by toggling the RST pin.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ adac2_set_active_ain_channel()

err_t adac2_set_active_ain_channel ( adac2_t * ctx,
uint8_t channel )

ADAC 2 set active ain channel function.

This function sets the active analog input channel.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[in]channel: Channel selection byte [0x00-0x19].
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_set_conversion_mode()

err_t adac2_set_conversion_mode ( adac2_t * ctx,
uint8_t mode )

ADAC 2 set conversion mode function.

This function sets the conversion mode by writing to the DCHNL_CTRL1 register.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[in]mode: Conversion mode.
  • 0 - Continuous,
  • 2 - Single-Cycle,
  • 3 - Continuous - Single-Cycle.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_start_conversion()

err_t adac2_start_conversion ( adac2_t * ctx,
uint8_t data_rate )

ADAC 2 start conversion function.

This function starts the conversion with the selected data rate.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[in]data_rate: Data rate [0x00-0x0F].
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_stop_conversion()

err_t adac2_stop_conversion ( adac2_t * ctx)

ADAC 2 stop conversion function.

This function stops the conversion.

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

◆ adac2_write_dac()

err_t adac2_write_dac ( adac2_t * ctx,
int32_t dac )

ADAC 2 write dac function.

This function sets the analog output by writing to the AO_DATA_WR register.

Parameters
[in]ctx: Click context object. See adac2_t object definition for detailed explanation.
[in]dac: DAC raw data [-131072, +131071].
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adac2_write_register()

err_t adac2_write_register ( adac2_t * ctx,
uint8_t reg,
uint32_t data_in )

ADAC 2 write register function.

This function writes a 24-bit data to the selected register by using SPI serial interface.

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