Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define LDCTOUCH_REG_STATUS 0x00
70 #define LDCTOUCH_REG_OUT 0x01
71 #define LDCTOUCH_REG_DATA0_LSB 0x02
72 #define LDCTOUCH_REG_DATA0_MSB 0x03
73 #define LDCTOUCH_REG_DATA1_LSB 0x04
74 #define LDCTOUCH_REG_DATA1_MSB 0x05
75 #define LDCTOUCH_REG_DATA2_LSB 0x06
76 #define LDCTOUCH_REG_DATA2_MSB 0x07
77 #define LDCTOUCH_REG_DATA3_LSB 0x08
78 #define LDCTOUCH_REG_DATA3_MSB 0x09
79 #define LDCTOUCH_REG_RESET 0x0A
80 #define LDCTOUCH_REG_EN 0x0C
81 #define LDCTOUCH_REG_NP_SCAN_RATE 0x0D
82 #define LDCTOUCH_REG_GAIN0 0x0E
83 #define LDCTOUCH_REG_LP_SCAN_RATE 0x0F
84 #define LDCTOUCH_REG_GAIN1 0x10
85 #define LDCTOUCH_REG_INTPOL 0x11
86 #define LDCTOUCH_REG_GAIN2 0x12
87 #define LDCTOUCH_REG_LP_BASE_INC 0x13
88 #define LDCTOUCH_REG_GAIN3 0x14
89 #define LDCTOUCH_REG_NP_BASE_INC 0x15
90 #define LDCTOUCH_REG_BTPAUSE_MAXWIN 0x16
91 #define LDCTOUCH_REG_LC_DIVIDER 0x17
92 #define LDCTOUCH_REG_HYST 0x18
93 #define LDCTOUCH_REG_TWIST 0x19
94 #define LDCTOUCH_REG_COMMON_DEFORM 0x1A
95 #define LDCTOUCH_REG_OPOL_DPOL 0x1C
96 #define LDCTOUCH_REG_CNTSC 0x1E
97 #define LDCTOUCH_REG_SENSOR0_CONFIG 0x20
98 #define LDCTOUCH_REG_SENSOR1_CONFIG 0x22
99 #define LDCTOUCH_REG_SENSOR2_CONFIG 0x24
100 #define LDCTOUCH_REG_FTF0 0x25
101 #define LDCTOUCH_REG_SENSOR3_CONFIG 0x26
102 #define LDCTOUCH_REG_FTF1_2 0x28
103 #define LDCTOUCH_REG_FTF3 0x2B
104 #define LDCTOUCH_REG_RAW_DATA0_3 0x59
105 #define LDCTOUCH_REG_RAW_DATA0_2 0x5A
106 #define LDCTOUCH_REG_RAW_DATA0_1 0x5B
107 #define LDCTOUCH_REG_RAW_DATA1_3 0x5C
108 #define LDCTOUCH_REG_RAW_DATA1_2 0x5D
109 #define LDCTOUCH_REG_RAW_DATA1_1 0x5E
110 #define LDCTOUCH_REG_RAW_DATA2_3 0x5F
111 #define LDCTOUCH_REG_RAW_DATA2_2 0x60
112 #define LDCTOUCH_REG_RAW_DATA2_1 0x61
113 #define LDCTOUCH_REG_RAW_DATA3_3 0x62
114 #define LDCTOUCH_REG_RAW_DATA3_2 0x63
115 #define LDCTOUCH_REG_RAW_DATA3_1 0x64
116 #define LDCTOUCH_REG_MANUFACTURER_ID_LSB 0xFC
117 #define LDCTOUCH_REG_MANUFACTURER_ID_MSB 0xFD
118 #define LDCTOUCH_REG_DEVICE_ID_LSB 0xFE
119 #define LDCTOUCH_REG_DEVICE_ID_MSB 0xFF
137 #define LDCTOUCH_STATUS_OUT 0x80
138 #define LDCTOUCH_STATUS_CHIP_READY 0x40
139 #define LDCTOUCH_STATUS_READY_TO_WRITE 0x20
140 #define LDCTOUCH_STATUS_MAXOUT 0x10
141 #define LDCTOUCH_STATUS_FSM_WD 0x08
142 #define LDCTOUCH_STATUS_LC_WD 0x04
143 #define LDCTOUCH_STATUS_TIMEOUT 0x02
144 #define LDCTOUCH_STATUS_REGISTER_FLAG 0x01
150 #define LDCTOUCH_MODE_NORMAL 0x00
151 #define LDCTOUCH_MODE_CONFIG 0x01
152 #define LDCTOUCH_MODE_FULL_RESET 0x10
158 #define LDCTOUCH_EN_CH3_LP 0x80
159 #define LDCTOUCH_EN_CH2_LP 0x40
160 #define LDCTOUCH_EN_CH1_LP 0x20
161 #define LDCTOUCH_EN_CH0_LP 0x10
162 #define LDCTOUCH_EN_CH3_NP 0x08
163 #define LDCTOUCH_EN_CH2_NP 0x04
164 #define LDCTOUCH_EN_CH1_NP 0x02
165 #define LDCTOUCH_EN_CH0_NP 0x01
171 #define LDCTOUCH_OPOL3_ACTIVE_HIGH 0x80
172 #define LDCTOUCH_OPOL3_ACTIVE_LOW 0x00
173 #define LDCTOUCH_OPOL2_ACTIVE_HIGH 0x40
174 #define LDCTOUCH_OPOL2_ACTIVE_LOW 0x00
175 #define LDCTOUCH_OPOL1_ACTIVE_HIGH 0x20
176 #define LDCTOUCH_OPOL1_ACTIVE_LOW 0x00
177 #define LDCTOUCH_OPOL0_ACTIVE_HIGH 0x10
178 #define LDCTOUCH_OPOL0_ACTIVE_LOW 0x00
179 #define LDCTOUCH_DPOL3_DATA_INCREASES 0x08
180 #define LDCTOUCH_DPOL3_DATA_DECREASES 0x00
181 #define LDCTOUCH_DPOL2_DATA_INCREASES 0x04
182 #define LDCTOUCH_DPOL2_DATA_DECREASES 0x00
183 #define LDCTOUCH_DPOL1_DATA_INCREASES 0x02
184 #define LDCTOUCH_DPOL1_DATA_DECREASES 0x00
185 #define LDCTOUCH_DPOL0_DATA_INCREASES 0x01
186 #define LDCTOUCH_DPOL0_DATA_DECREASES 0x00
192 #define LDCTOUCH_BUTTON_MODE_FINGER 0x00
193 #define LDCTOUCH_BUTTON_MODE_METAL 0x01
194 #define LDCTOUCH_BUTTON_MODE LDCTOUCH_BUTTON_MODE_FINGER
200 #define LDCTOUCH_MANUFACTURER_ID_LSB 0x49
201 #define LDCTOUCH_MANUFACTURER_ID_MSB 0x54
202 #define LDCTOUCH_DEVICE_ID_LSB 0x00
203 #define LDCTOUCH_DEVICE_ID_MSB 0x40
210 #define LDCTOUCH_DEVICE_ADDRESS 0x2A
228 #define LDCTOUCH_MAP_MIKROBUS( cfg, mikrobus ) \
229 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
230 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
231 cfg.s2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
232 cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
233 cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
234 cfg.s3 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
235 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t ldctouch_get_s1_pin(ldctouch_t *ctx)
LDC Touch get s1 pin function.
pin_name_t int_pin
Definition: ldctouch.h:274
uint8_t ldctouch_get_s0_pin(ldctouch_t *ctx)
LDC Touch get s0 pin function.
err_t ldctouch_get_data(ldctouch_t *ctx, ldctouch_data_t *button_data)
LDC Touch get data function.
uint8_t ldctouch_get_int_pin(ldctouch_t *ctx)
LDC Touch get int pin function.
i2c_master_t i2c
Definition: ldctouch.h:254
err_t ldctouch_generic_read(ldctouch_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
LDC Touch I2C reading function.
int16_t ch0_raw_button
Definition: ldctouch.h:289
ldctouch_return_value_t
LDC Touch Click return value data.
Definition: ldctouch.h:301
int16_t ch1_raw_button
Definition: ldctouch.h:290
pin_name_t s0
Definition: ldctouch.h:270
pin_name_t s1
Definition: ldctouch.h:271
LDC Touch Click configuration object.
Definition: ldctouch.h:266
@ LDCTOUCH_ERROR
Definition: ldctouch.h:303
int16_t ch2_raw_button
Definition: ldctouch.h:291
uint32_t i2c_speed
Definition: ldctouch.h:276
@ LDCTOUCH_OK
Definition: ldctouch.h:302
uint8_t ldctouch_get_s3_pin(ldctouch_t *ctx)
LDC Touch get s3 pin function.
LDC Touch Click context object.
Definition: ldctouch.h:245
digital_in_t s2
Definition: ldctouch.h:249
uint8_t slave_address
Definition: ldctouch.h:257
err_t ldctouch_read_register(ldctouch_t *ctx, uint8_t reg, uint8_t *data_out)
LDC Touch read register function.
uint8_t i2c_address
Definition: ldctouch.h:277
uint8_t out_state
Definition: ldctouch.h:288
pin_name_t scl
Definition: ldctouch.h:267
int16_t ch3_raw_button
Definition: ldctouch.h:292
digital_in_t s3
Definition: ldctouch.h:250
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.
err_t ldctouch_init(ldctouch_t *ctx, ldctouch_cfg_t *cfg)
LDC Touch initialization function.
pin_name_t sda
Definition: ldctouch.h:268
uint8_t status
Definition: ldctouch.h:287
err_t ldctouch_set_operation_mode(ldctouch_t *ctx, uint8_t mode)
LDC Touch set operation mode function.
err_t ldctouch_write_register(ldctouch_t *ctx, uint8_t reg, uint8_t data_in)
LDC Touch write register function.
err_t ldctouch_default_cfg(ldctouch_t *ctx)
LDC Touch default configuration function.
digital_in_t int_pin
Definition: ldctouch.h:251
digital_in_t s0
Definition: ldctouch.h:247
uint8_t ldctouch_get_s2_pin(ldctouch_t *ctx)
LDC Touch get s2 pin function.
pin_name_t s2
Definition: ldctouch.h:272
pin_name_t s3
Definition: ldctouch.h:273
digital_in_t s1
Definition: ldctouch.h:248
err_t ldctouch_check_communication(ldctouch_t *ctx)
LDC Touch check communication function.
LDC Touch Click data object.
Definition: ldctouch.h:286