touchpad5  2.0.0.0
touchpad5.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef TOUCHPAD5_H
29 #define TOUCHPAD5_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define TOUCHPAD5_CMD_VERSION_INFO 0x00
60 #define TOUCHPAD5_CMD_XY_DATA 0x01
61 #define TOUCHPAD5_CMD_PROXIMITY_STATUS 0x02
62 #define TOUCHPAD5_CMD_TOUCH_STATUS 0x03
63 #define TOUCHPAD5_CMD_COUNT_VALUES 0x04
64 #define TOUCHPAD5_CMD_LONG_TERM_AVERAGES 0x05
65 #define TOUCHPAD5_CMD_ATI_COMPENSATION 0x06
66 #define TOUCHPAD5_CMD_PORT_CONTROL 0x07
67 #define TOUCHPAD5_CMD_SNAP_STATUS 0x08
68 #define TOUCHPAD5_CMD_CONTROL_SETTINGS 0x10
69 #define TOUCHPAD5_CMD_THRESHOLD_SETTINGS 0x11
70 #define TOUCHPAD5_CMD_ATI_SETTINGS 0x12
71 #define TOUCHPAD5_CMD_FILTER_SETTINGS 0x13
72 #define TOUCHPAD5_CMD_TIMING_SETTINGS 0x14
73 #define TOUCHPAD5_CMD_CHANNEL_SETUP 0x15
74 #define TOUCHPAD5_CMD_HARDWARE_CONFIG_SETTINGS 0x16
75 #define TOUCHPAD5_CMD_ACTIVE_CHANNELS 0x17
76 #define TOUCHPAD5_CMD_DEBOUNCE_SETTINGS 0x18
77 #define TOUCHPAD5_CMD_PM_PROXIMITY_STATUS 0x20
78 #define TOUCHPAD5_CMD_PM_COUNT_VALUES 0x21
79 #define TOUCHPAD5_CMD_PM_LONG_TERM_AVERAGES 0x22
80 #define TOUCHPAD5_CMD_PM_ATI_COMPENSATION 0x23
81 #define TOUCHPAD5_CMD_PM_ATI_SETTINGS 0x24
82 #define TOUCHPAD5_CMD_BOOTLOADER 0xFF
83  // touchpad5_cmd
85 
101 #define TOUCHPAD5_SET_DEV_ADDR 0x74
102 
114 #define TOUCHPAD5_SHOW_RESET 0x80
115 #define TOUCHPAD5_MODE_INDICATOR 0x40
116 #define TOUCHPAD5_NOISE_STATUS 0x20
117 #define TOUCHPAD5_LP_STATUS 0x10
118 #define TOUCHPAD5_SNAP_OUTPUT 0x08
119 #define TOUCHPAD5_NO_OF_FINGERS 0x07
120 
126 #define TOUCHPAD5_ACK_RESET 0x80
127 #define TOUCHPAD5_AUTO_MODES 0x40
128 #define TOUCHPAD5_SINGLE_XY 0x20
129 #define TOUCHPAD5_PM_RESEED 0x10
130 #define TOUCHPAD5_MODE_SELECT 0x08
131 #define TOUCHPAD5_AUTO_ATI 0x04
132 #define TOUCHPAD5_TRACKPAD_RESEED 0x02
133 #define TOUCHPAD5_EVENT_MODE 0x01
134 #define TOUCHPAD5_DIS_PROX_EVENT 0x80
135 #define TOUCHPAD5_DIS_TOUCH_EVENT 0x40
136 #define TOUCHPAD5_DIS_SNAP_EVENT 0x20
137 #define TOUCHPAD5_DIS_PMPROX_EVENT 0x10
138 #define TOUCHPAD5_REVERSE_EN 0x08
139 #define TOUCHPAD5_SLEEP_EN 0x04
140 #define TOUCHPAD5_LOW_POWER 0x02
141 #define TOUCHPAD5_SNAP_EN 0x01
142 
148 #define TOUCHPAD5_DIS_NM_FILTER 0x10
149 #define TOUCHPAD5_DIS_PM_FILTER 0x08
150 #define TOUCHPAD5_SELECT_TOUCH_FILTER 0x04
151 #define TOUCHPAD5_DIS_HOVER_FILTER 0x02
152 #define TOUCHPAD5_DIS_TOUCH_FILTER 0x01
153 
159 #define TOUCHPAD5_CHARGE_TYPE_SELF_CHARG 0x80
160 #define TOUCHPAD5_CHARGE_MUTUAL_SELF_CHARG 0x00
161 #define TOUCHPAD5_RX_GROUP_RXB 0x40
162 #define TOUCHPAD5_RX_GROUP_RXA 0x00
163 #define TOUCHPAD5_SUM_OF_TP_RX 0x10
164 #define TOUCHPAD5_SUM_OF_TP_TX 0x00
165 #define TOUCHPAD5_RX_SELECT 0x0F
166 #define TOUCHPAD5_TX_HIGH_DFLT 0x1F
167 #define TOUCHPAD5_TX_LOW_DFLT 0xFF
168 
174 #define TOUCHPAD5_ND_ENABLE 0x20
175 #define TOUCHPAD5_RX_FLOAT 0x04
176 #define TOUCHPAD5_CK_FREQ_2 0x40
177 #define TOUCHPAD5_CK_FREQ_1 0x20
178 #define TOUCHPAD5_CK_FREQ_0 0x10
179 #define TOUCHPAD5_ANA_DEAD_TIME 0x02
180 #define TOUCHPAD5_INCR_PHASE 0x01
181 #define TOUCHPAD5_STAB_TIME_1 0x80
182 #define TOUCHPAD5_STAB_TIME_0 0x40
183 #define TOUCHPAD5_OPAMP_BIAS_1 0x20
184 #define TOUCHPAD5_OPAMP_BIAS_0 0x10
185 #define TOUCHPAD5_VTRIP_3 0x08
186 #define TOUCHPAD5_VTRIP_2 0x04
187 #define TOUCHPAD5_VTRIP_1 0x02
188 #define TOUCHPAD5_VTRIP_0 0x01
189 #define TOUCHPAD5_UPLEN_2 0x40
190 #define TOUCHPAD5_UPLEN_1 0x20
191 #define TOUCHPAD5_UPLEN_0 0x10
192 #define TOUCHPAD5_PASSLEN_2 0x04
193 #define TOUCHPAD5_PASSLEN_1 0x02
194 #define TOUCHPAD5_PASSLEN_0 0x01
195 
201 #define TOUCHPAD5_PALM_REJECT 0x08
202 #define TOUCHPAD5_SWITCH_XY_AXIS 0x04
203 #define TOUCHPAD5_FLIP_Y 0x02
204 #define TOUCHPAD5_FLIP_X 0x01
205 
211 #define TOUCHPAD5_PROX_EVENT 0x80
212 #define TOUCHPAD5_TOUCH_EVENT 0x40
213 #define TOUCHPAD5_SNAP_EVENT 0x20
214 #define TOUCHPAD5_ALP_PROX_EVENT 0x10
215 #define TOUCHPAD5_REATI_EVENT 0x08
216 #define TOUCHPAD5_TP_EVENT 0x04
217 #define TOUCHPAD5_GESTURE_EVENT 0x02
218 #define TOUCHPAD5_EVENT_MODE 0x01
219 #define TOUCHPAD5_ALP_COUNT_FILTER 0x08
220 #define TOUCHPAD5_IIR_SELECT 0x04
221 #define TOUCHPAD5_MAV_FILTER 0x02
222 #define TOUCHPAD5_IIR_FILTER 0x01
223 
229 #define TOUCHPAD5_CHARGE_TYPE 0x80
230 #define TOUCHPAD5_RX_GROUP 0x40
231 #define TOUCHPAD5_PROX_REV 0x20
232 #define TOUCHPAD5_ALP_ENABLE 0x10
233 
239 #define TOUCHPAD5_RX7_TX2 0x80
240 #define TOUCHPAD5_RX6_TX3 0x40
241 #define TOUCHPAD5_RX5_TX4 0x20
242 #define TOUCHPAD5_RX4_TX5 0x10
243 #define TOUCHPAD5_RX3_TX6 0x08
244 #define TOUCHPAD5_RX2_TX7 0x04
245 #define TOUCHPAD5_RX1_TX8 0x02
246 #define TOUCHPAD5_RX0_TX9 0x01
247 
248  // touchpad5_set
250 
265 #define TOUCHPAD5_PROXIMITY_STATUS 0x02
266 #define TOUCHPAD5_TOUCH_STATUS 0x01
267 #define TOUCHPAD5_SNAP_STATUS 0x05
268 
269  // sel_status
271 
281 #define TOUCHPAD5_ID_TAG_TOUCH_1 0x01
282 #define TOUCHPAD5_ID_TAG_TOUCH_2 0x02
283 #define TOUCHPAD5_ID_TAG_TOUCH_3 0x03
284 #define TOUCHPAD5_ID_TAG_TOUCH_4 0x04
285 #define TOUCHPAD5_ID_TAG_TOUCH_5 0x05
286 #define TOUCHPAD5_ID_TAG_HOVER_1 0x81
287 #define TOUCHPAD5_ID_TAG_HOVER_2 0x82
288 #define TOUCHPAD5_ID_TAG_HOVER_3 0x83
289 #define TOUCHPAD5_ID_TAG_HOVER_4 0x84
290 #define TOUCHPAD5_ID_TAG_HOVER_5 0x85
291  // id_tag
293 
294 
309 #define TOUCHPAD5_MAP_MIKROBUS( cfg, mikrobus ) \
310  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
311  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
312  cfg.nrst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
313  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
314  // touchpad5_map
316 
326 #define TOUCHPAD5_IQS550_PRODUCT_NUMBER 40
327 
328  // product_num // touchpad5
331 
336 typedef struct
337 {
338  // Output pins
339  digital_out_t nrst;
341  // Input pins
342  digital_in_t int_pin;
344  // Modules
345  i2c_master_t i2c;
347  // I2C slave address
348  uint8_t slave_address;
350 } touchpad5_t;
351 
356 typedef struct
357 {
358  pin_name_t scl;
359  pin_name_t sda;
361  pin_name_t nrst;
362  pin_name_t int_pin;
364  uint32_t i2c_speed;
365  uint8_t i2c_address;
368 
373 typedef struct
374 {
375  uint16_t product_num;
376  uint16_t project_num;
377  float version;
378  uint16_t hw_id;
379  uint16_t hw_revision;
381 
386 typedef struct
387 {
388  uint8_t xy_info;
389  uint8_t no_of_fingers;
390  uint8_t id_tag;
391  uint16_t x_pos;
392  uint16_t y_pos;
393  uint16_t touch_strength;
396 
401 typedef struct
402 {
403  uint8_t total_rx;
404  uint8_t total_tx;
405  uint8_t track_pad_rx;
406  uint8_t track_pad_tx;
407  uint8_t pm_setup;
408  uint16_t tx_config;
411 
416 typedef struct
417 {
418  uint8_t prox_thresh;
421  uint8_t pm_prox_thresh;
423  uint8_t snap_thresh_low;
424  uint8_t prox_thresh2;
429 
434 typedef struct
435 {
436  uint8_t ctrl_settings0;
437  uint8_t ctrl_settings1;
440 
445 typedef enum
446 {
448  TOUCHPAD5_ERROR = -1
449 
451 
468 
479 
495 
510 
526 err_t touchpad5_generic_write( touchpad5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
527 
543 err_t touchpad5_generic_read( touchpad5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
544 
545 
561 
574 err_t touchpad5_check_bl_status( touchpad5_t *ctx, uint8_t* rx_buf );
575 
589 
602 
619 
635 
636 
652 
653 
670 
689 err_t touchpad5_get_all_data( touchpad5_t *ctx, uint8_t *rx_data );
690 
710 err_t touchpad5_get_status( touchpad5_t *ctx, uint8_t sel_status, uint16_t *rx_data, uint8_t num_of_samples );
711 
712 #ifdef __cplusplus
713 }
714 #endif
715 #endif // TOUCHPAD5_H
716  // touchpad5
718 
719 // ------------------------------------------------------------------------ END
TOUCHPAD5_ERROR
@ TOUCHPAD5_ERROR
Definition: touchpad5.h:448
touchpad5_default_cfg
err_t touchpad5_default_cfg(touchpad5_t *ctx)
Touchpad 5 default configuration function.
touchpad5_channel_setup_t::total_tx
uint8_t total_tx
Definition: touchpad5.h:404
touchpad5_threshold_settings_t::snap_thresh_low
uint8_t snap_thresh_low
Definition: touchpad5.h:423
touchpad5_control_settings_t::ctrl_settings0
uint8_t ctrl_settings0
Definition: touchpad5.h:436
touchpad5_t::nrst
digital_out_t nrst
Definition: touchpad5.h:339
touchpad5_channel_setup_t::track_pad_rx
uint8_t track_pad_rx
Definition: touchpad5.h:405
touchpad5_ver_info_t::version
float version
Definition: touchpad5.h:377
touchpad5_channel_setup_t::tx_config
uint16_t tx_config
Definition: touchpad5.h:408
touchpad5_touch_t::id_tag
uint8_t id_tag
Definition: touchpad5.h:390
touchpad5_touch_t::touch_strength
uint16_t touch_strength
Definition: touchpad5.h:393
touchpad5_channel_setup_t::track_pad_tx
uint8_t track_pad_tx
Definition: touchpad5.h:406
touchpad5_threshold_settings_t::touch_thresh_mult
uint8_t touch_thresh_mult
Definition: touchpad5.h:419
touchpad5_get_all_data
err_t touchpad5_get_all_data(touchpad5_t *ctx, uint8_t *rx_data)
TouchPad 5 get all data function.
touchpad5_cfg_t::nrst
pin_name_t nrst
Definition: touchpad5.h:361
touchpad5_threshold_settings_t::pm_prox_thresh
uint8_t pm_prox_thresh
Definition: touchpad5.h:421
touchpad5_ver_info_t
TouchPad 5 device version information object.
Definition: touchpad5.h:374
touchpad5_channel_setup_t::pm_setup
uint8_t pm_setup
Definition: touchpad5.h:407
touchpad5_control_settings_t::ctrl_settings1
uint8_t ctrl_settings1
Definition: touchpad5.h:437
touchpad5_control_settings_t
TouchPad 5 Control Settings object.
Definition: touchpad5.h:435
touchpad5_reset
void touchpad5_reset(touchpad5_t *ctx)
Touchpad 5 reset function.
touchpad5_threshold_setup
err_t touchpad5_threshold_setup(touchpad5_t *ctx, touchpad5_threshold_settings_t thresh_setup)
TouchPad 5 threshold setup function.
touchpad5_cfg_t::sda
pin_name_t sda
Definition: touchpad5.h:359
touchpad5_generic_write
err_t touchpad5_generic_write(touchpad5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Touchpad 5 I2C writing function.
touchpad5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: touchpad5.h:364
touchpad5_cfg_t
Touchpad 5 Click configuration object.
Definition: touchpad5.h:357
touchpad5_touch_t::x_pos
uint16_t x_pos
Definition: touchpad5.h:391
touchpad5_channel_setup_t
TouchPad 5 Channel Setup object.
Definition: touchpad5.h:402
touchpad5_ver_info_t::hw_id
uint16_t hw_id
Definition: touchpad5.h:378
touchpad5_t::i2c
i2c_master_t i2c
Definition: touchpad5.h:345
touchpad5_ver_info_t::product_num
uint16_t product_num
Definition: touchpad5.h:375
touchpad5_touch_t
TouchPad 5 XY data object.
Definition: touchpad5.h:387
touchpad5_threshold_settings_t::prox_thresh2
uint8_t prox_thresh2
Definition: touchpad5.h:424
touchpad5_channel_setup
err_t touchpad5_channel_setup(touchpad5_t *ctx, touchpad5_channel_setup_t ch_setup)
TouchPad 5 channel setup function.
touchpad5_get_status
err_t touchpad5_get_status(touchpad5_t *ctx, uint8_t sel_status, uint16_t *rx_data, uint8_t num_of_samples)
TouchPad 5 get status function.
touchpad5_control_setup
err_t touchpad5_control_setup(touchpad5_t *ctx, touchpad5_control_settings_t ctrl_setup)
TouchPad 5 control setup function.
touchpad5_threshold_settings_t::touch_thresh_shift
uint8_t touch_thresh_shift
Definition: touchpad5.h:420
touchpad5_generic_read
err_t touchpad5_generic_read(touchpad5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Touchpad 5 I2C reading function.
touchpad5_ver_info_t::project_num
uint16_t project_num
Definition: touchpad5.h:376
touchpad5_touch_t::y_pos
uint16_t y_pos
Definition: touchpad5.h:392
touchpad5_cfg_setup
void touchpad5_cfg_setup(touchpad5_cfg_t *cfg)
Touchpad 5 configuration object setup function.
touchpad5_check_bl_status
err_t touchpad5_check_bl_status(touchpad5_t *ctx, uint8_t *rx_buf)
TouchPad 5 Check Bootloader Status.
touchpad5_t::int_pin
digital_in_t int_pin
Definition: touchpad5.h:342
touchpad5_check_version
err_t touchpad5_check_version(touchpad5_t *ctx, touchpad5_ver_info_t *ver_info)
TouchPad 5 Check Version function.
touchpad5_threshold_settings_t::snap_thresh_high
uint8_t snap_thresh_high
Definition: touchpad5.h:422
touchpad5_get_touch
err_t touchpad5_get_touch(touchpad5_t *ctx, touchpad5_touch_t *touch_data)
TouchPad 5 get touch function.
touchpad5_touch_t::no_of_fingers
uint8_t no_of_fingers
Definition: touchpad5.h:389
touchpad5_wait_ready
void touchpad5_wait_ready(touchpad5_t *ctx)
TouchPad 5 wait ready function.
touchpad5_threshold_settings_t
TouchPad 5 Threshold Settings object.
Definition: touchpad5.h:417
touchpad5_t
Touchpad 5 Click context object.
Definition: touchpad5.h:337
touchpad5_init
err_t touchpad5_init(touchpad5_t *ctx, touchpad5_cfg_t *cfg)
Touchpad 5 initialization function.
TOUCHPAD5_OK
@ TOUCHPAD5_OK
Definition: touchpad5.h:447
touchpad5_threshold_settings_t::prox_thresh
uint8_t prox_thresh
Definition: touchpad5.h:418
touchpad5_channel_setup_t::total_rx
uint8_t total_rx
Definition: touchpad5.h:403
touchpad5_ver_info_t::hw_revision
uint16_t hw_revision
Definition: touchpad5.h:379
touchpad5_touch_t::xy_info
uint8_t xy_info
Definition: touchpad5.h:388
touchpad5_check_interrupt
uint8_t touchpad5_check_interrupt(touchpad5_t *ctx)
TouchPad 5 check interrupt function.
touchpad5_cfg_t::scl
pin_name_t scl
Definition: touchpad5.h:358
touchpad5_threshold_settings_t::touch_thresh_mult2
uint8_t touch_thresh_mult2
Definition: touchpad5.h:425
touchpad5_cfg_t::i2c_address
uint8_t i2c_address
Definition: touchpad5.h:365
touchpad5_return_value_t
touchpad5_return_value_t
Touchpad 5 Click return value data.
Definition: touchpad5.h:446
touchpad5_threshold_settings_t::touch_thresh_shift2
uint8_t touch_thresh_shift2
Definition: touchpad5.h:426
touchpad5_cfg_t::int_pin
pin_name_t int_pin
Definition: touchpad5.h:362
touchpad5_t::slave_address
uint8_t slave_address
Definition: touchpad5.h:348