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 ADC_REG_DEV_ID 0x00
75#define ADC_REG_REV_ID 0x01
76#define ADC_REG_STATUS 0x02
77#define ADC_REG_CONTROL 0x03
78#define ADC_REG_MUX 0x04
79#define ADC_REG_CONFIG1 0x05
80#define ADC_REG_CONFIG2 0x06
81#define ADC_REG_CONFIG3 0x07
82#define ADC_REG_CONFIG4 0x08
83#define ADC_REG_OFFSET2 0x09
84#define ADC_REG_OFFSET1 0x0A
85#define ADC_REG_OFFSET0 0x0B
86#define ADC_REG_GAIN2 0x0C
87#define ADC_REG_GAIN1 0x0D
88#define ADC_REG_GAIN0 0x0E
89#define ADC_REG_CRC 0x0F
102#define ADC_CMD_NO_OPERATION 0x00
103#define ADC_CMD_READ_REG 0x40
104#define ADC_CMD_WRITE_REG 0x80
122#define ADC23_INT_VREF_2_5V 2.5f
128#define ADC23_SET_CTRL_STOP 0x01
129#define ADC23_SET_CTRL_START 0x02
130#define ADC23_SET_CTRL_SW_RESET 0x58
131#define ADC23_MAX_REG_ADDR 0x0F
137#define ADC23_CONV_V_TO_MV 1000.0f
143#define ADC23_FULL_SCALE_OUT_DATA_RANGE 0x7FFFFFul
153#define ADC23_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
154#define ADC23_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
172#define ADC23_MAP_MIKROBUS( cfg, mikrobus ) \
173 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
174 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
175 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
176 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
177 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
178 cfg.str = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
179 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
adc23_return_value_t
ADC 23 Click return value data.
Definition adc23.h:237
@ ADC23_ERROR
Definition adc23.h:239
@ ADC23_OK
Definition adc23.h:238
err_t adc23_read_reg_cmd(adc23_t *ctx, uint8_t reg, uint16_t *data_out, uint8_t *reg_data_out)
ADC 23 read register command function.
err_t adc23_stop_conversion(adc23_t *ctx)
ADC 23 stop conversion function.
err_t adc23_default_cfg(adc23_t *ctx)
ADC 23 default configuration function.
err_t adc23_write_reg_data(adc23_t *ctx, uint8_t reg, uint8_t data_in, uint32_t *data_out)
ADC 23 write register data function.
void adc23_set_stop(adc23_t *ctx)
ADC 23 set stop function.
uint8_t adc23_get_data_ready(adc23_t *ctx)
ADC 23 get data ready function.
void adc23_set_start(adc23_t *ctx)
ADC 23 set start function.
err_t adc23_generic_read(adc23_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
ADC 23 data reading function.
err_t adc23_get_voltage(adc23_t *ctx, float *voltage)
ADC 23 read get voltage level function.
err_t adc23_init(adc23_t *ctx, adc23_cfg_t *cfg)
ADC 23 initialization function.
err_t adc23_read_reg_data(adc23_t *ctx, uint8_t reg, uint32_t *data_out, uint8_t *reg_data_out)
ADC 23 read register data function.
void adc23_hw_reset(adc23_t *ctx)
ADC 23 hardware reset function.
err_t adc23_start_conversion(adc23_t *ctx)
ADC 23 start conversion function.
void adc23_cfg_setup(adc23_cfg_t *cfg)
ADC 23 configuration object setup function.
err_t adc23_read_conversion_data(adc23_t *ctx, int32_t *adc_data)
ADC 23 read conversion data function.
err_t adc23_generic_write(adc23_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
ADC 23 data writing function.
err_t adc23_write_reg_cmd(adc23_t *ctx, uint8_t reg, uint8_t data_in, uint16_t *data_out)
ADC 23 write register command function.
err_t adc23_generic_transfer(adc23_t *ctx, uint8_t *data_in, uint8_t *data_out, uint8_t len)
ADC 23 data transfer function.
err_t adc23_sw_reset(adc23_t *ctx)
ADC 23 software reset function.
This file contains SPI specific macros, functions, etc.
ADC 23 Click configuration object.
Definition adc23.h:211
float vref
Definition adc23.h:228
spi_master_chip_select_polarity_t cs_polarity
Definition adc23.h:226
pin_name_t sck
Definition adc23.h:215
spi_master_mode_t spi_mode
Definition adc23.h:225
pin_name_t mosi
Definition adc23.h:214
uint32_t spi_speed
Definition adc23.h:224
pin_name_t rdy
Definition adc23.h:221
pin_name_t miso
Definition adc23.h:213
pin_name_t str
Definition adc23.h:220
pin_name_t rst
Definition adc23.h:219
pin_name_t cs
Definition adc23.h:216
ADC 23 Click context object.
Definition adc23.h:189
spi_master_t spi
Definition adc23.h:198
float vref
Definition adc23.h:202
digital_out_t rst
Definition adc23.h:191
digital_out_t str
Definition adc23.h:192
pin_name_t chip_select
Definition adc23.h:200
digital_in_t rdy
Definition adc23.h:195