39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define ADC22_CMD_NOP 0x00
75#define ADC22_CMD_CLEAR_HWORD 0xC0
76#define ADC22_CMD_READ_HWORD 0xC8
77#define ADC22_CMD_READ 0x48
78#define ADC22_CMD_WRITE 0xD0
79#define ADC22_CMD_WRITE_MS 0xD2
80#define ADC22_CMD_WRITE_LS 0xD4
81#define ADC22_CMD_SET_HWORD 0xD8
99#define ADC22_REG_DEVICE_ID 0x02
100#define ADC22_REG_RST_PWRCTL_LSB 0x04
101#define ADC22_REG_RST_PWRCTL_MSB 0x05
102#define ADC22_REG_SDI_CTL 0x08
103#define ADC22_REG_SDO_CTL_LSB 0x0C
104#define ADC22_REG_SDO_CTL_MSB 0x0D
105#define ADC22_REG_DATAOUT_CTL_LSB 0x10
106#define ADC22_REG_DATAOUT_CTL_MSB 0x11
107#define ADC22_REG_RANGE_SEL 0x14
108#define ADC22_REG_ALARM_LSB 0x20
109#define ADC22_REG_ALARM_MSB 0x21
110#define ADC22_REG_ALARM_H_TH_LSB 0x24
111#define ADC22_REG_ALARM_H_TH_MSB 0x25
112#define ADC22_REG_ALARM_L_TH_LSB 0x28
113#define ADC22_REG_ALARM_L_TH_MSB 0x29
131#define ADC22_DEVICE_ADDR_MAX 16
137#define ADC22_SDO_MODE_SAME_SDI 1
138#define ADC22_SDO_MODE_INV 2
139#define ADC22_SDO_MODE_ADC_M_CLK 3
145#define ADC22_DATAOUT_CTL_VAL_CONV 0x00
146#define ADC22_DATAOUT_CTL_VAL_0_S 0x04
147#define ADC22_DATAOUT_CTL_VAL_1_S 0x05
148#define ADC22_DATAOUT_CTL_VAL_A_01_S 0x06
149#define ADC22_DATAOUT_CTL_VAL_A_0011_S 0x07
150#define ADC22_DATAOUT_CTL_PAR_DIS 0x00
151#define ADC22_DATAOUT_CTL_PAR_EN 0x08
157#define ADC22_ADC_ZERO_SCALE 2045u
158#define ADC22_ADC_MIDDLE_SCALE 2048.0f
159#define ADC22_ADC_FULL_SCALE 4096.0f
165#define ADC22_ADC_RANGE_12V28 12.28f
166#define ADC22_ADC_RANGE_10V24 10.24f
167#define ADC22_ADC_RANGE_6V14 6.14f
168#define ADC22_ADC_RANGE_5V12 5.12f
169#define ADC22_ADC_RANGE_2V56 2.56f
170#define ADC22_SET_RANGE_BIT_MASK 0x0F
176#define ADC22_PIN_STATE_LOW 0x00
177#define ADC22_PIN_STATE_HIGH 0x01
187#define ADC22_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
188#define ADC22_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
206#define ADC22_MAP_MIKROBUS( cfg, mikrobus ) \
207 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
208 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
209 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
210 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
211 cfg.rvs = MIKROBUS( mikrobus, MIKROBUS_AN ); \
212 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
213 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
adc22_return_value_t
ADC 22 Click return value data.
Definition adc22.h:267
@ ADC22_OK
Definition adc22.h:268
@ ADC22_ERROR
Definition adc22.h:269
adc22_range_sel_t
ADC 22 Click ADC ranges selections.
Definition adc22.h:278
@ ADC22_RANGE_5V12
Definition adc22.h:287
@ ADC22_RANGE_BI_2V56
Definition adc22.h:283
@ ADC22_RANGE_10V24
Definition adc22.h:285
@ ADC22_RANGE_6V14
Definition adc22.h:286
@ ADC22_RANGE_BI_6V14
Definition adc22.h:281
@ ADC22_RANGE_BI_12V28
Definition adc22.h:279
@ ADC22_RANGE_BI_5V12
Definition adc22.h:282
@ ADC22_RANGE_12V28
Definition adc22.h:284
@ ADC22_RANGE_BI_10V24
Definition adc22.h:280
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_range(adc22_t *ctx, uint8_t *range)
ADC 22 get range 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.
void adc22_hw_reset(adc22_t *ctx)
ADC 22 HW reset function.
err_t adc22_en_out_data_parity(adc22_t *ctx)
ADC 22 enable output data parity function.
err_t adc22_default_cfg(adc22_t *ctx)
ADC 22 default configuration function.
err_t adc22_get_device_id(adc22_t *ctx, uint8_t *device_id)
ADC 22 get device ID function.
uint8_t adc22_get_rvs(adc22_t *ctx)
ADC 22 get RVS function.
err_t adc22_get_voltage(adc22_t *ctx, float *voltage)
ADC 22 get voltage level function.
void adc22_cfg_setup(adc22_cfg_t *cfg)
ADC 22 configuration object setup function.
err_t adc22_set_device_addr(adc22_t *ctx, uint8_t device_addr)
ADC 22 set device address function.
err_t adc22_init(adc22_t *ctx, adc22_cfg_t *cfg)
ADC 22 initialization function.
uint8_t adc22_get_interrupt(adc22_t *ctx)
ADC 22 get interrupt function.
err_t adc22_set_range(adc22_t *ctx, adc22_range_sel_t range)
ADC 22 set range function.
err_t adc22_set_sdo_mode(adc22_t *ctx, uint8_t sdo_mode)
ADC 22 set SDO mode 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.
This file contains SPI specific macros, functions, etc.
ADC 22 Click configuration object.
Definition adc22.h:243
spi_master_chip_select_polarity_t cs_polarity
Definition adc22.h:258
pin_name_t sck
Definition adc22.h:247
spi_master_mode_t spi_mode
Definition adc22.h:257
pin_name_t mosi
Definition adc22.h:246
uint32_t spi_speed
Definition adc22.h:256
pin_name_t int_pin
Definition adc22.h:253
pin_name_t miso
Definition adc22.h:245
pin_name_t rst
Definition adc22.h:252
pin_name_t rvs
Definition adc22.h:251
pin_name_t cs
Definition adc22.h:248
ADC 22 Click context object.
Definition adc22.h:223
spi_master_t spi
Definition adc22.h:232
digital_in_t int_pin
Definition adc22.h:229
digital_out_t rst
Definition adc22.h:225
digital_in_t rvs
Definition adc22.h:228
pin_name_t chip_select
Definition adc22.h:234