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 ADC26_REG_CONVERSION 0x00
74 #define ADC26_REG_CONFIG 0x01
75 #define ADC26_REG_LO_THRESH 0x02
76 #define ADC26_REG_HI_THRESH 0x03
94 #define ADC26_CONFIG_OS_NO_EFFECT 0x0000
95 #define ADC26_CONFIG_OS_START_CONVERSION 0x8000
96 #define ADC26_CONFIG_OS_MASK 0x8000
97 #define ADC26_CONFIG_MUX_P_AIN0_N_AIN1 0x0000
98 #define ADC26_CONFIG_MUX_P_AIN0_N_AIN3 0x1000
99 #define ADC26_CONFIG_MUX_P_AIN1_N_AIN3 0x2000
100 #define ADC26_CONFIG_MUX_P_AIN2_N_AIN3 0x3000
101 #define ADC26_CONFIG_MUX_P_AIN0_N_GND 0x4000
102 #define ADC26_CONFIG_MUX_P_AIN1_N_GND 0x5000
103 #define ADC26_CONFIG_MUX_P_AIN2_N_GND 0x6000
104 #define ADC26_CONFIG_MUX_P_AIN3_N_GND 0x7000
105 #define ADC26_CONFIG_MUX_MASK 0x7000
106 #define ADC26_CONFIG_PGA_6_144V 0x0000
107 #define ADC26_CONFIG_PGA_4_096V 0x0200
108 #define ADC26_CONFIG_PGA_2_048V 0x0400
109 #define ADC26_CONFIG_PGA_1_024V 0x0600
110 #define ADC26_CONFIG_PGA_0_512V 0x0800
111 #define ADC26_CONFIG_PGA_0_256V 0x0A00
112 #define ADC26_CONFIG_PGA_MASK 0x0E00
113 #define ADC26_CONFIG_MODE_CONTINUOUS 0x0000
114 #define ADC26_CONFIG_MODE_SINGLE_SHOT 0x0100
115 #define ADC26_CONFIG_MODE_MASK 0x0100
116 #define ADC26_CONFIG_DR_128_SPS 0x0000
117 #define ADC26_CONFIG_DR_250_SPS 0x0020
118 #define ADC26_CONFIG_DR_490_SPS 0x0040
119 #define ADC26_CONFIG_DR_920_SPS 0x0060
120 #define ADC26_CONFIG_DR_1600_SPS 0x0080
121 #define ADC26_CONFIG_DR_2400_SPS 0x00A0
122 #define ADC26_CONFIG_DR_3300_SPS 0x00C0
123 #define ADC26_CONFIG_DR_MASK 0x00E0
124 #define ADC26_CONFIG_COMP_MODE_TRADITIONAL 0x0000
125 #define ADC26_CONFIG_COMP_MODE_WINDOW 0x0010
126 #define ADC26_CONFIG_COMP_MODE_MASK 0x0010
127 #define ADC26_CONFIG_COMP_POL_ACTIVE_LOW 0x0000
128 #define ADC26_CONFIG_COMP_POL_ACTIVE_HIGH 0x0008
129 #define ADC26_CONFIG_COMP_POL_MASK 0x0008
130 #define ADC26_CONFIG_COMP_LAT_NONLATCHING 0x0000
131 #define ADC26_CONFIG_COMP_LAT_LATCHING 0x0004
132 #define ADC26_CONFIG_COMP_LAT_MASK 0x0004
133 #define ADC26_CONFIG_COMP_QUE_ONE_CONV 0x0000
134 #define ADC26_CONFIG_COMP_QUE_TWO_CONV 0x0001
135 #define ADC26_CONFIG_COMP_QUE_FOUR_CONV 0x0002
136 #define ADC26_CONFIG_COMP_QUE_DISABLE 0x0003
137 #define ADC26_CONFIG_COMP_QUE_MASK 0x0003
143 #define ADC26_MUX_P_AIN0_N_AIN1 0
144 #define ADC26_MUX_P_AIN0_N_AIN3 1
145 #define ADC26_MUX_P_AIN1_N_AIN3 2
146 #define ADC26_MUX_P_AIN2_N_AIN3 3
147 #define ADC26_MUX_P_AIN0_N_GND 4
148 #define ADC26_MUX_P_AIN1_N_GND 5
149 #define ADC26_MUX_P_AIN2_N_GND 6
150 #define ADC26_MUX_P_AIN3_N_GND 7
156 #define ADC26_PGA_0_256V 0
157 #define ADC26_PGA_0_512V 1
158 #define ADC26_PGA_1_024V 2
159 #define ADC26_PGA_2_048V 3
160 #define ADC26_PGA_4_096V 4
166 #define ADC26_ADC_MIN ( -2048 )
167 #define ADC26_ADC_MAX ( 2047 )
173 #define ADC26_ADC_RESOLUTION 2048.0f
174 #define ADC26_ADC_GAIN_MIN 0.256f
181 #define ADC26_DEVICE_ADDRESS_GND 0x48
182 #define ADC26_DEVICE_ADDRESS_VCC 0x49
183 #define ADC26_DEVICE_ADDRESS_SDA 0x4A
184 #define ADC26_DEVICE_ADDRESS_SCL 0x4B
202 #define ADC26_MAP_MIKROBUS( cfg, mikrobus ) \
203 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
204 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
205 cfg.alert = MIKROBUS( mikrobus, MIKROBUS_INT )
digital_in_t alert
Definition: adc26.h:217
ADC 26 Click context object.
Definition: adc26.h:215
pin_name_t scl
Definition: adc26.h:233
err_t adc26_read_adc(adc26_t *ctx, int16_t *data_out)
ADC 26 read ADC function.
pin_name_t sda
Definition: adc26.h:234
pin_name_t alert
Definition: adc26.h:236
uint8_t adc26_get_alert_pin(adc26_t *ctx)
ADC 26 get alert pin function.
err_t adc26_read_reg(adc26_t *ctx, uint8_t reg, uint16_t *data_out)
ADC 26 read reg function.
uint32_t i2c_speed
Definition: adc26.h:238
@ ADC26_ERROR
Definition: adc26.h:250
adc26_return_value_t
ADC 26 Click return value data.
Definition: adc26.h:248
ADC 26 Click configuration object.
Definition: adc26.h:232
i2c_master_t i2c
Definition: adc26.h:220
uint8_t slave_address
Definition: adc26.h:223
err_t adc26_start_conversion(adc26_t *ctx, uint8_t mux, uint8_t pga)
ADC 26 start conversion function.
void adc26_cfg_setup(adc26_cfg_t *cfg)
ADC 26 configuration object setup function.
@ ADC26_OK
Definition: adc26.h:249
err_t adc26_write_threshold(adc26_t *ctx, int16_t lo_thresh, int16_t hi_thresh)
ADC 26 write threshold function.
err_t adc26_write_reg(adc26_t *ctx, uint8_t reg, uint16_t data_in)
ADC 26 write reg function.
err_t adc26_init(adc26_t *ctx, adc26_cfg_t *cfg)
ADC 26 initialization function.
err_t adc26_read_voltage(adc26_t *ctx, float *voltage)
ADC 26 read voltage function.
err_t adc26_default_cfg(adc26_t *ctx)
ADC 26 default configuration function.
uint8_t i2c_address
Definition: adc26.h:239