39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
74#define ADC10_REG_CONFIG_0 0x00
75#define ADC10_REG_CONFIG_1 0x01
76#define ADC10_REG_CONFIG_2 0x02
77#define ADC10_REG_CONFIG_3 0x03
78#define ADC10_REG_CONFIG_4 0x04
97#define ADC10_SYNC_WORD 0x55
98#define ADC10_CMD_RESET 0x06
99#define ADC10_CMD_START 0x08
100#define ADC10_CMD_POWERDOWN 0x03
101#define ADC10_CMD_RDATA 0x10
102#define ADC10_CMD_RREG 0x20
103#define ADC10_CMD_WREG 0x40
110#define ADC10_REG0_MUX_P0_N1 0x00
111#define ADC10_REG0_MUX_P0_N2 0x01
112#define ADC10_REG0_MUX_P0_N3 0x02
113#define ADC10_REG0_MUX_P1_N0 0x03
114#define ADC10_REG0_MUX_P1_N2 0x04
115#define ADC10_REG0_MUX_P1_N3 0x05
116#define ADC10_REG0_MUX_P2_N3 0x06
117#define ADC10_REG0_MUX_P3_N2 0x07
118#define ADC10_REG0_MUX_P0_NS 0x08
119#define ADC10_REG0_MUX_P1_NS 0x09
120#define ADC10_REG0_MUX_P2_NS 0x0A
121#define ADC10_REG0_MUX_P3_NS 0x0B
122#define ADC10_REG0_MUX_VREF 0x0C
123#define ADC10_REG0_MUX_AVOLD_4 0x0D
124#define ADC10_REG0_MUX_AVOLAVER 0x0E
125#define ADC10_REG0_MUX_RESERVE 0x0F
132#define ADC10_REG0_GAIN_1 0x00
133#define ADC10_REG0_GAIN_2 0x01
134#define ADC10_REG0_GAIN_4 0x02
135#define ADC10_REG0_GAIN_8 0x03
136#define ADC10_REG0_GAIN_16 0x04
137#define ADC10_REG0_GAIN_32 0x05
138#define ADC10_REG0_GAIN_64 0x06
139#define ADC10_REG0_GAIN_128 0x07
146#define ADC10_REG0_PGA_ENABLED 0x00
147#define ADC10_REG0_PGA_DISABLED 0x01
154#define ADC10_REG1_DR_NORMAL_20 0x00
155#define ADC10_REG1_DR_NORMAL_45 0x01
156#define ADC10_REG1_DR_NORMAL_90 0x02
157#define ADC10_REG1_DR_NORMAL_175 0x03
158#define ADC10_REG1_DR_NORMAL_330 0x04
159#define ADC10_REG1_DR_NORMAL_600 0x05
160#define ADC10_REG1_DR_NORMAL_1000 0x06
161#define ADC10_REG1_DR_TURBO_40 0x00
162#define ADC10_REG1_DR_TURBO_90 0x01
163#define ADC10_REG1_DR_TURBO_180 0x02
164#define ADC10_REG1_DR_TURBO_350 0x03
165#define ADC10_REG1_DR_TURBO_660 0x04
166#define ADC10_REG1_DR_TURBO_1200 0x05
167#define ADC10_REG1_DR_TURBO_2000 0x06
174#define ADC10_REG1_MODE_NORMAL 0x00
175#define ADC10_REG1_MODE_TURBO 0x01
182#define ADC10_REG1_CM_SINGAL_SHOT 0x00
183#define ADC10_REG1_CM_CONTINUOUS 0x01
190#define ADC10_REG1_VREF_INTERNAL_2048 0x00
191#define ADC10_REG1_VREF_EXTERNAL_REF 0x01
192#define ADC10_REG1_VREF_ANALOG_1 0x02
193#define ADC10_REG1_VREF_ANALOG_2 0x03
200#define ADC10_REG1_TS_DISABLED 0x00
201#define ADC10_REG1_TS_ENABLED 0x01
208#define ADC10_REG2_DRDY_NOT_READY 0x00
209#define ADC10_REG2_DRDY_READY 0x01
216#define ADC10_REG2_DCNT_DISABLED 0x00
217#define ADC10_REG2_DCNT_ENABLED 0x01
224#define ADC10_REG2_CRC_DISABLED 0x00
225#define ADC10_REG2_CRC_INVERTED_ENABLED 0x01
226#define ADC10_REG2_CRC_CRC16_ENABLED 0x02
227#define ADC10_REG2_CRC_RESERVED 0x03
234#define ADC10_REG2_BCS_CURRENT_SOURCE_OFF 0x00
235#define ADC10_REG2_BCS_CURRENT_SOURCE_ON 0x01
242#define ADC10_REG2_IDAC_CURRENT_OFF 0x00
243#define ADC10_REG2_IDAC_CURRENT_10_uA 0x01
244#define ADC10_REG2_IDAC_CURRENT_50_uA 0x02
245#define ADC10_REG2_IDAC_CURRENT_100_uA 0x03
246#define ADC10_REG2_IDAC_CURRENT_250_uA 0x04
247#define ADC10_REG2_IDAC_CURRENT_500_uA 0x05
248#define ADC10_REG2_IDAC_CURRENT_1000_uA 0x06
249#define ADC10_REG2_IDAC_CURRENT_1500_uA 0x07
256#define ADC10_REG3_L1MUX_DISABLED 0x00
257#define ADC10_REG3_L1MUX_TO_AIN0 0x01
258#define ADC10_REG3_L1MUX_TO_AIN1 0x02
259#define ADC10_REG3_L1MUX_TO_AIN2 0x03
260#define ADC10_REG3_L1MUX_TO_AIN3 0x04
261#define ADC10_REG3_L1MUX_TO_REFP 0x05
262#define ADC10_REG3_L1MUX_TO_REFN 0x06
263#define ADC10_REG3_L1MUX_RESERVED 0x07
270#define ADC10_REG3_L2MUX_DISABLED 0x00
271#define ADC10_REG3_L2MUX_TO_AIN0 0x01
272#define ADC10_REG3_L2MUX_TO_AIN1 0x02
273#define ADC10_REG3_L2MUX_TO_AIN2 0x03
274#define ADC10_REG3_L2MUX_TO_AIN3 0x04
275#define ADC10_REG3_L2MUX_TO_REFP 0x05
276#define ADC10_REG3_L2MUX_TO_REFN 0x06
283#define ADC10_REG3_DATA_MODE_MANUAL 0x00
284#define ADC10_REG3_DATA_MODE_AUTO 0x01
291#define ADC10_REG4_GPIO2_DIR_INPUT 0x00
292#define ADC10_REG4_GPIO2_DIR_OUTPUT 0x01
293#define ADC10_REG4_GPIO1_DIR_INPUT 0x00
294#define ADC10_REG4_GPIO1_DIR_OUTPUT 0x01
295#define ADC10_REG4_GPIO0_DIR_INPUT 0x00
296#define ADC10_REG4_GPIO0_DIR_OUTPUT 0x01
303#define ADC10_REG4_GPIO2_SEL_DAT 0x00
304#define ADC10_REG4_GPIO2_SEL_DRDY 0x01
311#define ADC10_REG4_GPIO_LOW 0x00
312#define ADC10_REG4_GPIO_HIGH 0x01
318#define ADC10_ANALOG_INPUT_CH_0 0x00
319#define ADC10_ANALOG_INPUT_CH_1 0x01
320#define ADC10_ANALOG_INPUT_CH_2 0x02
321#define ADC10_ANALOG_INPUT_CH_3 0x03
327#define ADC10_NEW_DATA_IS_READY 0x00
328#define ADC10_NEW_DATA_NOT_READY 0x01
334#define ADC10_GAIN_1 1
335#define ADC10_GAIN_2 2
336#define ADC10_GAIN_4 4
337#define ADC10_GAIN_8 8
338#define ADC10_GAIN_16 16
339#define ADC10_GAIN_32 32
340#define ADC10_GAIN_64 64
341#define ADC10_GAIN_128 128
347#define ADC10_REG_BITS 0x0E
348#define ADC10_ADC_RESOLUTION 0x007FFFFF
349#define ADC10_VREF_INTERNAL 2048.0
350#define ADC10_VREF_EXTERNAL_3300_mA 3300.0
351#define ADC10_VREF_EXTERNAL_5000_mA 5000.0
359#define DRV_BUFFER_SIZE 200
377#define ADC10_MAP_MIKROBUS( cfg, mikrobus ) \
378 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
379 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
380 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
381 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
#define DRV_BUFFER_SIZE
ADC 10 driver buffer size.
Definition adc10.h:359
uint8_t adc10_read_reg(adc10_t *ctx, uint8_t reg)
ADC 10 Read register function.
int32_t adc10_get_ch_output(adc10_t *ctx, uint8_t sel_ch)
ADC 10 Get the channel output function.
void adc10_write_reg(adc10_t *ctx, uint8_t reg, uint8_t tx_data)
ADC 10 Write register function.
float adc10_calc_voltage(adc10_t *ctx, int32_t adc_data, float vref, uint8_t gain)
ADC 10 Calculate the voltage function.
void adc10_get_config(adc10_t *ctx, adc10_settings_t *cfg_data)
ADC 10 Get configuration function.
void adc10_start_sync(adc10_t *ctx)
ADC 10 Start the synchronization function.
void adc10_set_config(adc10_t *ctx, adc10_settings_t cfg_data)
ADC 10 Set configuration function.
void adc10_send_command(adc10_t *ctx, uint8_t cmd)
ADC 10 Send command function.
err_t adc10_generic_read(adc10_t *ctx, char *data_buf, uint16_t max_len)
ADC 10 data reading function.
void adc10_reset(adc10_t *ctx)
ADC 10 Software reset function.
err_t adc10_init(adc10_t *ctx, adc10_cfg_t *cfg)
ADC 10 initialization function.
void adc10_cfg_setup(adc10_cfg_t *cfg)
ADC 10 configuration object setup function.
err_t adc10_generic_write(adc10_t *ctx, char *data_buf, uint16_t len)
ADC 10 data writing function.
void adc10_shutdown(adc10_t *ctx)
ADC 10 Shutdown function.
void adc10_hw_reset(adc10_t *ctx)
ADC 10 Hardware reset function.
uint8_t adc10_check_drdy(adc10_t *ctx)
ADC 10 Check DRDY function.
void adc10_default_cfg(adc10_t *ctx)
ADC 10 default configuration function.
ADC 10 Click configuration object.
Definition adc10.h:416
uint32_t baud_rate
Definition adc10.h:429
bool uart_blocking
Definition adc10.h:430
uart_data_bits_t data_bit
Definition adc10.h:431
pin_name_t tx_pin
Definition adc10.h:420
pin_name_t rx_pin
Definition adc10.h:419
uart_stop_bits_t stop_bit
Definition adc10.h:433
pin_name_t int_pin
Definition adc10.h:425
uart_parity_t parity_bit
Definition adc10.h:432
pin_name_t rst
Definition adc10.h:424
uint8_t gpio2_io_lvl
Definition adc10.h:459
uint8_t idac2_routing
Definition adc10.h:453
uint8_t conv_drdy
Definition adc10.h:447
uint8_t b_current_src
Definition adc10.h:450
uint8_t gpio1_io_lvl
Definition adc10.h:460
uint8_t input_mux
Definition adc10.h:439
uint8_t pga_bypass
Definition adc10.h:441
uint8_t idac_current
Definition adc10.h:451
uint8_t gain
Definition adc10.h:440
uint8_t gpio1_ctrl
Definition adc10.h:456
uint8_t gpio2_drdy_ctrl
Definition adc10.h:458
uint8_t adc_data_out_mode
Definition adc10.h:454
uint8_t data_rate
Definition adc10.h:442
uint8_t gpio0_ctrl
Definition adc10.h:457
uint8_t data_integ_check
Definition adc10.h:449
uint8_t vref
Definition adc10.h:445
uint8_t idac1_routing
Definition adc10.h:452
uint8_t data_cnt
Definition adc10.h:448
uint8_t temp_sensor
Definition adc10.h:446
uint8_t gpio2_ctrl
Definition adc10.h:455
uint8_t gpio0_io_lvl
Definition adc10.h:461
uint8_t op_mode
Definition adc10.h:443
uint8_t conv_mode
Definition adc10.h:444
ADC 10 Click context object.
Definition adc10.h:391
uart_t uart
Definition adc10.h:402
digital_in_t int_pin
Definition adc10.h:398
digital_out_t rst
Definition adc10.h:394