Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
52 #define TOUCHCLAMP_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
61 #define TOUCHCLAMP_RETVAL uint8_t
63 #define TOUCHCLAMP_OK 0x00
64 #define TOUCHCLAMP_INIT_ERROR 0xFF
67 #define TOUCHCLAMP_I2C_ADDRESS 0x5A
77 #define TOUCHCLAMP_REG_TS1 0x00
78 #define TOUCHCLAMP_REG_TS2 0x01
79 #define TOUCHCLAMP_REG_OORS1 0x02
80 #define TOUCHCLAMP_REG_OORS2 0x03
86 #define TOUCHCLAMP_REG_E0FDL 0x04
87 #define TOUCHCLAMP_REG_E0FDH 0x05
88 #define TOUCHCLAMP_REG_E1FDL 0x06
89 #define TOUCHCLAMP_REG_E1FDH 0x07
90 #define TOUCHCLAMP_REG_E2FDL 0x08
91 #define TOUCHCLAMP_REG_E2FDH 0x09
92 #define TOUCHCLAMP_REG_E3FDL 0x0A
93 #define TOUCHCLAMP_REG_E3FDH 0x0B
94 #define TOUCHCLAMP_REG_E4FDL 0x0C
95 #define TOUCHCLAMP_REG_E4FDH 0x0D
96 #define TOUCHCLAMP_REG_E5FDL 0x0E
97 #define TOUCHCLAMP_REG_E5FDH 0x0F
98 #define TOUCHCLAMP_REG_E6FDL 0x10
99 #define TOUCHCLAMP_REG_E6FDH 0x11
100 #define TOUCHCLAMP_REG_E7FDL 0x12
101 #define TOUCHCLAMP_REG_E7FDH 0x13
102 #define TOUCHCLAMP_REG_E8FDL 0x14
103 #define TOUCHCLAMP_REG_E8FDH 0x15
104 #define TOUCHCLAMP_REG_E9FDL 0x16
105 #define TOUCHCLAMP_REG_E9FDH 0x17
106 #define TOUCHCLAMP_REG_E10FDL 0x18
107 #define TOUCHCLAMP_REG_E10FDH 0x19
108 #define TOUCHCLAMP_REG_E11FDL 0x1A
109 #define TOUCHCLAMP_REG_E11FDH 0x1B
110 #define TOUCHCLAMP_REG_E12FDL 0x1C
111 #define TOUCHCLAMP_REG_E12FDH 0x1D
117 #define TOUCHCLAMP_REG_E0BV 0x1E
118 #define TOUCHCLAMP_REG_E1BV 0x1F
119 #define TOUCHCLAMP_REG_E2BV 0x20
120 #define TOUCHCLAMP_REG_E3BV 0x21
121 #define TOUCHCLAMP_REG_E4BV 0x22
122 #define TOUCHCLAMP_REG_E5BV 0x23
123 #define TOUCHCLAMP_REG_E6BV 0x24
124 #define TOUCHCLAMP_REG_E7BV 0x25
125 #define TOUCHCLAMP_REG_E8BV 0x26
126 #define TOUCHCLAMP_REG_E9BV 0x27
127 #define TOUCHCLAMP_REG_E10BV 0x28
128 #define TOUCHCLAMP_REG_E11BV 0x29
129 #define TOUCHCLAMP_REG_E12BV 0x2A
140 #define TOUCHCLAMP_REG_MHDR 0x2B
141 #define TOUCHCLAMP_REG_NHDR 0x2C
142 #define TOUCHCLAMP_REG_NCLR 0x2D
143 #define TOUCHCLAMP_REG_FDLR 0x2E
149 #define TOUCHCLAMP_REG_MHDF 0x2F
150 #define TOUCHCLAMP_REG_NHDF 0x30
151 #define TOUCHCLAMP_REG_NCLF 0x31
152 #define TOUCHCLAMP_REG_FDLF 0x32
153 #define TOUCHCLAMP_REG_NHDT 0x33
154 #define TOUCHCLAMP_REG_NCLT 0x34
155 #define TOUCHCLAMP_REG_FDLT 0x35
167 #define TOUCHCLAMP_REG_MHDPROXR 0x36
168 #define TOUCHCLAMP_REG_NHDPROXR 0x37
169 #define TOUCHCLAMP_REG_NCLPROXR 0x38
170 #define TOUCHCLAMP_REG_FDLPROXR 0x39
176 #define TOUCHCLAMP_REG_MHDPROXF 0x3A
177 #define TOUCHCLAMP_REG_NHDPROXF 0x3B
178 #define TOUCHCLAMP_REG_NCLPROXF 0x3C
179 #define TOUCHCLAMP_REG_FDLPROXF 0x3D
185 #define TOUCHCLAMP_REG_NHDPROXT 0x3E
186 #define TOUCHCLAMP_REG_NCLPROXT 0x3F
187 #define TOUCHCLAMP_REG_FDLPROXT 0x40
193 #define TOUCHCLAMP_REG_E0TTH 0x41
194 #define TOUCHCLAMP_REG_E0RTH 0x42
195 #define TOUCHCLAMP_REG_E1TTH 0x43
196 #define TOUCHCLAMP_REG_E1RTH 0x44
197 #define TOUCHCLAMP_REG_E2TTH 0x45
198 #define TOUCHCLAMP_REG_E2RTH 0x46
199 #define TOUCHCLAMP_REG_E3TTH 0x47
200 #define TOUCHCLAMP_REG_E3RTH 0x48
201 #define TOUCHCLAMP_REG_E4TTH 0x49
202 #define TOUCHCLAMP_REG_E4RTH 0x4A
203 #define TOUCHCLAMP_REG_E5TTH 0x4B
204 #define TOUCHCLAMP_REG_E5RTH 0x4C
205 #define TOUCHCLAMP_REG_E6TTH 0x4D
206 #define TOUCHCLAMP_REG_E6RTH 0x4E
207 #define TOUCHCLAMP_REG_E7TTH 0x4F
208 #define TOUCHCLAMP_REG_E7RTH 0x50
209 #define TOUCHCLAMP_REG_E8TTH 0x51
210 #define TOUCHCLAMP_REG_E8RTH 0x52
211 #define TOUCHCLAMP_REG_E9TTH 0x53
212 #define TOUCHCLAMP_REG_E9RTH 0x54
213 #define TOUCHCLAMP_REG_E10TTH 0x55
214 #define TOUCHCLAMP_REG_E10RTH 0x56
215 #define TOUCHCLAMP_REG_E11TTH 0x57
216 #define TOUCHCLAMP_REG_E11RTH 0x58
217 #define TOUCHCLAMP_REG_E12TTH 0x59
218 #define TOUCHCLAMP_REG_E12RTH 0x5A
224 #define TOUCHCLAMP_REG_DTR 0x5B
230 #define TOUCHCLAMP_REG_AFE1 0x5C
231 #define TOUCHCLAMP_REG_AFE2 0x5D
232 #define TOUCHCLAMP_REG_ECR 0x5E
238 #define TOUCHCLAMP_REG_CDC0 0x5F
239 #define TOUCHCLAMP_REG_CDC1 0x60
240 #define TOUCHCLAMP_REG_CDC2 0x61
241 #define TOUCHCLAMP_REG_CDC3 0x62
242 #define TOUCHCLAMP_REG_CDC4 0x63
243 #define TOUCHCLAMP_REG_CDC5 0x64
244 #define TOUCHCLAMP_REG_CDC6 0x65
245 #define TOUCHCLAMP_REG_CDC7 0x66
246 #define TOUCHCLAMP_REG_CDC8 0x67
247 #define TOUCHCLAMP_REG_CDC9 0x68
248 #define TOUCHCLAMP_REG_CDC10 0x69
249 #define TOUCHCLAMP_REG_CDC11 0x6A
250 #define TOUCHCLAMP_REG_CDC12 0x6B
256 #define TOUCHCLAMP_REG_CDT01 0x6C
257 #define TOUCHCLAMP_REG_CDT23 0x6D
258 #define TOUCHCLAMP_REG_CDT45 0x6E
259 #define TOUCHCLAMP_REG_CDT67 0x6F
260 #define TOUCHCLAMP_REG_CDT89 0x70
261 #define TOUCHCLAMP_REG_CDT1011 0x71
262 #define TOUCHCLAMP_REG_CDT11 0x72
268 #define TOUCHCLAMP_REG_CTL0 0x73
269 #define TOUCHCLAMP_REG_CTL1 0x74
270 #define TOUCHCLAMP_REG_DAT 0x75
271 #define TOUCHCLAMP_REG_DIR 0x76
272 #define TOUCHCLAMP_REG_EN 0x77
273 #define TOUCHCLAMP_REG_SET 0x78
274 #define TOUCHCLAMP_REG_CLR 0x79
275 #define TOUCHCLAMP_REG_TOG 0x7A
281 #define TOUCHCLAMP_REG_ACCR0 0x7B
282 #define TOUCHCLAMP_REG_ACCR1 0x7C
283 #define TOUCHCLAMP_REG_USL 0x7D
284 #define TOUCHCLAMP_REG_LSL 0x7E
285 #define TOUCHCLAMP_REG_TL 0x7F
291 #define TOUCHCLAMP_REG_SRST 0x80
303 #define TOUCHCLAMP_ECR_INIT_VAL 0x00
309 #define TOUCHCLAMP_MHDR_MAX_VAL 0x01
315 #define TOUCHCLAMP_NHDR_MIN_VAL 0x01
321 #define TOUCHCLAMP_NCLR_DEF_VAL 0x10
327 #define TOUCHCLAMP_FDLR_DEF_VAL 0x20
333 #define TOUCHCLAMP_MHDF_DEF_VAL 0x01
339 #define TOUCHCLAMP_NHDF_DEF_VAL 0x01
345 #define TOUCHCLAMP_NCLF_DEF_VAL 0x10
351 #define TOUCHCLAMP_FDLF_DEF_VAL 0x20
357 #define TOUCHCLAMP_NHDT_DEF_VAL 0x01
363 #define TOUCHCLAMP_NCLT_DEF_VAL 0x10
369 #define TOUCHCLAMP_FDLT_DEF_VAL 0xFF
375 #define TOUCHCLAMP_MHDPROXR_DEF_VAL 0x0F
381 #define TOUCHCLAMP_NHDPROXR_DEF_VAL 0x0F
387 #define TOUCHCLAMP_NCLPROXR_DEF_VAL 0x00
393 #define TOUCHCLAMP_FDLPROXR_DEF_VAL 0x00
399 #define TOUCHCLAMP_MHDPROXF_DEF_VAL 0x01
405 #define TOUCHCLAMP_NHDPROXF_DEF_VAL 0x01
411 #define TOUCHCLAMP_NCLPROXF_DEF_VAL 0xFF
417 #define TOUCHCLAMP_NHDPROXT_DEF_VAL 0x00
423 #define TOUCHCLAMP_DTR_DEF_VAL 0x11
429 #define TOUCHCLAMP_AFE1_DEF_VAL 0xFF
435 #define TOUCHCLAMP_AFE2_DEF_VAL 0x30
441 #define TOUCHCLAMP_ECR_DEF_VAL 0x88
449 #define TOUCHCLAMP_BIT_MASK_SCRATCH 0xF8
450 #define TOUCHCLAMP_BIT_MASK_SAMP_PER 0x07
451 #define TOUCHCLAMP_BIT_MASK_STOP_BIT 0xC0
452 #define TOUCHCLAMP_BIT_MASK_SW_RESET 0x63
459 #define TOUCHCLAMP_TOUCH_POSITION_A 0x80
460 #define TOUCHCLAMP_TOUCH_POSITION_B 0x40
461 #define TOUCHCLAMP_TOUCH_POSITION_C 0x20
462 #define TOUCHCLAMP_TOUCH_POSITION_D 0x08
463 #define TOUCHCLAMP_TOUCH_POSITION_E 0x04
464 #define TOUCHCLAMP_TOUCH_POSITION_F 0x02
465 #define TOUCHCLAMP_TOUCH_POSITION_G 0x01
466 #define TOUCHCLAMP_TOUCH_POSITION_H 0x10
467 #define TOUCHCLAMP_NO_TOUCH 0x00
859 #endif // _TOUCHCLAMP_H_
void touchclamp_set_sample_period(touchclamp_t *ctx, uint8_t sample_per)
Sets the sample period function.
uint8_t touchclamp_get_release_threshold(touchclamp_t *ctx, uint8_t electrode)
Get the current release threshold for a specified electrode function.
digital_in_t int_pin
Definition: touchclamp.h:484
pin_name_t scl
Definition: touchclamp.h:503
#define TOUCHCLAMP_RETVAL
Definition: touchclamp.h:61
Click ctx object definition.
Definition: touchclamp.h:481
void touchclamp_digital_toggle(touchclamp_t *ctx, uint8_t electrode)
Toggles electrode set as GPIO output function.
pin_name_t int_pin
Definition: touchclamp.h:508
void touchclamp_stop(touchclamp_t *ctx)
Stop touch clamp function.
uint8_t touchclamp_get_touch_threshold(touchclamp_t *ctx, uint8_t electrode)
Get the current touch threshold for a specified electrode function.
void touchclamp_set_release_threshold(touchclamp_t *ctx, uint8_t rth_data)
Setting release threshold for a specified electrode function.
Click configuration structure definition.
Definition: touchclamp.h:500
uint8_t i2c_address
Definition: touchclamp.h:513
TOUCHCLAMP_RETVAL touchclamp_init(touchclamp_t *ctx, touchclamp_cfg_t *cfg)
Initialization function.
uint8_t slave_address
Definition: touchclamp.h:492
void touchclamp_set_touch_threshold(touchclamp_t *ctx, uint8_t th_data)
Setting touch threshold for a specified electrode function.
i2c_master_t i2c
Definition: touchclamp.h:488
void touchclamp_cfg_setup(touchclamp_cfg_t *cfg)
Config Object Initialization function.
uint32_t i2c_speed
Definition: touchclamp.h:512
pin_name_t sda
Definition: touchclamp.h:504
void touchclamp_default_cfg(touchclamp_t *ctx)
Click Default Configuration function.
void touchclamp_generic_write(touchclamp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint16_t touchclamp_get_touch_data(touchclamp_t *ctx)
Get touch data function.
void touchclamp_soft_reset(touchclamp_t *ctx)
Soft reset function.
uint8_t touchclamp_get_interrupt(touchclamp_t *ctx)
Get state of interrupt pin function.
void touchclamp_generic_read(touchclamp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.