adc22 2.1.0.0
adc22.h File Reference

This file contains API for ADC 22 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  adc22_t
 ADC 22 Click context object. More...
 
struct  adc22_cfg_t
 ADC 22 Click configuration object. More...
 

Macros

#define ADC22_CMD_NOP   0x00
 ADC 22 description command.
 
#define ADC22_CMD_CLEAR_HWORD   0xC0
 
#define ADC22_CMD_READ_HWORD   0xC8
 
#define ADC22_CMD_READ   0x48
 
#define ADC22_CMD_WRITE   0xD0
 
#define ADC22_CMD_WRITE_MS   0xD2
 
#define ADC22_CMD_WRITE_LS   0xD4
 
#define ADC22_CMD_SET_HWORD   0xD8
 
#define ADC22_REG_DEVICE_ID   0x02
 ADC 22 description register.
 
#define ADC22_REG_RST_PWRCTL_LSB   0x04
 
#define ADC22_REG_RST_PWRCTL_MSB   0x05
 
#define ADC22_REG_SDI_CTL   0x08
 
#define ADC22_REG_SDO_CTL_LSB   0x0C
 
#define ADC22_REG_SDO_CTL_MSB   0x0D
 
#define ADC22_REG_DATAOUT_CTL_LSB   0x10
 
#define ADC22_REG_DATAOUT_CTL_MSB   0x11
 
#define ADC22_REG_RANGE_SEL   0x14
 
#define ADC22_REG_ALARM_LSB   0x20
 
#define ADC22_REG_ALARM_MSB   0x21
 
#define ADC22_REG_ALARM_H_TH_LSB   0x24
 
#define ADC22_REG_ALARM_H_TH_MSB   0x25
 
#define ADC22_REG_ALARM_L_TH_LSB   0x28
 
#define ADC22_REG_ALARM_L_TH_MSB   0x29
 
#define ADC22_DEVICE_ADDR_MAX   16
 ADC 22 identification numbers associated to a device values.
 
#define ADC22_SDO_MODE_SAME_SDI   1
 ADC 22 SDO mode data values.
 
#define ADC22_SDO_MODE_INV   2
 
#define ADC22_SDO_MODE_ADC_M_CLK   3
 
#define ADC22_DATAOUT_CTL_VAL_CONV   0x00
 ADC 22 controls the data output by the device data values.
 
#define ADC22_DATAOUT_CTL_VAL_0_S   0x04
 
#define ADC22_DATAOUT_CTL_VAL_1_S   0x05
 
#define ADC22_DATAOUT_CTL_VAL_A_01_S   0x06
 
#define ADC22_DATAOUT_CTL_VAL_A_0011_S   0x07
 
#define ADC22_DATAOUT_CTL_PAR_DIS   0x00
 
#define ADC22_DATAOUT_CTL_PAR_EN   0x08
 
#define ADC22_ADC_ZERO_SCALE   2045u
 ADC 22 ADC resolution data values.
 
#define ADC22_ADC_MIDDLE_SCALE   2048.0f
 
#define ADC22_ADC_FULL_SCALE   4096.0f
 
#define ADC22_ADC_RANGE_12V28   12.28f
 ADC 22 ADC range data values.
 
#define ADC22_ADC_RANGE_10V24   10.24f
 
#define ADC22_ADC_RANGE_6V14   6.14f
 
#define ADC22_ADC_RANGE_5V12   5.12f
 
#define ADC22_ADC_RANGE_2V56   2.56f
 
#define ADC22_SET_RANGE_BIT_MASK   0x0F
 
#define ADC22_PIN_STATE_LOW   0x00
 ADC 22 I/O pin state data values.
 
#define ADC22_PIN_STATE_HIGH   0x01
 
#define ADC22_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define ADC22_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define ADC22_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  adc22_return_value_t { ADC22_OK = 0 , ADC22_ERROR = -1 }
 ADC 22 Click return value data. More...
 
enum  adc22_range_sel_t {
  ADC22_RANGE_BI_12V28 = 0x00 , ADC22_RANGE_BI_10V24 = 0x01 , ADC22_RANGE_BI_6V14 = 0x02 , ADC22_RANGE_BI_5V12 = 0x03 ,
  ADC22_RANGE_BI_2V56 = 0x04 , ADC22_RANGE_12V28 = 0x08 , ADC22_RANGE_10V24 = 0x09 , ADC22_RANGE_6V14 = 0x0A ,
  ADC22_RANGE_5V12 = 0x0B
}
 ADC 22 Click ADC ranges selections. More...
 

Functions

void adc22_cfg_setup (adc22_cfg_t *cfg)
 ADC 22 configuration object setup function.
 
err_t adc22_init (adc22_t *ctx, adc22_cfg_t *cfg)
 ADC 22 initialization function.
 
err_t adc22_default_cfg (adc22_t *ctx)
 ADC 22 default configuration function.
 
void adc22_hw_reset (adc22_t *ctx)
 ADC 22 HW reset function.
 
uint8_t adc22_get_interrupt (adc22_t *ctx)
 ADC 22 get interrupt function.
 
uint8_t adc22_get_rvs (adc22_t *ctx)
 ADC 22 get RVS function.
 
err_t adc22_write_reg (adc22_t *ctx, uint8_t w_cmd, uint8_t reg, uint8_t data_in)
 ADC 22 data writing function.
 
err_t adc22_read_reg (adc22_t *ctx, uint8_t r_cmd, uint8_t reg, uint8_t *data_out)
 ADC 22 data reading function.
 
err_t adc22_get_adc_raw_data (adc22_t *ctx, uint16_t *raw_adc)
 ADC 22 get ADC raw data function.
 
err_t adc22_get_voltage (adc22_t *ctx, float *voltage)
 ADC 22 get voltage level function.
 
err_t adc22_set_device_addr (adc22_t *ctx, uint8_t device_addr)
 ADC 22 set device address function.
 
err_t adc22_get_device_id (adc22_t *ctx, uint8_t *device_id)
 ADC 22 get device ID function.
 
err_t adc22_set_sdo_mode (adc22_t *ctx, uint8_t sdo_mode)
 ADC 22 set SDO mode function.
 
err_t adc22_en_out_data_parity (adc22_t *ctx)
 ADC 22 enable output data parity function.
 
err_t adc22_set_range (adc22_t *ctx, adc22_range_sel_t range)
 ADC 22 set range function.
 
err_t adc22_get_range (adc22_t *ctx, uint8_t *range)
 ADC 22 get range function.
 

Detailed Description

This file contains API for ADC 22 Click Driver.

Enumeration Type Documentation

◆ adc22_range_sel_t

ADC 22 Click ADC ranges selections.

Predefined enum values for driver ADC ranges selections.

Enumerator
ADC22_RANGE_BI_12V28 

Input range = ±3×VREF [–12.288:12.288].

ADC22_RANGE_BI_10V24 

Input range = ±2.5×VREF [–10.24:10.24].

ADC22_RANGE_BI_6V14 

Input range = ±1.5×VREF [–6.144:6.144].

ADC22_RANGE_BI_5V12 

Input range = ±1.25×VREF [–5.12:5.12].

ADC22_RANGE_BI_2V56 

Input range = ±0.625×VREF [–2.56:2.56].

ADC22_RANGE_12V28 

Input range = 3×VREF [0:12.288].

ADC22_RANGE_10V24 

Input range = 2.5×VREF [0:10.24].

ADC22_RANGE_6V14 

Input range = 1.5×VREF [0:6.144].

ADC22_RANGE_5V12 

Input range = 1.25×VREF [0:5.12].

◆ adc22_return_value_t

ADC 22 Click return value data.

Predefined enum values for driver return values.

Enumerator
ADC22_OK 
ADC22_ERROR