adc18 2.0.0.0
ADC 18 Click Driver

API for configuring and manipulating ADC 18 Click driver. More...

Topics

 ADC 18 Registers List
 List of registers of ADC 18 Click driver.
 
 ADC 18 Registers Settings
 Settings for registers of ADC 18 Click driver.
 
 ADC 18 MikroBUS Map
 MikroBUS pin mapping of ADC 18 Click driver.
 

Functions

void adc18_cfg_setup (adc18_cfg_t *cfg)
 ADC 18 configuration object setup function.
 
err_t adc18_init (adc18_t *ctx, adc18_cfg_t *cfg)
 ADC 18 initialization function.
 
err_t adc18_default_cfg (adc18_t *ctx)
 ADC 18 default configuration function.
 
err_t adc18_write_register (adc18_t *ctx, uint8_t reg, uint32_t data_in)
 ADC 18 write register function.
 
err_t adc18_read_register (adc18_t *ctx, uint8_t reg, uint32_t *data_out)
 ADC 18 read register function.
 
err_t adc18_enable_spi_crc (adc18_t *ctx)
 ADC 18 enable spi crc function.
 
err_t adc18_disable_spi_crc (adc18_t *ctx)
 ADC 18 disable spi crc function.
 
err_t adc18_check_communication (adc18_t *ctx)
 ADC 18 check communication function.
 
void adc18_reset_device (adc18_t *ctx)
 ADC 18 reset device function.
 
uint8_t adc18_get_rdy_pin (adc18_t *ctx)
 ADC 18 get rdy pin function.
 
uint8_t adc18_get_int_pin (adc18_t *ctx)
 ADC 18 get int pin function.
 
err_t adc18_start_conversion (adc18_t *ctx, uint8_t data_rate)
 ADC 18 start conversion function.
 
err_t adc18_stop_conversion (adc18_t *ctx)
 ADC 18 stop conversion function.
 
err_t adc18_set_conversion_mode (adc18_t *ctx, uint8_t mode)
 ADC 18 set conversion mode function.
 
err_t adc18_set_active_channel (adc18_t *ctx, uint8_t channel)
 ADC 18 set active channel function.
 
err_t adc18_read_raw_adc (adc18_t *ctx, int32_t *raw_adc)
 ADC 18 read raw adc function.
 
err_t adc18_read_voltage (adc18_t *ctx, float *voltage)
 ADC 18 read voltage function.
 

Detailed Description

API for configuring and manipulating ADC 18 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

◆ adc18_cfg_setup()

void adc18_cfg_setup ( adc18_cfg_t * cfg)

ADC 18 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ adc18_check_communication()

err_t adc18_check_communication ( adc18_t * ctx)

ADC 18 check communication function.

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

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

◆ adc18_default_cfg()

err_t adc18_default_cfg ( adc18_t * ctx)

ADC 18 default configuration function.

This function executes a default configuration of ADC 18 click board.

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

◆ adc18_disable_spi_crc()

err_t adc18_disable_spi_crc ( adc18_t * ctx)

ADC 18 disable spi crc function.

This function disables SPI CRC.

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

◆ adc18_enable_spi_crc()

err_t adc18_enable_spi_crc ( adc18_t * ctx)

ADC 18 enable spi crc function.

This function enables SPI CRC.

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

◆ adc18_get_int_pin()

uint8_t adc18_get_int_pin ( adc18_t * ctx)

ADC 18 get int pin function.

This function returns the INT pin logic state.

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

◆ adc18_get_rdy_pin()

uint8_t adc18_get_rdy_pin ( adc18_t * ctx)

ADC 18 get rdy pin function.

This function returns the RDY pin logic state.

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

◆ adc18_init()

err_t adc18_init ( adc18_t * ctx,
adc18_cfg_t * cfg )

ADC 18 initialization function.

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

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

◆ adc18_read_raw_adc()

err_t adc18_read_raw_adc ( adc18_t * ctx,
int32_t * raw_adc )

ADC 18 read raw adc function.

This function reads RAW ADC value of previous conversion.

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

◆ adc18_read_register()

err_t adc18_read_register ( adc18_t * ctx,
uint8_t reg,
uint32_t * data_out )

ADC 18 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 adc18_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.

◆ adc18_read_voltage()

err_t adc18_read_voltage ( adc18_t * ctx,
float * voltage )

ADC 18 read voltage function.

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

Parameters
[in]ctx: Click context object. See adc18_t object definition for detailed explanation.
[out]voltage: Voltage in range -12.5V to +12.5V.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ adc18_reset_device()

void adc18_reset_device ( adc18_t * ctx)

ADC 18 reset device function.

This function resets the device by toggling the RST pin.

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

◆ adc18_set_active_channel()

err_t adc18_set_active_channel ( adc18_t * ctx,
uint8_t channel )

ADC 18 set active channel function.

This function sets the active channel.

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

◆ adc18_set_conversion_mode()

err_t adc18_set_conversion_mode ( adc18_t * ctx,
uint8_t mode )

ADC 18 set conversion mode function.

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

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

◆ adc18_start_conversion()

err_t adc18_start_conversion ( adc18_t * ctx,
uint8_t data_rate )

ADC 18 start conversion function.

This function starts the conversion with the selected data rate.

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

◆ adc18_stop_conversion()

err_t adc18_stop_conversion ( adc18_t * ctx)

ADC 18 stop conversion function.

This function stops the conversion.

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

◆ adc18_write_register()

err_t adc18_write_register ( adc18_t * ctx,
uint8_t reg,
uint32_t data_in )

ADC 18 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 adc18_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.