adc21 2.1.0.0
ADC 21 Click Driver

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

Topics

 ADC 21 Settings
 Settings of ADC 21 Click driver.
 
 ADC 21 MikroBUS Map
 MikroBUS pin mapping of ADC 21 Click driver.
 

Functions

void adc21_cfg_setup (adc21_cfg_t *cfg)
 ADC 21 configuration object setup function.
 
err_t adc21_init (adc21_t *ctx, adc21_cfg_t *cfg)
 ADC 21 initialization function.
 
err_t adc21_read_raw_adc (adc21_t *ctx, uint8_t channel, uint16_t *raw_adc)
 ADC 21 read raw adc function.
 
err_t adc21_read_voltage (adc21_t *ctx, uint8_t channel, float avcc, float *voltage)
 ADC 21 read voltage function.
 

Detailed Description

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

◆ adc21_cfg_setup()

void adc21_cfg_setup ( adc21_cfg_t * cfg)

ADC 21 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ adc21_init()

err_t adc21_init ( adc21_t * ctx,
adc21_cfg_t * cfg )

ADC 21 initialization function.

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

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

◆ adc21_read_raw_adc()

err_t adc21_read_raw_adc ( adc21_t * ctx,
uint8_t channel,
uint16_t * raw_adc )

ADC 21 read raw adc function.

This function reads raw ADC value from the selected channel by using SPI serial interface.

Parameters
[in]ctx: Click context object. See adc21_t object definition for detailed explanation.
[in]channel: Input channel selection (0-7).
[out]raw_adc: 12-bit raw ADC value.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ adc21_read_voltage()

err_t adc21_read_voltage ( adc21_t * ctx,
uint8_t channel,
float avcc,
float * voltage )

ADC 21 read voltage function.

This function reads raw ADC value from the selected channel and converts it to proportional voltage level depending on the avcc selection.

Parameters
[in]ctx: Click context object. See adc21_t object definition for detailed explanation.
[in]channel: Input channel selection (0-7).
[in]avcc: Voltage on AVCC (3.3V by default).
[out]voltage: Output voltage level [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.