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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define TOUCHPAD5_CMD_VERSION_INFO 0x00
70 #define TOUCHPAD5_CMD_XY_DATA 0x01
71 #define TOUCHPAD5_CMD_PROXIMITY_STATUS 0x02
72 #define TOUCHPAD5_CMD_TOUCH_STATUS 0x03
73 #define TOUCHPAD5_CMD_COUNT_VALUES 0x04
74 #define TOUCHPAD5_CMD_LONG_TERM_AVERAGES 0x05
75 #define TOUCHPAD5_CMD_ATI_COMPENSATION 0x06
76 #define TOUCHPAD5_CMD_PORT_CONTROL 0x07
77 #define TOUCHPAD5_CMD_SNAP_STATUS 0x08
78 #define TOUCHPAD5_CMD_CONTROL_SETTINGS 0x10
79 #define TOUCHPAD5_CMD_THRESHOLD_SETTINGS 0x11
80 #define TOUCHPAD5_CMD_ATI_SETTINGS 0x12
81 #define TOUCHPAD5_CMD_FILTER_SETTINGS 0x13
82 #define TOUCHPAD5_CMD_TIMING_SETTINGS 0x14
83 #define TOUCHPAD5_CMD_CHANNEL_SETUP 0x15
84 #define TOUCHPAD5_CMD_HARDWARE_CONFIG_SETTINGS 0x16
85 #define TOUCHPAD5_CMD_ACTIVE_CHANNELS 0x17
86 #define TOUCHPAD5_CMD_DEBOUNCE_SETTINGS 0x18
87 #define TOUCHPAD5_CMD_PM_PROXIMITY_STATUS 0x20
88 #define TOUCHPAD5_CMD_PM_COUNT_VALUES 0x21
89 #define TOUCHPAD5_CMD_PM_LONG_TERM_AVERAGES 0x22
90 #define TOUCHPAD5_CMD_PM_ATI_COMPENSATION 0x23
91 #define TOUCHPAD5_CMD_PM_ATI_SETTINGS 0x24
92 #define TOUCHPAD5_CMD_BOOTLOADER 0xFF
93  // touchpad5_cmd
95 
111 #define TOUCHPAD5_SET_DEV_ADDR 0x74
112 
124 #define TOUCHPAD5_SHOW_RESET 0x80
125 #define TOUCHPAD5_MODE_INDICATOR 0x40
126 #define TOUCHPAD5_NOISE_STATUS 0x20
127 #define TOUCHPAD5_LP_STATUS 0x10
128 #define TOUCHPAD5_SNAP_OUTPUT 0x08
129 #define TOUCHPAD5_NO_OF_FINGERS 0x07
130 
136 #define TOUCHPAD5_ACK_RESET 0x80
137 #define TOUCHPAD5_AUTO_MODES 0x40
138 #define TOUCHPAD5_SINGLE_XY 0x20
139 #define TOUCHPAD5_PM_RESEED 0x10
140 #define TOUCHPAD5_MODE_SELECT 0x08
141 #define TOUCHPAD5_AUTO_ATI 0x04
142 #define TOUCHPAD5_TRACKPAD_RESEED 0x02
143 #define TOUCHPAD5_EVENT_MODE 0x01
144 #define TOUCHPAD5_DIS_PROX_EVENT 0x80
145 #define TOUCHPAD5_DIS_TOUCH_EVENT 0x40
146 #define TOUCHPAD5_DIS_SNAP_EVENT 0x20
147 #define TOUCHPAD5_DIS_PMPROX_EVENT 0x10
148 #define TOUCHPAD5_REVERSE_EN 0x08
149 #define TOUCHPAD5_SLEEP_EN 0x04
150 #define TOUCHPAD5_LOW_POWER 0x02
151 #define TOUCHPAD5_SNAP_EN 0x01
152 
158 #define TOUCHPAD5_DIS_NM_FILTER 0x10
159 #define TOUCHPAD5_DIS_PM_FILTER 0x08
160 #define TOUCHPAD5_SELECT_TOUCH_FILTER 0x04
161 #define TOUCHPAD5_DIS_HOVER_FILTER 0x02
162 #define TOUCHPAD5_DIS_TOUCH_FILTER 0x01
163 
169 #define TOUCHPAD5_CHARGE_TYPE_SELF_CHARG 0x80
170 #define TOUCHPAD5_CHARGE_MUTUAL_SELF_CHARG 0x00
171 #define TOUCHPAD5_RX_GROUP_RXB 0x40
172 #define TOUCHPAD5_RX_GROUP_RXA 0x00
173 #define TOUCHPAD5_SUM_OF_TP_RX 0x10
174 #define TOUCHPAD5_SUM_OF_TP_TX 0x00
175 #define TOUCHPAD5_RX_SELECT 0x0F
176 #define TOUCHPAD5_TX_HIGH_DFLT 0x1F
177 #define TOUCHPAD5_TX_LOW_DFLT 0xFF
178 
184 #define TOUCHPAD5_ND_ENABLE 0x20
185 #define TOUCHPAD5_RX_FLOAT 0x04
186 #define TOUCHPAD5_CK_FREQ_2 0x40
187 #define TOUCHPAD5_CK_FREQ_1 0x20
188 #define TOUCHPAD5_CK_FREQ_0 0x10
189 #define TOUCHPAD5_ANA_DEAD_TIME 0x02
190 #define TOUCHPAD5_INCR_PHASE 0x01
191 #define TOUCHPAD5_STAB_TIME_1 0x80
192 #define TOUCHPAD5_STAB_TIME_0 0x40
193 #define TOUCHPAD5_OPAMP_BIAS_1 0x20
194 #define TOUCHPAD5_OPAMP_BIAS_0 0x10
195 #define TOUCHPAD5_VTRIP_3 0x08
196 #define TOUCHPAD5_VTRIP_2 0x04
197 #define TOUCHPAD5_VTRIP_1 0x02
198 #define TOUCHPAD5_VTRIP_0 0x01
199 #define TOUCHPAD5_UPLEN_2 0x40
200 #define TOUCHPAD5_UPLEN_1 0x20
201 #define TOUCHPAD5_UPLEN_0 0x10
202 #define TOUCHPAD5_PASSLEN_2 0x04
203 #define TOUCHPAD5_PASSLEN_1 0x02
204 #define TOUCHPAD5_PASSLEN_0 0x01
205 
211 #define TOUCHPAD5_PALM_REJECT 0x08
212 #define TOUCHPAD5_SWITCH_XY_AXIS 0x04
213 #define TOUCHPAD5_FLIP_Y 0x02
214 #define TOUCHPAD5_FLIP_X 0x01
215 
221 #define TOUCHPAD5_PROX_EVENT 0x80
222 #define TOUCHPAD5_TOUCH_EVENT 0x40
223 #define TOUCHPAD5_SNAP_EVENT 0x20
224 #define TOUCHPAD5_ALP_PROX_EVENT 0x10
225 #define TOUCHPAD5_REATI_EVENT 0x08
226 #define TOUCHPAD5_TP_EVENT 0x04
227 #define TOUCHPAD5_GESTURE_EVENT 0x02
228 #define TOUCHPAD5_EVENT_MODE 0x01
229 #define TOUCHPAD5_ALP_COUNT_FILTER 0x08
230 #define TOUCHPAD5_IIR_SELECT 0x04
231 #define TOUCHPAD5_MAV_FILTER 0x02
232 #define TOUCHPAD5_IIR_FILTER 0x01
233 
239 #define TOUCHPAD5_CHARGE_TYPE 0x80
240 #define TOUCHPAD5_RX_GROUP 0x40
241 #define TOUCHPAD5_PROX_REV 0x20
242 #define TOUCHPAD5_ALP_ENABLE 0x10
243 
249 #define TOUCHPAD5_RX7_TX2 0x80
250 #define TOUCHPAD5_RX6_TX3 0x40
251 #define TOUCHPAD5_RX5_TX4 0x20
252 #define TOUCHPAD5_RX4_TX5 0x10
253 #define TOUCHPAD5_RX3_TX6 0x08
254 #define TOUCHPAD5_RX2_TX7 0x04
255 #define TOUCHPAD5_RX1_TX8 0x02
256 #define TOUCHPAD5_RX0_TX9 0x01
257 
258  // touchpad5_set
260 
275 #define TOUCHPAD5_PROXIMITY_STATUS 0x02
276 #define TOUCHPAD5_TOUCH_STATUS 0x01
277 #define TOUCHPAD5_SNAP_STATUS 0x05
278 
279  // sel_status
281 
291 #define TOUCHPAD5_ID_TAG_TOUCH_1 0x01
292 #define TOUCHPAD5_ID_TAG_TOUCH_2 0x02
293 #define TOUCHPAD5_ID_TAG_TOUCH_3 0x03
294 #define TOUCHPAD5_ID_TAG_TOUCH_4 0x04
295 #define TOUCHPAD5_ID_TAG_TOUCH_5 0x05
296 #define TOUCHPAD5_ID_TAG_HOVER_1 0x81
297 #define TOUCHPAD5_ID_TAG_HOVER_2 0x82
298 #define TOUCHPAD5_ID_TAG_HOVER_3 0x83
299 #define TOUCHPAD5_ID_TAG_HOVER_4 0x84
300 #define TOUCHPAD5_ID_TAG_HOVER_5 0x85
301  // id_tag
303 
304 
319 #define TOUCHPAD5_MAP_MIKROBUS( cfg, mikrobus ) \
320  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
321  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
322  cfg.nrst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
323  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
324  // touchpad5_map
326 
336 #define TOUCHPAD5_IQS550_PRODUCT_NUMBER 40
337 
338  // product_num // touchpad5
341 
346 typedef struct
347 {
348  // Output pins
349  digital_out_t nrst;
351  // Input pins
352  digital_in_t int_pin;
354  // Modules
355  i2c_master_t i2c;
357  // I2C slave address
358  uint8_t slave_address;
360 } touchpad5_t;
361 
366 typedef struct
367 {
368  pin_name_t scl;
369  pin_name_t sda;
371  pin_name_t nrst;
372  pin_name_t int_pin;
374  uint32_t i2c_speed;
375  uint8_t i2c_address;
378 
383 typedef struct
384 {
385  uint16_t product_num;
386  uint16_t project_num;
387  float version;
388  uint16_t hw_id;
389  uint16_t hw_revision;
391 
396 typedef struct
397 {
398  uint8_t xy_info;
399  uint8_t no_of_fingers;
400  uint8_t id_tag;
401  uint16_t x_pos;
402  uint16_t y_pos;
403  uint16_t touch_strength;
406 
411 typedef struct
412 {
413  uint8_t total_rx;
414  uint8_t total_tx;
415  uint8_t track_pad_rx;
416  uint8_t track_pad_tx;
417  uint8_t pm_setup;
418  uint16_t tx_config;
421 
426 typedef struct
427 {
428  uint8_t prox_thresh;
431  uint8_t pm_prox_thresh;
433  uint8_t snap_thresh_low;
434  uint8_t prox_thresh2;
439 
444 typedef struct
445 {
446  uint8_t ctrl_settings0;
447  uint8_t ctrl_settings1;
450 
455 typedef enum
456 {
458  TOUCHPAD5_ERROR = -1
459 
461 
478 
489 
505 
520 
536 err_t touchpad5_generic_write( touchpad5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
537 
553 err_t touchpad5_generic_read( touchpad5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
554 
555 
571 
584 err_t touchpad5_check_bl_status( touchpad5_t *ctx, uint8_t* rx_buf );
585 
599 
612 
629 
645 
646 
662 
663 
680 
699 err_t touchpad5_get_all_data( touchpad5_t *ctx, uint8_t *rx_data );
700 
720 err_t touchpad5_get_status( touchpad5_t *ctx, uint8_t sel_status, uint16_t *rx_data, uint8_t num_of_samples );
721 
722 #ifdef __cplusplus
723 }
724 #endif
725 #endif // TOUCHPAD5_H
726  // touchpad5
728 
729 // ------------------------------------------------------------------------ END
TOUCHPAD5_ERROR
@ TOUCHPAD5_ERROR
Definition: touchpad5.h:458
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:414
touchpad5_threshold_settings_t::snap_thresh_low
uint8_t snap_thresh_low
Definition: touchpad5.h:433
touchpad5_control_settings_t::ctrl_settings0
uint8_t ctrl_settings0
Definition: touchpad5.h:446
touchpad5_t::nrst
digital_out_t nrst
Definition: touchpad5.h:349
touchpad5_channel_setup_t::track_pad_rx
uint8_t track_pad_rx
Definition: touchpad5.h:415
touchpad5_ver_info_t::version
float version
Definition: touchpad5.h:387
touchpad5_channel_setup_t::tx_config
uint16_t tx_config
Definition: touchpad5.h:418
touchpad5_touch_t::id_tag
uint8_t id_tag
Definition: touchpad5.h:400
touchpad5_touch_t::touch_strength
uint16_t touch_strength
Definition: touchpad5.h:403
touchpad5_channel_setup_t::track_pad_tx
uint8_t track_pad_tx
Definition: touchpad5.h:416
touchpad5_threshold_settings_t::touch_thresh_mult
uint8_t touch_thresh_mult
Definition: touchpad5.h:429
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:371
touchpad5_threshold_settings_t::pm_prox_thresh
uint8_t pm_prox_thresh
Definition: touchpad5.h:431
touchpad5_ver_info_t
TouchPad 5 device version information object.
Definition: touchpad5.h:384
touchpad5_channel_setup_t::pm_setup
uint8_t pm_setup
Definition: touchpad5.h:417
touchpad5_control_settings_t::ctrl_settings1
uint8_t ctrl_settings1
Definition: touchpad5.h:447
touchpad5_control_settings_t
TouchPad 5 Control Settings object.
Definition: touchpad5.h:445
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:369
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:374
touchpad5_cfg_t
Touchpad 5 Click configuration object.
Definition: touchpad5.h:367
touchpad5_touch_t::x_pos
uint16_t x_pos
Definition: touchpad5.h:401
touchpad5_channel_setup_t
TouchPad 5 Channel Setup object.
Definition: touchpad5.h:412
touchpad5_ver_info_t::hw_id
uint16_t hw_id
Definition: touchpad5.h:388
touchpad5_t::i2c
i2c_master_t i2c
Definition: touchpad5.h:355
touchpad5_ver_info_t::product_num
uint16_t product_num
Definition: touchpad5.h:385
touchpad5_touch_t
TouchPad 5 XY data object.
Definition: touchpad5.h:397
touchpad5_threshold_settings_t::prox_thresh2
uint8_t prox_thresh2
Definition: touchpad5.h:434
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:430
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:386
touchpad5_touch_t::y_pos
uint16_t y_pos
Definition: touchpad5.h:402
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:352
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:432
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:399
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:427
touchpad5_t
Touchpad 5 Click context object.
Definition: touchpad5.h:347
touchpad5_init
err_t touchpad5_init(touchpad5_t *ctx, touchpad5_cfg_t *cfg)
Touchpad 5 initialization function.
TOUCHPAD5_OK
@ TOUCHPAD5_OK
Definition: touchpad5.h:457
touchpad5_threshold_settings_t::prox_thresh
uint8_t prox_thresh
Definition: touchpad5.h:428
touchpad5_channel_setup_t::total_rx
uint8_t total_rx
Definition: touchpad5.h:413
touchpad5_ver_info_t::hw_revision
uint16_t hw_revision
Definition: touchpad5.h:389
touchpad5_touch_t::xy_info
uint8_t xy_info
Definition: touchpad5.h:398
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:368
touchpad5_threshold_settings_t::touch_thresh_mult2
uint8_t touch_thresh_mult2
Definition: touchpad5.h:435
touchpad5_cfg_t::i2c_address
uint8_t i2c_address
Definition: touchpad5.h:375
touchpad5_return_value_t
touchpad5_return_value_t
Touchpad 5 Click return value data.
Definition: touchpad5.h:456
touchpad5_threshold_settings_t::touch_thresh_shift2
uint8_t touch_thresh_shift2
Definition: touchpad5.h:436
touchpad5_cfg_t::int_pin
pin_name_t int_pin
Definition: touchpad5.h:372
touchpad5_t::slave_address
uint8_t slave_address
Definition: touchpad5.h:358