Go to the documentation of this file.
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_i2c_master.h"
73 #define ADC16_OPCODE_SINGLE_READ 0x10
74 #define ADC16_OPCODE_SINGLE_WRITE 0x08
75 #define ADC16_OPCODE_SET_BIT 0x18
76 #define ADC16_OPCODE_CLEAR_BIT 0x20
77 #define ADC16_OPCODE_CONTINUOUS_READ 0x30
78 #define ADC16_OPCODE_CONTINUOUS_WRITE 0x28
84 #define ADC16_REG_OPMODE_I2CMODE_STATUS 0x00
85 #define ADC16_REG_DATA_BUFFER_STATUS 0x01
86 #define ADC16_REG_ACCUMULATOR_STATUS 0x02
87 #define ADC16_REG_ALERT_TRIG_CHID 0x03
88 #define ADC16_REG_SEQUENCE_STATUS 0x04
89 #define ADC16_REG_ACC_CH0_LSB 0x08
90 #define ADC16_REG_ACC_CH0_MSB 0x09
91 #define ADC16_REG_ACC_CH1_LSB 0x0A
92 #define ADC16_REG_ACC_CH1_MSB 0x0B
93 #define ADC16_REG_ALERT_LOW_FLAGS 0x0C
94 #define ADC16_REG_ALERT_HIGH_FLAGS 0x0E
95 #define ADC16_REG_DEVICE_RESET 0x14
96 #define ADC16_REG_OFFSET_CAL 0x15
97 #define ADC16_REG_WKEY 0x17
98 #define ADC16_REG_OSC_SEL 0x18
99 #define ADC16_REG_NCLK_SEL 0x19
100 #define ADC16_REG_OPMODE_SEL 0x1C
101 #define ADC16_REG_START_SEQUENCE 0x1E
102 #define ADC16_REG_ABORT_SEQUENCE 0x1F
103 #define ADC16_REG_AUTO_SEQ_CHEN 0x20
104 #define ADC16_REG_CH_INPUT_CFG 0x24
105 #define ADC16_REG_DOUT_FORMAT_CFG 0x28
106 #define ADC16_REG_DATA_BUFFER_OPMODE 0x2C
107 #define ADC16_REG_ACC_EN 0x30
108 #define ADC16_REG_ALERT_CHEN 0x34
109 #define ADC16_REG_PRE_ALT_MAX_EVENT_COUNT 0x36
110 #define ADC16_REG_ALERT_DWC_EN 0x37
111 #define ADC16_REG_DWC_HTH_CH0_LSB 0x38
112 #define ADC16_REG_DWC_HTH_CH0_MSB 0x39
113 #define ADC16_REG_DWC_LTH_CH0_LSB 0x3A
114 #define ADC16_REG_DWC_LTH_CH0_MSB 0x3B
115 #define ADC16_REG_DWC_HTH_CH1_LSB 0x3C
116 #define ADC16_REG_DWC_HTH_CH1_MSB 0x3D
117 #define ADC16_REG_DWC_LTH_CH1_LSB 0x3E
118 #define ADC16_REG_DWC_LTH_CH1_MSB 0x3F
119 #define ADC16_REG_DWC_HYS_CH0 0x40
120 #define ADC16_REG_DWC_HYS_CH1 0x41
138 #define ADC16_WKEY_UNLOCK 0x0A
139 #define ADC16_WKEY_LOCK 0x00
145 #define ADC16_DEVICE_RESET 0x01
151 #define ADC16_START_CALIBRATION 0x01
157 #define ADC16_CH_CFG_TWO_CH_SINGLE_END 0x00
158 #define ADC16_CH_CFG_SIN_CH_SINGLE_END_RMT_GND 0x01
159 #define ADC16_CH_CFG_SIN_CH_SINGLE_END_PSEUDO_DIFF 0x02
165 #define ADC16_OPMODE_SEL_MAN_WITH_CH0 0x00
166 #define ADC16_OPMODE_SEL_MAN_WITH_AUTO_SEQ 0x04
167 #define ADC16_OPMODE_SEL_AUTO_WITH_AUTO_SEQ 0x06
168 #define ADC16_OPMODE_SEL_HIGH_PREC_WITH_AUTO_SEQ 0x07
174 #define ADC16_AUTOSEQ_EN_CH0 0x01
175 #define ADC16_AUTOSEQ_EN_CH1 0x02
176 #define ADC16_AUTOSEQ_EN_BOTH_CH 0x03
182 #define ADC16_START_SEQUENCE 0x01
183 #define ADC16_ABORT_SEQUENCE 0x01
189 #define ADC16_RESOLUTION 0x0FFF
190 #define ADC16_VREF 3.3
197 #define ADC16_DEV_ADDR_R1_0_R2_DNP 0x1F
198 #define ADC16_DEV_ADDR_R1_11K_R2_DNP 0x1E
199 #define ADC16_DEV_ADDR_R1_33K_R2_DNP 0x1D
200 #define ADC16_DEV_ADDR_R1_100K_R2_DNP 0x1C
201 #define ADC16_DEV_ADDR_R1_DNP_R2_DNP 0x18
202 #define ADC16_DEV_ADDR_R1_DNP_R2_11K 0x19
203 #define ADC16_DEV_ADDR_R1_DNP_R2_33K 0x1A
204 #define ADC16_DEV_ADDR_R1_DNP_R2_100K 0x1B
222 #define ADC16_MAP_MIKROBUS( cfg, mikrobus ) \
223 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
224 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
225 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_AN ); \
226 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
uint32_t i2c_speed
Definition: adc16.h:261
err_t adc16_single_register_read(adc16_t *ctx, uint8_t reg, uint8_t *data_out)
ADC 16 single register read function.
err_t adc16_init(adc16_t *ctx, adc16_cfg_t *cfg)
ADC 16 initialization function.
err_t adc16_set_register_bits(adc16_t *ctx, uint8_t reg, uint8_t bit_mask)
ADC 16 set register bits function.
adc16_return_value_t
ADC 16 Click return value data.
Definition: adc16.h:271
pin_name_t alr
Definition: adc16.h:259
@ ADC16_OK
Definition: adc16.h:272
uint8_t adc16_get_alr_pin(adc16_t *ctx)
ADC 16 get alr pin function.
err_t adc16_continuous_register_read(adc16_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
ADC 16 continuous register read function.
err_t adc16_get_voltage(adc16_t *ctx, float *ain0_voltage, float *ain1_voltage)
ADC 16 get voltage function.
uint8_t adc16_get_rdy_pin(adc16_t *ctx)
ADC 16 get rdy pin function.
i2c_master_t i2c
Definition: adc16.h:242
err_t adc16_default_cfg(adc16_t *ctx)
ADC 16 default configuration function.
err_t adc16_continuous_register_write(adc16_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
ADC 16 continuous register write function.
ADC 16 Click configuration object.
Definition: adc16.h:254
uint8_t slave_address
Definition: adc16.h:245
ADC 16 Click context object.
Definition: adc16.h:236
uint8_t i2c_address
Definition: adc16.h:262
err_t adc16_clear_register_bits(adc16_t *ctx, uint8_t reg, uint8_t bit_mask)
ADC 16 clear register bits function.
pin_name_t scl
Definition: adc16.h:255
digital_in_t alr
Definition: adc16.h:239
pin_name_t rdy
Definition: adc16.h:258
digital_in_t rdy
Definition: adc16.h:238
void adc16_cfg_setup(adc16_cfg_t *cfg)
ADC 16 configuration object setup function.
@ ADC16_ERROR
Definition: adc16.h:273
pin_name_t sda
Definition: adc16.h:256
err_t adc16_single_register_write(adc16_t *ctx, uint8_t reg, uint8_t data_in)
ADC 16 single register write function.