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 HODCAP_REG_SENSOR_ID 0x01
75#define HODCAP_REG_STATUS 0x02
76#define HODCAP_REG_I_DATA 0x03
77#define HODCAP_REG_Q_DATA 0x04
78#define HODCAP_REG_ADC_STATUS 0x05
79#define HODCAP_REG_EDIV 0x20
80#define HODCAP_REG_FREQ 0x21
81#define HODCAP_REG_TXV 0x22
82#define HODCAP_REG_MUX_CTRL 0x23
83#define HODCAP_REG_SDG 0x24
84#define HODCAP_REG_CBG 0x25
85#define HODCAP_REG_DCLK 0x26
86#define HODCAP_REG_PGA 0x27
87#define HODCAP_REG_PGA_OFFSET_I 0x28
88#define HODCAP_REG_PGA_OFFSET_Q 0x29
89#define HODCAP_REG_ADCTL 0x2A
90#define HODCAP_REG_BLANK 0x2B
91#define HODCAP_REG_DIAG_MUX_CTRL 0x2C
92#define HODCAP_REG_QUICK_READ 0x90
98#define HODCAP_CMD_WRITE 0x10
99#define HODCAP_CMD_READ 0x00
100#define HODCAP_CMD_QUICK_READ 0x90
118#define HODCAP_SENSOR_ID 0xA431u
124#define HODCAP_ADC_DATA_READY 0x0001u
130#define HODCAP_SET_EDIV_12 0x0000u
131#define HODCAP_SET_EDIV_11 0x0001u
132#define HODCAP_SET_EDIV_10 0x0002u
133#define HODCAP_SET_EDIV_9 0x0003u
134#define HODCAP_SET_EDIV_8 0x0004u
135#define HODCAP_SET_EDIV_7 0x0005u
136#define HODCAP_SET_EDIV_6 0x0006u
137#define HODCAP_SET_EDIV_5 0x0007u
138#define HODCAP_SET_EDIV_4 0x0008u
139#define HODCAP_SET_EDIV_3 0x0009u
140#define HODCAP_SET_EDIV_2 0x000Au
141#define HODCAP_SET_EDIV_1 0x000Bu
142#define HODCAP_SET_EDIV_BIT_MASK 0x000Fu
148#define HODCAP_SET_FREQ_45_45KHZ 0x0000u
149#define HODCAP_SET_FREQ_71_4KHZ 0x0001u
150#define HODCAP_SET_FREQ_100KHZ 0x0002u
151#define HODCAP_SET_FREQ_125KHZ 0x0003u
157#define HODCAP_SET_TXV_0V 0x0000u
158#define HODCAP_SET_TXV_0_5V 0x0001u
159#define HODCAP_SET_TXV_1V 0x0002u
165#define HODCAP_SET_MUX_CTRL_MODE_OPEN 0x0000u
166#define HODCAP_SET_MUX_CTRL_MODE_SENSOR_DRV 0x0001u
167#define HODCAP_SET_MUX_CTRL_MODE_COMMON 0x0002u
168#define HODCAP_SET_MUX_CTRL_MODE_NO_OP 0x0003u
169#define HODCAP_SET_MUX_CTRL_SEL_SEN0 0x0000u
170#define HODCAP_SET_MUX_CTRL_SEL_SEN1 0x0004u
171#define HODCAP_SET_MUX_CTRL_SEL_SEN2 0x0008u
172#define HODCAP_SET_MUX_CTRL_SEL_SEN3 0x000Cu
173#define HODCAP_SET_MUX_CTRL_SEL_SEN4 0x0010u
174#define HODCAP_SET_MUX_CTRL_SEL_SEN5 0x0014u
175#define HODCAP_SET_MUX_CTRL_SEL_SEN6 0x0018u
176#define HODCAP_SET_MUX_CTRL_SEL_SEN7 0x001Cu
177#define HODCAP_SET_MUX_CTRL_SEL_SEN8 0x0020u
178#define HODCAP_SET_MUX_CTRL_SEL_SEN9 0x0024u
179#define HODCAP_SET_MUX_CTRL_SEL_NONE 0x0028u
180#define HODCAP_SET_MUX_CTRL_SEL_VAR_SEN 0x002Cu
181#define HODCAP_SET_MUX_CTRL_SEL_BIT_MASK 0x003Cu
187#define HODCAP_TOTAL_NUMBER_OF_CHANNELS 10
193#define HODCAP_SET_PGA_GAIN_36 0x0000u
194#define HODCAP_SET_PGA_GAIN_24 0x0001u
195#define HODCAP_SET_PGA_GAIN_16 0x0002u
196#define HODCAP_SET_PGA_GAIN_10_67 0x0003u
197#define HODCAP_SET_PGA_GAIN_7_11 0x0004u
198#define HODCAP_SET_PGA_GAIN_4_74 0x0005u
199#define HODCAP_SET_PGA_GAIN_3_16 0x0006u
200#define HODCAP_SET_PGA_GAIN_2_11 0x0007u
206#define HODCAP_SET_DEFAULT_PGA_OFFSET_I 96
207#define HODCAP_SET_DEFAULT_PGA_OFFSET_Q 144
213#define HODCAP_SET_ADCTL_MODE_RESET_STOP 0x0000u
214#define HODCAP_SET_ADCTL_MODE_START_SINGLE_CONVO 0x0001u
215#define HODCAP_SET_ADCTL_MODE_START_CONT_CONVO 0x0002u
216#define HODCAP_SET_ADCTL_MODE_STOP_CURRENT_CONVO 0x0003u
217#define HODCAP_SET_ADCTL_MODE_BIT_MASK 0x0003u
218#define HODCAP_SET_ADCTL_CS_CLK_250KHZ 0x0000u
219#define HODCAP_SET_ADCTL_CS_CLK_500KHZ 0x0004u
220#define HODCAP_SET_ADCTL_CS_CLK_1000KHZ 0x0008u
221#define HODCAP_SET_ADCTL_ACCU_NUMB_OF_SAMPLES_4 0x0000u
222#define HODCAP_SET_ADCTL_ACCU_NUMB_OF_SAMPLES_8 0x0010u
223#define HODCAP_SET_ADCTL_ACCU_NUMB_OF_SAMPLES_16 0x0020u
224#define HODCAP_SET_ADCTL_TS_400US 0x0000u
225#define HODCAP_SET_ADCTL_TS_576US 0x0040u
226#define HODCAP_SET_ADCTL_TS_664US 0x0080u
232#define HODCAP_SET_MUX_CTRL_PLUS_SEN0 0x0000u
233#define HODCAP_SET_MUX_CTRL_PLUS_SEN1 0x0001u
234#define HODCAP_SET_MUX_CTRL_PLUS_SEN2 0x0002u
235#define HODCAP_SET_MUX_CTRL_PLUS_SEN3 0x0003u
236#define HODCAP_SET_MUX_CTRL_PLUS_SEN4 0x0004u
237#define HODCAP_SET_MUX_CTRL_PLUS_SEN5 0x0005u
238#define HODCAP_SET_MUX_CTRL_PLUS_SEN6 0x0006u
239#define HODCAP_SET_MUX_CTRL_PLUS_SEN7 0x0007u
240#define HODCAP_SET_MUX_CTRL_PLUS_SEN8 0x0008u
241#define HODCAP_SET_MUX_CTRL_PLUS_SEN9 0x0009u
242#define HODCAP_SET_MUX_CTRL_PLUS_VAR_SEN 0x000Bu
243#define HODCAP_SET_MUX_CTRL_PLUS_NONE 0x000Fu
244#define HODCAP_SET_MUX_CTRL_MINUS_SEN0 0x0000u
245#define HODCAP_SET_MUX_CTRL_MINUS_SEN1 0x0010u
246#define HODCAP_SET_MUX_CTRL_MINUS_SEN2 0x0020u
247#define HODCAP_SET_MUX_CTRL_MINUS_SEN3 0x0030u
248#define HODCAP_SET_MUX_CTRL_MINUS_SEN4 0x0040u
249#define HODCAP_SET_MUX_CTRL_MINUS_SEN5 0x0050u
250#define HODCAP_SET_MUX_CTRL_MINUS_SEN6 0x0060u
251#define HODCAP_SET_MUX_CTRL_MINUS_SEN7 0x0070u
252#define HODCAP_SET_MUX_CTRL_MINUS_SEN8 0x0080u
253#define HODCAP_SET_MUX_CTRL_MINUS_SEN9 0x0090u
254#define HODCAP_SET_MUX_CTRL_MINUS_VAR_SEN 0x00B0u
255#define HODCAP_SET_MUX_CTRL_MINUS_NONE 0x00F0u
265#define HODCAP_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
266#define HODCAP_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
284#define HODCAP_MAP_MIKROBUS( cfg, mikrobus ) \
285 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
286 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
287 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
288 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
289 cfg.clk = MIKROBUS( mikrobus, MIKROBUS_PWM )
err_t hodcap_wait_adc_data_ready(hodcap_t *ctx)
HOD CAP wait ADC data ready function.
err_t hodcap_get_i_q_data(hodcap_t *ctx, uint16_t *i_data, uint16_t *q_data)
HOD CAP gets the I and Q data function.
err_t hodcap_init(hodcap_t *ctx, hodcap_cfg_t *cfg)
HOD CAP initialization function.
err_t hodcap_set_adc_op_mode(hodcap_t *ctx, uint16_t adc_op_mode)
HOD CAP sets the ADC operation mode function.
err_t hodcap_generic_read(hodcap_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
HOD CAP data reading function.
err_t hodcap_get_status(hodcap_t *ctx, hodcap_status_t *status)
HOD CAP gets sensor status function.
err_t hodcap_default_cfg(hodcap_t *ctx)
HOD CAP default configuration function.
err_t hodcap_check_adc_data_ready(hodcap_t *ctx, uint16_t *data_ready)
HOD CAP check ADC data ready function.
err_t hodcap_read_reg(hodcap_t *ctx, uint8_t reg, uint16_t *data_out)
HOD CAP read register function.
err_t hodcap_get_sensor_id(hodcap_t *ctx, uint16_t *sensor_id)
HOD CAP gets sensor ID function.
err_t hodcap_write_reg(hodcap_t *ctx, uint8_t reg, uint16_t data_in)
HOD CAP write register function.
err_t hodcap_generic_write(hodcap_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
HOD CAP data writing function.
void hodcap_set_clk_state(hodcap_t *ctx, uint8_t clk_state)
HOD CAP set CLK pin state function.
err_t hodcap_mux_channel_selection(hodcap_t *ctx, uint8_t sen_pos)
HOD CAP MUX channel selection function.
void hodcap_cfg_setup(hodcap_cfg_t *cfg)
HOD CAP configuration object setup function.
hodcap_return_value_t
HOD CAP Click return value data.
Definition hodcap.h:360
@ HODCAP_OK
Definition hodcap.h:361
@ HODCAP_ERROR
Definition hodcap.h:362
This file contains SPI specific macros, functions, etc.
HOD CAP Click configuration object.
Definition hodcap.h:315
pin_name_t clk
Definition hodcap.h:323
spi_master_chip_select_polarity_t cs_polarity
Definition hodcap.h:328
pin_name_t sck
Definition hodcap.h:319
spi_master_mode_t spi_mode
Definition hodcap.h:327
pin_name_t mosi
Definition hodcap.h:318
uint32_t spi_speed
Definition hodcap.h:326
pin_name_t miso
Definition hodcap.h:317
pin_name_t cs
Definition hodcap.h:320
HOD CAP Click status object.
Definition hodcap.h:337
uint8_t r_ediv
Definition hodcap.h:338
uint8_t cbf
Definition hodcap.h:351
uint8_t tx2f
Definition hodcap.h:347
uint8_t ppsf
Definition hodcap.h:340
uint8_t tx1f
Definition hodcap.h:346
uint8_t bpff
Definition hodcap.h:341
uint8_t pga2f
Definition hodcap.h:349
uint8_t nclk
Definition hodcap.h:350
uint8_t pga1f
Definition hodcap.h:348
uint8_t test
Definition hodcap.h:345
uint8_t ocsen
Definition hodcap.h:344
uint8_t otpf
Definition hodcap.h:339
uint8_t regf
Definition hodcap.h:342
uint8_t ocsld
Definition hodcap.h:343
HOD CAP Click context object.
Definition hodcap.h:299
spi_master_t spi
Definition hodcap.h:304
digital_out_t clk
Definition hodcap.h:301
pin_name_t chip_select
Definition hodcap.h:306