captouch2 2.0.0.0
captouch2.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef CAPTOUCH2_H
36#define CAPTOUCH2_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define CAPTOUCH2_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.alt = MIKROBUS( mikrobus, MIKROBUS_INT );
80#define CAPTOUCH2_RETVAL uint8_t
81
82#define CAPTOUCH2_OK 0x00
83#define CAPTOUCH2_INIT_ERROR 0xFF
90#define CAPTOUCH2_MAIN_CONTROL_REG 0x00
91#define CAPTOUCH2_GEN_STATUS_REG 0x02
92#define CAPTOUCH2_SENS_IN_STATUS_REG 0x03
93#define CAPTOUCH2_NOISE_FLAG_REG 0x0A
94#define CAPTOUCH2_SENS_IN1_DELTA_CNT_REG 0x10
95#define CAPTOUCH2_SENS_IN2_DELTA_CNT_REG 0x11
96#define CAPTOUCH2_SENS_IN3_DELTA_CNT_REG 0x12
97#define CAPTOUCH2_SENS_IN4_DELTA_CNT_REG 0x13
98#define CAPTOUCH2_SENS_IN5_DELTA_CNT_REG 0x14
99#define CAPTOUCH2_SENS_IN6_DELTA_CNT_REG 0x15
100#define CAPTOUCH2_SENSITIVITY_CON_REG 0x1F
101#define CAPTOUCH2_CONFIG_REG 0x20
102#define CAPTOUCH2_SENS_IN_EN_REG 0x21
103#define CAPTOUCH2_SENS_IN_CONFIG_REG 0x22
104#define CAPTOUCH2_SENS_IN_CONFIG2_REG 0x23
105#define CAPTOUCH2_AVRG_AND_SAMPL_CONFIG_REG 0x24
106#define CAPTOUCH2_CALIB_ACTIVATE_REG 0x26
107#define CAPTOUCH2_INTERR_EN_REG 0x27
108#define CAPTOUCH2_REPEAT_RATE_EN_REG 0x28
109#define CAPTOUCH2_MULTIPLE_TOUCH_CONFIG_REG 0x2A
110#define CAPTOUCH2_MULTIPLE_TOUCH_PATTERN_CONFIG_REG 0x2B
111#define CAPTOUCH2_MULTIPLE_TOUCH_PATTERN_REG 0x2D
112#define CAPTOUCH2_RECALIB_CONFIG_REG 0x2F
113#define CAPTOUCH2_SENS_IN1_THRESHOLD_REG 0x30
114#define CAPTOUCH2_SENS_IN2_THRESHOLD_REG 0x31
115#define CAPTOUCH2_SENS_IN3_THRESHOLD_REG 0x32
116#define CAPTOUCH2_SENS_IN4_THRESHOLD_REG 0x33
117#define CAPTOUCH2_SENS_IN5_THRESHOLD_REG 0x34
118#define CAPTOUCH2_SENS_IN6_THRESHOLD_REG 0x35
119#define CAPTOUCH2_SENS_IN_NOISE_THRESHOLD_REG 0x38
120#define CAPTOUCH2_STANDBY_CHANN_REG 0x40
121#define CAPTOUCH2_STANDBY_CONFIG_REG 0x41
122#define CAPTOUCH2_STANDBY_SENSITIVITY_REG 0x42
123#define CAPTOUCH2_STANDBY_THRESHOLD_REG 0x43
124#define CAPTOUCH2_CONFIG2_REG 0x44
125#define CAPTOUCH2_SENS_IN1_BASE_CNT_REG 0x50
126#define CAPTOUCH2_SENS_IN2_BASE_CNT_REG 0x51
127#define CAPTOUCH2_SENS_IN3_BASE_CNT_REG 0x52
128#define CAPTOUCH2_SENS_IN4_BASE_CNT_REG 0x53
129#define CAPTOUCH2_SENS_IN5_BASE_CNT_REG 0x54
130#define CAPTOUCH2_SENS_IN6_BASE_CNT_REG 0x55
131#define CAPTOUCH2_LED_OUTPUT_TYPE_REG 0x71
132#define CAPTOUCH2_SENS_IN_LED_LINK_REG 0x72
133#define CAPTOUCH2_LED_POLARITY_REG 0x73
134#define CAPTOUCH2_LED_OUT_CON_REG 0x74
135#define CAPTOUCH2_LED_LINK_TRANS_CON_REG 0x77
136#define CAPTOUCH2_LED_MIRROR_CON_REG 0x79
137#define CAPTOUCH2_LED_BEHAVIOR1_REG 0x81
138#define CAPTOUCH2_LED_BEHAVIOR2_REG 0x82
139#define CAPTOUCH2_LED_PULSE1_PERIOD_REG 0x84
140#define CAPTOUCH2_LED_PULSE2_PERIOD_REG 0x85
141#define CAPTOUCH2_LED_BREATHE_PERIOD_REG 0x86
142#define CAPTOUCH2_LED_CONFIG_REG 0x88
143#define CAPTOUCH2_LED_PULSE1_DUTY_REG 0x90
144#define CAPTOUCH2_LED_PULSE2_DUTY_REG 0x91
145#define CAPTOUCH2_LED_BREATHE_DUTY_REG 0x92
146#define CAPTOUCH2_LED_DIRECT_DUTY_REG 0x93
147#define CAPTOUCH2_LED_DIRECT_RAMP_RATES_REG 0x94
148#define CAPTOUCH2_LED_OFF_DELAY_REG 0x95
149#define CAPTOUCH2_SENS_IN1_CALIB_REG 0xB1
150#define CAPTOUCH2_SENS_IN2_CALIB_REG 0xB2
151#define CAPTOUCH2_SENS_IN3_CALIB_REG 0xB3
152#define CAPTOUCH2_SENS_IN4_CALIB_REG 0xB4
153#define CAPTOUCH2_SENS_IN5_CALIB_REG 0xB5
154#define CAPTOUCH2_SENS_IN6_CALIB_REG 0xB6
155#define CAPTOUCH2_SENS_IN_CALIB_LSB1_REG 0xB9
156#define CAPTOUCH2_SENS_IN_CALIB_LSB2_REG 0xBA
157#define CAPTOUCH2_PRODUCT_ID_REG 0xFD
158#define CAPTOUCH2_MANUFACT_ID_REG 0xFE
159#define CAPTOUCH2_REVISION_REG 0xFF
166#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_128X 0x00
167#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_64X 0x10
168#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_32X 0x20
169#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_16X 0x30
170#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_8X 0x40
171#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_4X 0x50
172#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_2X 0x60
173#define CAPTOUCH2_SENSITIVITY_MULTIPLIER_1X 0x70
174#define CAPTOUCH2_DATA_SCALING_FACTOR_1X 0x00
175#define CAPTOUCH2_DATA_SCALING_FACTOR_2X 0x01
176#define CAPTOUCH2_DATA_SCALING_FACTOR_4X 0x02
177#define CAPTOUCH2_DATA_SCALING_FACTOR_8X 0x03
178#define CAPTOUCH2_DATA_SCALING_FACTOR_16X 0x04
179#define CAPTOUCH2_DATA_SCALING_FACTOR_32X 0x05
180#define CAPTOUCH2_DATA_SCALING_FACTOR_64X 0x06
181#define CAPTOUCH2_DATA_SCALING_FACTOR_128X 0x07
182#define CAPTOUCH2_DATA_SCALING_FACTOR_256X 0x08
189#define CAPTOUCH2_TIMEOUT_DIS 0x00
190#define CAPTOUCH2_TIMEOUT_EN 0x80
191#define CAPTOUCH2_WAKE_PIN_NOT_ASSERTED 0x00
192#define CAPTOUCH2_WAKE_PIN_ASSERTED 0x40
193#define CAPTOUCH2_DIG_NOISE_THRESHOLD_EN 0x00
194#define CAPTOUCH2_DIG_NOISE_THRESHOLD_DIS 0x20
195#define CAPTOUCH2_AN_NOISE_FILTER_EN 0x00
196#define CAPTOUCH2_AN_NOISE_FILTER_DIS 0x10
197#define CAPTOUCH2_MAX_DUR_RECALIB_DIS 0x00
198#define CAPTOUCH2_MAX_DUR_RECALIB_EN 0x08
205#define CAPTOUCH2_NOT_INVERT_TOUCH_SIGNAL 0x00
206#define CAPTOUCH2_INVERT_TOUCH_SIGNAL 0x80
207#define CAPTOUCH2_ALERT_ACTIVE_HIGH 0x00
208#define CAPTOUCH2_ALERT_ACTIVE_LOW 0x40
209#define CAPTOUCH2_POWER_CONSUMPTION_REDUCE_EN 0x00
210#define CAPTOUCH2_POWER_CONSUMPTION_REDUCE_DIS 0x20
211#define CAPTOUCH2_AUTOSET_LED_MIRROR_CON 0x00
212#define CAPTOUCH2_NOT_AUTOSET_LED_MIRROR_CON 0x10
213#define CAPTOUCH2_SHOW_LOW_FREQ_NOISE 0x00
214#define CAPTOUCH2_NOT_SHOW_LOW_FREQ_NOISE 0x08
215#define CAPTOUCH2_RF_NOISE_FILTER_EN 0x00
216#define CAPTOUCH2_RF_NOISE_FILTER_DIS 0x04
217#define CAPTOUCH2_AN_CALIB_FAIL_INTERR_DIS 0x00
218#define CAPTOUCH2_AN_CALIB_FAIL_INTERR_EN 0x02
219#define CAPTOUCH2_DETECT_RELEASE_EN 0x00
220#define CAPTOUCH2_DETECT_RELEASE_DIS 0x01
227#define CAPTOUCH2_560MILISEC_BEFORE_RECALIB 0x00
228#define CAPTOUCH2_840MILISEC_BEFORE_RECALIB 0x10
229#define CAPTOUCH2_1120MILISEC_BEFORE_RECALIB 0x20
230#define CAPTOUCH2_1400MILISEC_BEFORE_RECALIB 0x30
231#define CAPTOUCH2_1680MILISEC_BEFORE_RECALIB 0x40
232#define CAPTOUCH2_2240MILISEC_BEFORE_RECALIB 0x50
233#define CAPTOUCH2_2800MILISEC_BEFORE_RECALIB 0x60
234#define CAPTOUCH2_3360MILISEC_BEFORE_RECALIB 0x70
235#define CAPTOUCH2_3920MILISEC_BEFORE_RECALIB 0x80
236#define CAPTOUCH2_4480MILISEC_BEFORE_RECALIB 0x90
237#define CAPTOUCH2_5600MILISEC_BEFORE_RECALIB 0xA0
238#define CAPTOUCH2_6720MILISEC_BEFORE_RECALIB 0xB0
239#define CAPTOUCH2_7840MILISEC_BEFORE_RECALIB 0xC0
240#define CAPTOUCH2_8906MILISEC_BEFORE_RECALIB 0xD0
241#define CAPTOUCH2_10080MILISEC_BEFORE_RECALIB 0xE0
242#define CAPTOUCH2_11200MILISEC_BEFORE_RECALIB 0xF0
243#define CAPTOUCH2_INTERR_REPEAT_RATE_35MILISEC 0x00
244#define CAPTOUCH2_INTERR_REPEAT_RATE_70MILISEC 0x01
245#define CAPTOUCH2_INTERR_REPEAT_RATE_105MILISEC 0x02
246#define CAPTOUCH2_INTERR_REPEAT_RATE_140MILISEC 0x03
247#define CAPTOUCH2_INTERR_REPEAT_RATE_175MILISEC 0x04
248#define CAPTOUCH2_INTERR_REPEAT_RATE_210MILISEC 0x05
249#define CAPTOUCH2_INTERR_REPEAT_RATE_245MILISEC 0x06
250#define CAPTOUCH2_INTERR_REPEAT_RATE_280MILISEC 0x07
251#define CAPTOUCH2_INTERR_REPEAT_RATE_315MILISEC 0x08
252#define CAPTOUCH2_INTERR_REPEAT_RATE_350MILISEC 0x09
253#define CAPTOUCH2_INTERR_REPEAT_RATE_385MILISEC 0x0A
254#define CAPTOUCH2_INTERR_REPEAT_RATE_420MILISEC 0x0B
255#define CAPTOUCH2_INTERR_REPEAT_RATE_455MILISEC 0x0C
256#define CAPTOUCH2_INTERR_REPEAT_RATE_490MILISEC 0x0D
257#define CAPTOUCH2_INTERR_REPEAT_RATE_525MILISEC 0x0E
258#define CAPTOUCH2_INTERR_REPEAT_RATE_560MILISEC 0x0F
265#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_35MILISEC 0x00
266#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_70MILISEC 0x01
267#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_105MILISEC 0x02
268#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_140MILISEC 0x03
269#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_175MILISEC 0x04
270#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_210MILISEC 0x05
271#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_245MILISEC 0x06
272#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_280MILISEC 0x07
273#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_315MILISEC 0x08
274#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_350MILISEC 0x09
275#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_385MILISEC 0x0A
276#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_420MILISEC 0x0B
277#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_455MILISEC 0x0C
278#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_490MILISEC 0x0D
279#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_525MILISEC 0x0E
280#define CAPTOUCH2_PRESS_AND_HOLD_EVENT_AFTER_560MILISEC 0x0F
287#define CAPTOUCH2_1_SAMPLE 0x00
288#define CAPTOUCH2_2_SAMPLES 0x10
289#define CAPTOUCH2_4_SAMPLES 0x20
290#define CAPTOUCH2_8_SAMPLES 0x30
291#define CAPTOUCH2_16_SAMPLES 0x40
292#define CAPTOUCH2_32_SAMPLES 0x50
293#define CAPTOUCH2_64_SAMPLES 0x60
294#define CAPTOUCH2_128_SAMPLES 0x70
295#define CAPTOUCH2_SAMPLE_TIME_320MICROSEC 0x00
296#define CAPTOUCH2_SAMPLE_TIME_640MICROSEC 0x04
297#define CAPTOUCH2_SAMPLE_TIME_1280MICROSEC 0x08
298#define CAPTOUCH2_SAMPLE_TIME_2560MICROSEC 0x0C
299#define CAPTOUCH2_CYCLE_TIME_35MILISEC 0x00
300#define CAPTOUCH2_CYCLE_TIME_70MILISEC 0x01
301#define CAPTOUCH2_CYCLE_TIME_105MILISEC 0x02
302#define CAPTOUCH2_CYCLE_TIME_140MILISEC 0x03
309#define CAPTOUCH2_ALL_INPUTS_CALIB_DIS 0x00
310#define CAPTOUCH2_INPUT1_CALIB_EN 0x01
311#define CAPTOUCH2_INPUT2_CALIB_EN 0x02
312#define CAPTOUCH2_INPUT3_CALIB_EN 0x04
313#define CAPTOUCH2_INPUT4_CALIB_EN 0x08
314#define CAPTOUCH2_INPUT5_CALIB_EN 0x10
315#define CAPTOUCH2_INPUT6_CALIB_EN 0x20
322#define CAPTOUCH2_ALL_INPUTS_INTERR_DIS 0x00
323#define CAPTOUCH2_INPUT1_INTERR_EN 0x01
324#define CAPTOUCH2_INPUT2_INTERR_EN 0x02
325#define CAPTOUCH2_INPUT3_INTERR_EN 0x04
326#define CAPTOUCH2_INPUT4_INTERR_EN 0x08
327#define CAPTOUCH2_INPUT5_INTERR_EN 0x10
328#define CAPTOUCH2_INPUT6_INTERR_EN 0x20
335#define CAPTOUCH2_REPEAT_RATE_DIS 0x00
336#define CAPTOUCH2_INPUT1_REPEAT_RATE_EN 0x01
337#define CAPTOUCH2_INPUT2_REPEAT_RATE_EN 0x02
338#define CAPTOUCH2_INPUT3_REPEAT_RATE_EN 0x04
339#define CAPTOUCH2_INPUT4_REPEAT_RATE_EN 0x08
340#define CAPTOUCH2_INPUT5_REPEAT_RATE_EN 0x10
341#define CAPTOUCH2_INPUT6_REPEAT_RATE_EN 0x20
348#define CAPTOUCH2_MULTIPLE_BLOCK_DIS 0x00
349#define CAPTOUCH2_MULTIPLE_BLOCK_EN 0x80
350#define CAPTOUCH2_SIMUL_TOUCH_NUM_1 0x00
351#define CAPTOUCH2_SIMUL_TOUCH_NUM_2 0x04
352#define CAPTOUCH2_SIMUL_TOUCH_NUM_3 0x08
353#define CAPTOUCH2_SIMUL_TOUCH_NUM_4 0x0C
360#define CAPTOUCH2_MULTIPLE_THRESHOLD_12_PERCENTS 0x00
361#define CAPTOUCH2_MULTIPLE_THRESHOLD_25_PERCENTS 0x04
362#define CAPTOUCH2_MULTIPLE_THRESHOLD_37_PERCENTS 0x08
363#define CAPTOUCH2_MULTIPLE_THRESHOLD_100_PERCENTS 0x0C
364#define CAPTOUCH2_MLTP_TOUCH_PATTERN 0x00
365#define CAPTOUCH2_PATTERN_RECOGNITION 0x02
366#define CAPTOUCH2_MLTP_EVENT_ALERT_DIS 0x00
367#define CAPTOUCH2_MLTP_EVENT_ALERT_EN 0x01
374#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUTS_DIS 0x00
375#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT1_EN 0x01
376#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT2_EN 0x02
377#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT3_EN 0x04
378#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT4_EN 0x08
379#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT5_EN 0x10
380#define CAPTOUCH2_MLTP_TOUCH_PATTERN_INPUT6_EN 0x20
387#define CAPTOUCH2_INPUTS_THRESHOLD_UPDT_INDIVIDUALY 0x00
388#define CAPTOUCH2_INPUT1_THRESHOLD_OVERWRITE 0x80
389#define CAPTOUCH2_ACC_INTER_DATA_CLEAR 0x00
390#define CAPTOUCH2_ACC_INTER_DATA_NOT_CLEAR 0x40
391#define CAPTOUCH2_CONS_NEG_DELTA_CNT_CLEAR 0x00
392#define CAPTOUCH2_CONS_NEG_DELTA_CNT_NOT_CLEAR 0x20
393#define CAPTOUCH2_CONS_NEG_DELTA_CNT_8 0x00
394#define CAPTOUCH2_CONS_NEG_DELTA_CNT_16 0x08
395#define CAPTOUCH2_CONS_NEG_DELTA_CNT_32 0x10
396#define CAPTOUCH2_CONS_NEG_DELTA_CNT_DIS 0x18
397#define CAPTOUCH2_REC_SAMPLES_16_UPDT_TIME_16 0x00
398#define CAPTOUCH2_REC_SAMPLES_32_UPDT_TIME_32 0x01
399#define CAPTOUCH2_REC_SAMPLES_64_UPDT_TIME_64 0x02
400#define CAPTOUCH2_REC_SAMPLES_128_UPDT_TIME_128 0x03
401#define CAPTOUCH2_REC_SAMPLES_256_UPDT_TIME_256 0x04
402#define CAPTOUCH2_REC_SAMPLES_256_UPDT_TIME_1024 0x05
403#define CAPTOUCH2_REC_SAMPLES_256_UPDT_TIME_2048 0x06
404#define CAPTOUCH2_REC_SAMPLES_256_UPDT_TIME_4096 0x07
411#define CAPTOUCH2_AVERAGE_BASED 0x00
412#define CAPTOUCH2_SUMMATION_BASED 0x80
419#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_128X 0x00
420#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_64X 0x01
421#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_32X 0x02
422#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_16X 0x03
423#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_8X 0x04
424#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_4X 0x05
425#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_2X 0x06
426#define CAPTOUCH2_STBY_SENSE_MULTIPLIER_1X 0x07
433#define CAPTOUCH2_LED6_PIN_OPEN_DRAIN 0x00
434#define CAPTOUCH2_LED6_PIN_PUSH_PULL 0x20
435#define CAPTOUCH2_LED5_PIN_OPEN_DRAIN 0x00
436#define CAPTOUCH2_LED5_PIN_PUSH_PULL 0x10
437#define CAPTOUCH2_LED4_PIN_OPEN_DRAIN 0x00
438#define CAPTOUCH2_LED4_PIN_PUSH_PULL 0x08
439#define CAPTOUCH2_LED3_PIN_OPEN_DRAIN 0x00
440#define CAPTOUCH2_LED3_PIN_PUSH_PULL 0x04
441#define CAPTOUCH2_LED2_PIN_OPEN_DRAIN 0x00
442#define CAPTOUCH2_LED2_PIN_PUSH_PULL 0x02
443#define CAPTOUCH2_LED1_PIN_OPEN_DRAIN 0x00
444#define CAPTOUCH2_LED1_PIN_PUSH_PULL 0x01
451#define CAPTOUCH2_LED6_IN6_NOT_LINKED 0x00
452#define CAPTOUCH2_LED6_IN6_LINKED 0x20
453#define CAPTOUCH2_LED5_IN5_NOT_LINKED 0x00
454#define CAPTOUCH2_LED5_IN5_LINKED 0x10
455#define CAPTOUCH2_LED4_IN4_NOT_LINKED 0x00
456#define CAPTOUCH2_LED4_IN4_LINKED 0x08
457#define CAPTOUCH2_LED3_IN3_NOT_LINKED 0x00
458#define CAPTOUCH2_LED3_IN3_LINKED 0x04
459#define CAPTOUCH2_LED2_IN2_NOT_LINKED 0x00
460#define CAPTOUCH2_LED2_IN2_LINKED 0x02
461#define CAPTOUCH2_LED1_IN1_NOT_LINKED 0x00
462#define CAPTOUCH2_LED1_IN1_LINKED 0x01
469#define CAPTOUCH2_LED6_OUT_INVERTED 0x00
470#define CAPTOUCH2_LED6_OUT_NOT_INVERTED 0x20
471#define CAPTOUCH2_LED5_OUT_INVERTED 0x00
472#define CAPTOUCH2_LED5_OUT_NOT_INVERTED 0x10
473#define CAPTOUCH2_LED4_OUT_INVERTED 0x00
474#define CAPTOUCH2_LED4_OUT_NOT_INVERTED 0x08
475#define CAPTOUCH2_LED3_OUT_INVERTED 0x00
476#define CAPTOUCH2_LED3_OUT_NOT_INVERTED 0x04
477#define CAPTOUCH2_LED2_OUT_INVERTED 0x00
478#define CAPTOUCH2_LED2_OUT_NOT_INVERTED 0x02
479#define CAPTOUCH2_LED1_OUT_INVERTED 0x00
480#define CAPTOUCH2_LED1_OUT_NOT_INVERTED 0x01
487#define CAPTOUCH2_LED6_DRIVEN_TO_MIN_DUTY 0x00
488#define CAPTOUCH2_LED6_DRIVEN_TO_MAX_DUTY 0x20
489#define CAPTOUCH2_LED5_DRIVEN_TO_MIN_DUTY 0x00
490#define CAPTOUCH2_LED5_DRIVEN_TO_MAX_DUTY 0x10
491#define CAPTOUCH2_LED4_DRIVEN_TO_MIN_DUTY 0x00
492#define CAPTOUCH2_LED4_DRIVEN_TO_MAX_DUTY 0x08
493#define CAPTOUCH2_LED3_DRIVEN_TO_MIN_DUTY 0x00
494#define CAPTOUCH2_LED3_DRIVEN_TO_MAX_DUTY 0x04
495#define CAPTOUCH2_LED2_DRIVEN_TO_MIN_DUTY 0x00
496#define CAPTOUCH2_LED2_DRIVEN_TO_MAX_DUTY 0x02
497#define CAPTOUCH2_LED1_DRIVEN_TO_MIN_DUTY 0x00
498#define CAPTOUCH2_LED1_DRIVEN_TO_MAX_DUTY 0x01
505#define CAPTOUCH2_LED6_CHANGE_STATE 0x00
506#define CAPTOUCH2_LED6_NOT_CHANGE_STATE 0x20
507#define CAPTOUCH2_LED5_CHANGE_STATE 0x00
508#define CAPTOUCH2_LED5_NOT_CHANGE_STATE 0x10
509#define CAPTOUCH2_LED4_CHANGE_STATE 0x00
510#define CAPTOUCH2_LED4_NOT_CHANGE_STATE 0x08
511#define CAPTOUCH2_LED3_CHANGE_STATE 0x00
512#define CAPTOUCH2_LED3_NOT_CHANGE_STATE 0x04
513#define CAPTOUCH2_LED2_CHANGE_STATE 0x00
514#define CAPTOUCH2_LED2_NOT_CHANGE_STATE 0x02
515#define CAPTOUCH2_LED1_CHANGE_STATE 0x00
516#define CAPTOUCH2_LED1_NOT_CHANGE_STATE 0x01
523#define CAPTOUCH2_LED1_DIRECT_BEHAVIOR 0x00
524#define CAPTOUCH2_LED1_PULSE1_BEHAVIOR 0x01
525#define CAPTOUCH2_LED1_PULSE2_BEHAVIOR 0x02
526#define CAPTOUCH2_LED1_BREATHE_BEHAVIOR 0x03
527#define CAPTOUCH2_LED2_DIRECT_BEHAVIOR 0x00
528#define CAPTOUCH2_LED2_PULSE1_BEHAVIOR ( 0x01 << 2 )
529#define CAPTOUCH2_LED2_PULSE2_BEHAVIOR ( 0x02 << 2 )
530#define CAPTOUCH2_LED2_BREATHE_BEHAVIOR ( 0x03 << 2 )
531#define CAPTOUCH2_LED3_DIRECT_BEHAVIOR 0x00
532#define CAPTOUCH2_LED3_PULSE1_BEHAVIOR ( 0x01 << 4 )
533#define CAPTOUCH2_LED3_PULSE2_BEHAVIOR ( 0x02 << 4 )
534#define CAPTOUCH2_LED3_BREATHE_BEHAVIOR ( 0x03 << 4 )
535#define CAPTOUCH2_LED4_DIRECT_BEHAVIOR ( 0x00 )
536#define CAPTOUCH2_LED4_PULSE1_BEHAVIOR ( 0x01 << 6 )
537#define CAPTOUCH2_LED4_PULSE2_BEHAVIOR ( 0x02 << 6 )
538#define CAPTOUCH2_LED4_BREATHE_BEHAVIOR ( 0x03 << 6 )
545#define CAPTOUCH2_LED5_DIRECT_BEHAVIOR 0x00
546#define CAPTOUCH2_LED5_PULSE1_BEHAVIOR 0x01
547#define CAPTOUCH2_LED5_PULSE2_BEHAVIOR 0x02
548#define CAPTOUCH2_LED5_BREATHE_BEHAVIOR 0x03
549#define CAPTOUCH2_LED6_DIRECT_BEHAVIOR 0x00
550#define CAPTOUCH2_LED6_PULSE1_BEHAVIOR ( 0x01 << 2 )
551#define CAPTOUCH2_LED6_PULSE2_BEHAVIOR ( 0x02 << 2 )
552#define CAPTOUCH2_LED6_BREATHE_BEHAVIOR ( 0x03 << 2 )
559#define CAPTOUCH2_LED_PULSE_ON_TOUCH 0x00
560#define CAPTOUCH2_LED_PULSE_ON_RELEASE 0x80
561#define CAPTOUCH2_LED_PULSE_PERIOD_32MILISEC 0x00
562#define CAPTOUCH2_LED_PULSE_PERIOD_4064MILISEC 0x7F
569#define CAPTOUCH2_ALERT_NOT_ASSERTED_ON_LED_ACT 0x00
570#define CAPTOUCH2_ALERT_ASSERTED_ON_LED_ACT 0x40
571#define CAPTOUCH2_PULSE1_1_PULSE 0x00
572#define CAPTOUCH2_PULSE1_2_PULSES 0x01
573#define CAPTOUCH2_PULSE1_3_PULSES 0x02
574#define CAPTOUCH2_PULSE1_4_PULSES 0x03
575#define CAPTOUCH2_PULSE1_5_PULSES 0x04
576#define CAPTOUCH2_PULSE1_6_PULSES 0x05
577#define CAPTOUCH2_PULSE1_7_PULSES 0x06
578#define CAPTOUCH2_PULSE1_8_PULSES 0x07
579#define CAPTOUCH2_PULSE2_1_PULSE 0x00
580#define CAPTOUCH2_PULSE2_2_PULSES ( 0x01 << 3 )
581#define CAPTOUCH2_PULSE2_3_PULSES ( 0x02 << 3 )
582#define CAPTOUCH2_PULSE2_4_PULSES ( 0x03 << 3 )
583#define CAPTOUCH2_PULSE2_5_PULSES ( 0x04 << 3 )
584#define CAPTOUCH2_PULSE2_6_PULSES ( 0x05 << 3 )
585#define CAPTOUCH2_PULSE2_7_PULSES ( 0x06 << 3 )
586#define CAPTOUCH2_PULSE2_8_PULSES ( 0x07 << 3 )
593#define CAPTOUCH2_MIN_DUTY_0_PERCENT 0x00
594#define CAPTOUCH2_MIN_DUTY_7_PERCENTS 0x01
595#define CAPTOUCH2_MIN_DUTY_9_PERCENTS 0x02
596#define CAPTOUCH2_MIN_DUTY_11_PERCENTS 0x03
597#define CAPTOUCH2_MIN_DUTY_14_PERCENTS 0x04
598#define CAPTOUCH2_MIN_DUTY_17_PERCENTS 0x05
599#define CAPTOUCH2_MIN_DUTY_20_PERCENTS 0x06
600#define CAPTOUCH2_MIN_DUTY_23_PERCENTS 0x07
601#define CAPTOUCH2_MIN_DUTY_26_PERCENTS 0x08
602#define CAPTOUCH2_MIN_DUTY_30_PERCENTS 0x09
603#define CAPTOUCH2_MIN_DUTY_35_PERCENTS 0x0A
604#define CAPTOUCH2_MIN_DUTY_40_PERCENTS 0x0B
605#define CAPTOUCH2_MIN_DUTY_46_PERCENTS 0x0C
606#define CAPTOUCH2_MIN_DUTY_53_PERCENTS 0x0D
607#define CAPTOUCH2_MIN_DUTY_63_PERCENTS 0x0E
608#define CAPTOUCH2_MIN_DUTY_77_PERCENTS 0x0F
609#define CAPTOUCH2_MAX_DUTY_7_PERCENTS 0x00
610#define CAPTOUCH2_MAX_DUTY_9_PERCENTS 0x10
611#define CAPTOUCH2_MAX_DUTY_11_PERCENTS 0x20
612#define CAPTOUCH2_MAX_DUTY_14_PERCENTS 0x30
613#define CAPTOUCH2_MAX_DUTY_17_PERCENTS 0x40
614#define CAPTOUCH2_MAX_DUTY_20_PERCENTS 0x50
615#define CAPTOUCH2_MAX_DUTY_23_PERCENTS 0x60
616#define CAPTOUCH2_MAX_DUTY_26_PERCENTS 0x70
617#define CAPTOUCH2_MAX_DUTY_30_PERCENTS 0x80
618#define CAPTOUCH2_MAX_DUTY_35_PERCENTS 0x90
619#define CAPTOUCH2_MAX_DUTY_40_PERCENTS 0xA0
620#define CAPTOUCH2_MAX_DUTY_46_PERCENTS 0xB0
621#define CAPTOUCH2_MAX_DUTY_53_PERCENTS 0xC0
622#define CAPTOUCH2_MAX_DUTY_63_PERCENTS 0xD0
623#define CAPTOUCH2_MAX_DUTY_77_PERCENTS 0xE0
624#define CAPTOUCH2_MAX_DUTY_100_PERCENTS 0xF0
631#define CAPTOUCH2_GAIN_1 0x01
632#define CAPTOUCH2_GAIN_2 0x02
633#define CAPTOUCH2_GAIN_4 0x04
634#define CAPTOUCH2_GAIN_8 0x08
635#define CAPTOUCH2_ALL_INPUTS_DISABLE 0x00
636#define CAPTOUCH2_INPUT1_EN 0x01
637#define CAPTOUCH2_INPUT2_EN 0x02
638#define CAPTOUCH2_INPUT3_EN 0x04
639#define CAPTOUCH2_INPUT4_EN 0x08
640#define CAPTOUCH2_INPUT5_EN 0x10
641#define CAPTOUCH2_INPUT6_EN 0x20
642#define CAPTOUCH2_ALL_INPUTS_ENABLE 0x3F
645 // End group macro
646// --------------------------------------------------------------- PUBLIC TYPES
655typedef struct
656{
657 // Output pins
658
659 digital_out_t cs;
660 digital_out_t rst;
661
662 // Input pins
663
664 digital_in_t alt;
665
666 // Modules
667
668 spi_master_t spi;
669 pin_name_t chip_select;
670
671 // ctx variable
673 uint8_t input_check[ 6 ];
675
677
681typedef struct
682{
683 // Communication gpio pins
684
685 pin_name_t miso;
686 pin_name_t mosi;
687 pin_name_t sck;
688 pin_name_t cs;
689
690 // Additional gpio pins
691
692 pin_name_t rst;
693 pin_name_t alt;
694
695 // static variable
696
697 uint32_t spi_speed;
698 spi_master_mode_t spi_mode;
699 spi_master_chip_select_polarity_t cs_polarity;
700
702
703 // End types group
704
705// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
706
711#ifdef __cplusplus
712extern "C"{
713#endif
714
724
734
755
767void captouch2_generic_transfer ( captouch2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
768
778void captouch2_write_reg ( captouch2_t *ctx, uint8_t reg_addr, uint8_t tx_data );
779
790void captouch2_read_reg( captouch2_t *ctx, uint8_t reg_addr, uint8_t *rx_data, uint8_t n_bytes );
791
804void captouch2_detect_touch( captouch2_t *ctx, uint8_t *in_sens );
805
815void captouch2_set_active_mode( captouch2_t *ctx, uint8_t analog_gain, uint8_t en_input );
816
826void captouch2_set_standby_mode( captouch2_t *ctx, uint8_t analog_gain, uint8_t en_input );
827
838
848
857
858#ifdef __cplusplus
859}
860#endif
861#endif // _CAPTOUCH2_H_
862
863 // End public_function group
865
866// ------------------------------------------------------------------------- END
#define CAPTOUCH2_RETVAL
Definition captouch2.h:80
void captouch2_reset(captouch2_t *ctx)
Reset function.
CAPTOUCH2_RETVAL captouch2_init(captouch2_t *ctx, captouch2_cfg_t *cfg)
Initialization function.
void captouch2_generic_transfer(captouch2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void captouch2_set_standby_mode(captouch2_t *ctx, uint8_t analog_gain, uint8_t en_input)
Standby Mode Set function.
void captouch2_write_reg(captouch2_t *ctx, uint8_t reg_addr, uint8_t tx_data)
Generic Write function.
void captouch2_default_cfg(captouch2_t *ctx)
Click Default Configuration function.
uint8_t captouch2_check_interrupt(captouch2_t *ctx)
Interrupt Check function.
void captouch2_set_deep_sleep_mode(captouch2_t *ctx)
DeepSleep Mode Set function.
void captouch2_cfg_setup(captouch2_cfg_t *cfg)
Config Object Initialization function.
void captouch2_detect_touch(captouch2_t *ctx, uint8_t *in_sens)
Touch Detect function.
void captouch2_set_active_mode(captouch2_t *ctx, uint8_t analog_gain, uint8_t en_input)
Active Mode Set function.
void captouch2_read_reg(captouch2_t *ctx, uint8_t reg_addr, uint8_t *rx_data, uint8_t n_bytes)
Generic Read function.
Click configuration structure definition.
Definition captouch2.h:682
pin_name_t alt
Definition captouch2.h:693
spi_master_chip_select_polarity_t cs_polarity
Definition captouch2.h:699
pin_name_t sck
Definition captouch2.h:687
spi_master_mode_t spi_mode
Definition captouch2.h:698
pin_name_t mosi
Definition captouch2.h:686
uint32_t spi_speed
Definition captouch2.h:697
pin_name_t miso
Definition captouch2.h:685
pin_name_t rst
Definition captouch2.h:692
pin_name_t cs
Definition captouch2.h:688
Click ctx object definition.
Definition captouch2.h:656
digital_out_t cs
Definition captouch2.h:659
spi_master_t spi
Definition captouch2.h:668
digital_in_t alt
Definition captouch2.h:664
digital_out_t rst
Definition captouch2.h:660
uint8_t release_check
Definition captouch2.h:672
uint8_t cfg_byte_data
Definition captouch2.h:674
pin_name_t chip_select
Definition captouch2.h:669