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 LDC_REG_DATA_CH0 0x00
74#define LDC_REG_DATA_CH1 0x02
75#define LDC_REG_RCOUNT_CH0 0x08
76#define LDC_REG_RCOUNT_CH1 0x09
77#define LDC_REG_OFFSET_CH0 0x0C
78#define LDC_REG_OFFSET_CH1 0x0D
79#define LDC_REG_SETTLECOUNT_CH0 0x10
80#define LDC_REG_SETTLECOUNT_CH1 0x11
81#define LDC_REG_CLOCK_DIVIDERS_CH0 0x14
82#define LDC_REG_CLOCK_DIVIDERS_CH1 0x15
83#define LDC_REG_STATUS 0x18
84#define LDC_REG_ERROR_CONFIG 0x19
85#define LDC_REG_CONFIG 0x1A
86#define LDC_REG_MUX_CONFIG 0x1B
87#define LDC_REG_RESET_DEV 0x1C
88#define LDC_REG_DRIVE_CURRENT_CH0 0x1E
89#define LDC_REG_DRIVE_CURRENT_CH1 0x1F
90#define LDC_REG_MANUFACTURER_ID 0x7E
91#define LDC_REG_DEVICE_ID 0x7F
109#define LDC_MANUFACTURER_ID 0x5449
110#define LDC_DEVICE_ID 0x3054
116#define LDC_INTERNAL_FREQUENCY 43.4
117#define LDC_FREQUENCY_RESOLUTION 4096
118#define LDC_SENSOR_CAPACITANCE 0.00022
119#define LDC_MATH_TWO_PI 6.28318530717958
125#define LDC_GAIN_1 0x0000
126#define LDC_GAIN_4 0x0200
127#define LDC_GAIN_8 0x0400
128#define LDC_GAIN_16 0x0600
134#define LDC_OVER_RANGE 0x8
135#define LDC_UNDER_RANGE 0x4
136#define LDC_WATCHDOG 0x3
142#define LDC_STATUS_DRDY 0x0040
149#define LDC_SET_DEV_ADDR 0x2B
167#define LDC_MAP_MIKROBUS( cfg, mikrobus ) \
168 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
169 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
170 cfg.sd = MIKROBUS( mikrobus, MIKROBUS_RST ); \
171 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t ldc_generic_read(ldc_t *ctx, uint8_t reg, uint16_t *rx_data)
LDC I2C reading function.
void ldc_set_shut_down(ldc_t *ctx, uint8_t state)
Set shut down pin status.
err_t ldc_init(ldc_t *ctx, ldc_cfg_t *cfg)
LDC initialization function.
float ldc_calculate_inductance(float frequency)
Calculate inductance relative to frequency.
void ldc_cfg_setup(ldc_cfg_t *cfg)
LDC configuration object setup function.
err_t ldc_generic_write(ldc_t *ctx, uint8_t reg, uint16_t tx_data)
LDC I2C writing function.
err_t ldc_get_frequency(ldc_t *ctx, uint8_t channel, uint16_t divider, float *frequency)
Get frequency value calulated for specific channel.
uint8_t ldc_get_interrupt(ldc_t *ctx)
Get interrupt pin status.
err_t ldc_default_cfg(ldc_t *ctx)
LDC default configuration function.
ldc_return_value_t
LDC Click return value data.
Definition ldc.h:218
@ LDC_ERROR_WATCHDOG
Definition ldc.h:223
@ LDC_ERROR_UNDER_RANGE
Definition ldc.h:221
@ LDC_ERROR
Definition ldc.h:220
@ LDC_ERROR_OVER_RANGE
Definition ldc.h:222
@ LDC_OK
Definition ldc.h:219
uint16_t divider
Definition main.c:37
LDC Click configuration object.
Definition ldc.h:201
pin_name_t sd
Definition ldc.h:205
uint32_t i2c_speed
Definition ldc.h:208
pin_name_t scl
Definition ldc.h:202
pin_name_t int_pin
Definition ldc.h:206
pin_name_t sda
Definition ldc.h:203
uint8_t i2c_address
Definition ldc.h:209
LDC Click context object.
Definition ldc.h:181
digital_out_t sd
Definition ldc.h:183
digital_in_t int_pin
Definition ldc.h:186
i2c_master_t i2c
Definition ldc.h:189
uint8_t slave_address
Definition ldc.h:192