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 LDCTOUCH_REG_STATUS 0x00
74#define LDCTOUCH_REG_OUT 0x01
75#define LDCTOUCH_REG_DATA0_LSB 0x02
76#define LDCTOUCH_REG_DATA0_MSB 0x03
77#define LDCTOUCH_REG_DATA1_LSB 0x04
78#define LDCTOUCH_REG_DATA1_MSB 0x05
79#define LDCTOUCH_REG_DATA2_LSB 0x06
80#define LDCTOUCH_REG_DATA2_MSB 0x07
81#define LDCTOUCH_REG_DATA3_LSB 0x08
82#define LDCTOUCH_REG_DATA3_MSB 0x09
83#define LDCTOUCH_REG_RESET 0x0A
84#define LDCTOUCH_REG_EN 0x0C
85#define LDCTOUCH_REG_NP_SCAN_RATE 0x0D
86#define LDCTOUCH_REG_GAIN0 0x0E
87#define LDCTOUCH_REG_LP_SCAN_RATE 0x0F
88#define LDCTOUCH_REG_GAIN1 0x10
89#define LDCTOUCH_REG_INTPOL 0x11
90#define LDCTOUCH_REG_GAIN2 0x12
91#define LDCTOUCH_REG_LP_BASE_INC 0x13
92#define LDCTOUCH_REG_GAIN3 0x14
93#define LDCTOUCH_REG_NP_BASE_INC 0x15
94#define LDCTOUCH_REG_BTPAUSE_MAXWIN 0x16
95#define LDCTOUCH_REG_LC_DIVIDER 0x17
96#define LDCTOUCH_REG_HYST 0x18
97#define LDCTOUCH_REG_TWIST 0x19
98#define LDCTOUCH_REG_COMMON_DEFORM 0x1A
99#define LDCTOUCH_REG_OPOL_DPOL 0x1C
100#define LDCTOUCH_REG_CNTSC 0x1E
101#define LDCTOUCH_REG_SENSOR0_CONFIG 0x20
102#define LDCTOUCH_REG_SENSOR1_CONFIG 0x22
103#define LDCTOUCH_REG_SENSOR2_CONFIG 0x24
104#define LDCTOUCH_REG_FTF0 0x25
105#define LDCTOUCH_REG_SENSOR3_CONFIG 0x26
106#define LDCTOUCH_REG_FTF1_2 0x28
107#define LDCTOUCH_REG_FTF3 0x2B
108#define LDCTOUCH_REG_RAW_DATA0_3 0x59
109#define LDCTOUCH_REG_RAW_DATA0_2 0x5A
110#define LDCTOUCH_REG_RAW_DATA0_1 0x5B
111#define LDCTOUCH_REG_RAW_DATA1_3 0x5C
112#define LDCTOUCH_REG_RAW_DATA1_2 0x5D
113#define LDCTOUCH_REG_RAW_DATA1_1 0x5E
114#define LDCTOUCH_REG_RAW_DATA2_3 0x5F
115#define LDCTOUCH_REG_RAW_DATA2_2 0x60
116#define LDCTOUCH_REG_RAW_DATA2_1 0x61
117#define LDCTOUCH_REG_RAW_DATA3_3 0x62
118#define LDCTOUCH_REG_RAW_DATA3_2 0x63
119#define LDCTOUCH_REG_RAW_DATA3_1 0x64
120#define LDCTOUCH_REG_MANUFACTURER_ID_LSB 0xFC
121#define LDCTOUCH_REG_MANUFACTURER_ID_MSB 0xFD
122#define LDCTOUCH_REG_DEVICE_ID_LSB 0xFE
123#define LDCTOUCH_REG_DEVICE_ID_MSB 0xFF
141#define LDCTOUCH_STATUS_OUT 0x80
142#define LDCTOUCH_STATUS_CHIP_READY 0x40
143#define LDCTOUCH_STATUS_READY_TO_WRITE 0x20
144#define LDCTOUCH_STATUS_MAXOUT 0x10
145#define LDCTOUCH_STATUS_FSM_WD 0x08
146#define LDCTOUCH_STATUS_LC_WD 0x04
147#define LDCTOUCH_STATUS_TIMEOUT 0x02
148#define LDCTOUCH_STATUS_REGISTER_FLAG 0x01
154#define LDCTOUCH_MODE_NORMAL 0x00
155#define LDCTOUCH_MODE_CONFIG 0x01
156#define LDCTOUCH_MODE_FULL_RESET 0x10
162#define LDCTOUCH_EN_CH3_LP 0x80
163#define LDCTOUCH_EN_CH2_LP 0x40
164#define LDCTOUCH_EN_CH1_LP 0x20
165#define LDCTOUCH_EN_CH0_LP 0x10
166#define LDCTOUCH_EN_CH3_NP 0x08
167#define LDCTOUCH_EN_CH2_NP 0x04
168#define LDCTOUCH_EN_CH1_NP 0x02
169#define LDCTOUCH_EN_CH0_NP 0x01
175#define LDCTOUCH_OPOL3_ACTIVE_HIGH 0x80
176#define LDCTOUCH_OPOL3_ACTIVE_LOW 0x00
177#define LDCTOUCH_OPOL2_ACTIVE_HIGH 0x40
178#define LDCTOUCH_OPOL2_ACTIVE_LOW 0x00
179#define LDCTOUCH_OPOL1_ACTIVE_HIGH 0x20
180#define LDCTOUCH_OPOL1_ACTIVE_LOW 0x00
181#define LDCTOUCH_OPOL0_ACTIVE_HIGH 0x10
182#define LDCTOUCH_OPOL0_ACTIVE_LOW 0x00
183#define LDCTOUCH_DPOL3_DATA_INCREASES 0x08
184#define LDCTOUCH_DPOL3_DATA_DECREASES 0x00
185#define LDCTOUCH_DPOL2_DATA_INCREASES 0x04
186#define LDCTOUCH_DPOL2_DATA_DECREASES 0x00
187#define LDCTOUCH_DPOL1_DATA_INCREASES 0x02
188#define LDCTOUCH_DPOL1_DATA_DECREASES 0x00
189#define LDCTOUCH_DPOL0_DATA_INCREASES 0x01
190#define LDCTOUCH_DPOL0_DATA_DECREASES 0x00
196#define LDCTOUCH_BUTTON_MODE_FINGER 0x00
197#define LDCTOUCH_BUTTON_MODE_METAL 0x01
198#define LDCTOUCH_BUTTON_MODE LDCTOUCH_BUTTON_MODE_FINGER
204#define LDCTOUCH_MANUFACTURER_ID_LSB 0x49
205#define LDCTOUCH_MANUFACTURER_ID_MSB 0x54
206#define LDCTOUCH_DEVICE_ID_LSB 0x00
207#define LDCTOUCH_DEVICE_ID_MSB 0x40
214#define LDCTOUCH_DEVICE_ADDRESS 0x2A
232#define LDCTOUCH_MAP_MIKROBUS( cfg, mikrobus ) \
233 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
234 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
235 cfg.s2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
236 cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
237 cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
238 cfg.s3 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
239 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t ldctouch_get_s2_pin(ldctouch_t *ctx)
LDC Touch get s2 pin function.
err_t ldctouch_check_communication(ldctouch_t *ctx)
LDC Touch check communication function.
err_t ldctouch_set_operation_mode(ldctouch_t *ctx, uint8_t mode)
LDC Touch set operation mode function.
void ldctouch_cfg_setup(ldctouch_cfg_t *cfg)
LDC Touch configuration object setup function.
err_t ldctouch_generic_write(ldctouch_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
LDC Touch I2C writing function.
uint8_t ldctouch_get_s0_pin(ldctouch_t *ctx)
LDC Touch get s0 pin function.
err_t ldctouch_default_cfg(ldctouch_t *ctx)
LDC Touch default configuration function.
err_t ldctouch_generic_read(ldctouch_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
LDC Touch I2C reading function.
err_t ldctouch_read_register(ldctouch_t *ctx, uint8_t reg, uint8_t *data_out)
LDC Touch read register function.
err_t ldctouch_get_data(ldctouch_t *ctx, ldctouch_data_t *button_data)
LDC Touch get data function.
err_t ldctouch_init(ldctouch_t *ctx, ldctouch_cfg_t *cfg)
LDC Touch initialization function.
uint8_t ldctouch_get_s3_pin(ldctouch_t *ctx)
LDC Touch get s3 pin function.
uint8_t ldctouch_get_s1_pin(ldctouch_t *ctx)
LDC Touch get s1 pin function.
uint8_t ldctouch_get_int_pin(ldctouch_t *ctx)
LDC Touch get int pin function.
err_t ldctouch_write_register(ldctouch_t *ctx, uint8_t reg, uint8_t data_in)
LDC Touch write register function.
ldctouch_return_value_t
LDC Touch Click return value data.
Definition ldctouch.h:305
@ LDCTOUCH_ERROR
Definition ldctouch.h:307
@ LDCTOUCH_OK
Definition ldctouch.h:306
LDC Touch Click configuration object.
Definition ldctouch.h:270
pin_name_t s2
Definition ldctouch.h:276
pin_name_t s3
Definition ldctouch.h:277
pin_name_t s0
Definition ldctouch.h:274
uint32_t i2c_speed
Definition ldctouch.h:280
pin_name_t s1
Definition ldctouch.h:275
pin_name_t scl
Definition ldctouch.h:271
pin_name_t int_pin
Definition ldctouch.h:278
pin_name_t sda
Definition ldctouch.h:272
uint8_t i2c_address
Definition ldctouch.h:281
LDC Touch Click data object.
Definition ldctouch.h:290
int16_t ch1_raw_button
Definition ldctouch.h:294
int16_t ch3_raw_button
Definition ldctouch.h:296
int16_t ch2_raw_button
Definition ldctouch.h:295
int16_t ch0_raw_button
Definition ldctouch.h:293
uint8_t out_state
Definition ldctouch.h:292
uint8_t status
Definition ldctouch.h:291
LDC Touch Click context object.
Definition ldctouch.h:249
digital_in_t s2
Definition ldctouch.h:253
digital_in_t int_pin
Definition ldctouch.h:255
i2c_master_t i2c
Definition ldctouch.h:258
digital_in_t s1
Definition ldctouch.h:252
uint8_t slave_address
Definition ldctouch.h:261
digital_in_t s3
Definition ldctouch.h:254
digital_in_t s0
Definition ldctouch.h:251