mikroSDK Reference Manual
ft5xx6.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2023 MikroElektronika d.o.o.
4 ** Contact: https://www.mikroe.com/contact
5 **
6 ** This file is part of the mikroSDK package
7 **
8 ** Commercial License Usage
9 **
10 ** Licensees holding valid commercial NECTO compilers AI licenses may use this
11 ** file in accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The MikroElektronika Company.
14 ** For licensing terms and conditions see
15 ** https://www.mikroe.com/legal/software-license-agreement.
16 ** For further information use the contact form at
17 ** https://www.mikroe.com/contact.
18 **
19 **
20 ** GNU Lesser General Public License Usage
21 **
22 ** Alternatively, this file may be used for
23 ** non-commercial projects under the terms of the GNU Lesser
24 ** General Public License version 3 as published by the Free Software
25 ** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26 **
27 ** The above copyright notice and this permission notice shall be
28 ** included in all copies or substantial portions of the Software.
29 **
30 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 ** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32 ** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 **
38 ****************************************************************************/
39 
45 #ifndef FT5XX6_H
46 #define FT5XX6_H
47 
48 #include "drv_i2c_master.h"
49 #include "drv_digital_in.h"
50 #include "drv_name.h"
51 #include "tp.h"
52 
81 #define FT5XX6_REG_DEVICE_MODE 0x0
82 
88 #define FT5XX6_REG_GEST_ID 0x1
89 
94 #define FT5XX6_REG_TD_STATUS 0x2
95 
101 #define FT5XX6_REG_TOUCH1_XH 0x3
102 
108 #define FT5XX6_REG_TOUCH1_XL 0x4
109 
115 #define FT5XX6_REG_TOUCH1_YH 0x5
116 
122 #define FT5XX6_REG_TOUCH1_YL 0x6
123 
129 #define FT5XX6_REG_TOUCH2_XH 0x9
130 
136 #define FT5XX6_REG_TOUCH2_XL 0xA
137 
143 #define FT5XX6_REG_TOUCH2_YH 0xB
144 
150 #define FT5XX6_REG_TOUCH2_YL 0xC
151 
157 #define FT5XX6_REG_TOUCH3_XH 0xF
158 
164 #define FT5XX6_REG_TOUCH3_XL 0x10
165 
171 #define FT5XX6_REG_TOUCH3_YH 0x11
172 
178 #define FT5XX6_REG_TOUCH3_YL 0x12
179 
185 #define FT5XX6_REG_TOUCH4_XH 0x15
186 
192 #define FT5XX6_REG_TOUCH4_XL 0x16
193 
199 #define FT5XX6_REG_TOUCH4_YH 0x17
200 
206 #define FT5XX6_REG_TOUCH4_YL 0x18
207 
213 #define FT5XX6_REG_TOUCH5_XH 0x1B
214 
220 #define FT5XX6_REG_TOUCH5_XL 0x1C
221 
227 #define FT5XX6_REG_TOUCH5_YH 0x1D
228 
234 #define FT5XX6_REG_TOUCH5_YL 0x1E
235 
241 #define FT5XX6_REG_TOUCH_DET_TH 0x80
242 
248 #define FT5XX6_REG_TOUCH_PEAK_DET_TH 0x81
249 
255 #define FT5XX6_REG_TOUCH_TH_CAL 0x82
256 
262 #define FT5XX6_REG_TOUCH_TH_WATER 0x83
263 
269 #define FT5XX6_REG_TOUCH_TH_TEMP_COMP 0x84
270 
276 #define FT5XX6_REG_POWER_CTRL_MODE 0x86
277 
283 #define FT5XX6_REG_MONITOR_STATUS_TMR 0x87
284 
290 #define FT5XX6_REG_MONITOR_ACT_PERIOD 0x88
291 
297 #define FT5XX6_REG_ENTER_IDLE_TIMER 0x89
298 
304 #define FT5XX6_REG_AUTO_CALIB_MODE 0xA0
305 
311 #define FT5XX6_REG_LIB_VERSION_H 0xA1
312 
318 #define FT5XX6_REG_LIB_VERSION_L 0xA2
319 
325 #define FT5XX6_REG_LIB_CHIP_VENDOR_ID 0xA3
326 
332 #define FT5XX6_REG_IVT_TO_HOST_STATUS 0xA4
333 
339 #define FT5XX6_REG_POWER_CONSUME_MODE 0xA5
340 
346 #define FT5XX6_REG_FW_ID 0xA6
347 
353 #define FT5XX6_REG_RUNNING_STATE 0xA7
354 
360 #define FT5XX6_REG_CTPM_VENDOR_ID 0xA8
361 
366 #define FT5XX6_REG_ERROR_ID 0xA9
367 
373 #define FT5XX6_REG_CONFIGURE_CAL_MODE 0xAA
374 
380 #define FT5XX6_REG_BIG_AREA_TH 0xAE
381  // ft5xx6_registers
383 
399 #define FT5XX6_INT_MODE_POLLING 0
400 
405 #define FT5XX6_INT_MODE_TRIGGER 1
406 
411 #define FT5XX6_I2C_ADDR 0x38
412 
417 #define FT5XX6_N_DATA_TRANSFER_MIN 1
418 
423 #define FT5XX6_N_DATA_TRANSFER_MAX 256
424 
429 #define FT5XX6_GESTURE_ITEMS_MAX 7
430 
435 #define FT5XX6_EVENT_PRESS_DET 0x80
436 
452 #define FT5XX6_MASK_PRESS_COORD 0xFFF
453 
458 #define FT5XX6_MASK_PRESS_EVENT 0xC0
459 
464 #define FT5XX6_MASK_PRESS_DET 0xC0
465 
470 #define FT5XX6_MASK_TP_NUM 0xF
471  // ft5xx6_masks
473 
489 #define FT5XX6_OFFSET_PRESS_EVENT 6
490 
495 #define FT5XX6_OFFSET_PRESS_ID 4
496 
501 #define FT5XX6_OFFSET_DEV_MODE 4
502 
507 #define FT5XX6_OFFSET_TOUCH_READING 6
508  // ft5xx6_offsets
510 
515 #define FT5XX6_MAP_PINS( cfg ) \
516  cfg.i2c_cfg.scl = CTP_SCL; \
517  cfg.i2c_cfg.sda = CTP_SDA; \
518  cfg.int_pin = CTP_INT
519  // ft5xx6_settings // ft5xx6 // middlewaregroup
523 
528 typedef enum
529 {
535 
540 typedef enum
541 {
549 
554 typedef struct
555 {
556  uint8_t key;
557  tp_event_t value;
560 
565 typedef struct
566 {
570 
575 typedef struct
576 {
577  pin_name_t int_pin;
579  i2c_master_config_t i2c_cfg;
581  const ft5xx6_controller_t * controller;
583 } ft5xx6_cfg_t;
584 
589 typedef struct
590 {
591  i2c_master_t i2c;
593  digital_in_t int_pin;
595  const ft5xx6_controller_t * controller;
597  tp_event_t press_det;
599  tp_event_t gesture;
601 } ft5xx6_t;
602 
609 
616 
623 
630 
643 #ifdef __cplusplus
644 extern "C"{
645 #endif
646 
681 void
682 ft5xx6_cfg_setup( ft5xx6_cfg_t * cfg, const ft5xx6_controller_t * controller );
683 
719 tp_err_t
720 ft5xx6_init( ft5xx6_t * ctx, ft5xx6_cfg_t * cfg, tp_drv_t * drv );
721 
741 void
743 
764 void
765 ft5xx6_generic_write( ft5xx6_t * ctx, uint8_t reg_addr, uint8_t data_in );
766 
787 uint8_t
788 ft5xx6_generic_read_single( ft5xx6_t * ctx, uint8_t reg_addr );
789 
819 tp_err_t
820 ft5xx6_generic_read_multiple( ft5xx6_t * ctx, uint8_t reg_addr,
821  uint8_t * data_out, uint16_t n_bytes );
822 
842 void
844 
864 void
866 
890 
914 void
915 ft5xx6_press_coordinates( ft5xx6_t * ctx, tp_touch_item_t * touch_item );
916 
939 void
940 ft5xx6_gesture( ft5xx6_t * ctx, tp_event_t * event );
941 
966 tp_err_t
967 ft5xx6_process( ft5xx6_t * ctx );
968 
969 #ifdef __cplusplus
970 }
971 #endif
972 #endif // FT5XX6_H
973  // ft5xx6 // middlewaregroup
976 
977 // ------------------------------------------------------------------------ END
drv_name.h
Pin and port name type definitions.
ft5xx6_press_coordinates
void ft5xx6_press_coordinates(ft5xx6_t *ctx, tp_touch_item_t *touch_item)
FT5xx6 Pressure Coordinates Check Function.
ft5xx6_gest_item_t
FT5xx6 Gesture Item Definition.
Definition: ft5xx6.h:553
i2c_master_t
I2C Master driver context structure, consisted of the following fields :
Definition: drv_i2c_master.h:119
FT5XX6_GESTURE_ITEMS_MAX
#define FT5XX6_GESTURE_ITEMS_MAX
FT5xx6 Gesture Items Limit Setting.
Definition: ft5xx6.h:428
FT5XX6_DEV_MODE_SYS_INFO
Definition: ft5xx6.h:530
FT5XX6_DEV_MODE_NORMAL
Definition: ft5xx6.h:529
tp.h
Touch Panel API Library.
ft5xx6_default_cfg
void ft5xx6_default_cfg(ft5xx6_t *ctx)
FT5xx6 Default Configuration Function.
FT5XX6_RUN_MODE_AUTO_CAL
Definition: ft5xx6.h:545
ft5xx6_generic_read_single
uint8_t ft5xx6_generic_read_single(ft5xx6_t *ctx, uint8_t reg_addr)
FT5xx6 Generic Single Read Function.
FT5X46_CONTROLLER
const ft5xx6_controller_t FT5X46_CONTROLLER
FT5x46 Touch Controllers Descriptor.
FT5XX6_RUN_MODE_CAL
Definition: ft5xx6.h:543
drv_digital_in.h
API for Digital input driver.
tp_event_t
tp_event_t
Touch Panel Event Code Definition.
Definition: tp.h:79
ft5xx6_gesture
void ft5xx6_gesture(ft5xx6_t *ctx, tp_event_t *event)
FT5xx6 Gesture Check Function.
FT5XX6_DEV_MODE_TEST
Definition: ft5xx6.h:531
digital_in_t
Digital input driver context structure, consisted of the following fields :
Definition: drv_digital_in.h:71
ft5xx6_init
tp_err_t ft5xx6_init(ft5xx6_t *ctx, ft5xx6_cfg_t *cfg, tp_drv_t *drv)
FT5xx6 Initialization Function.
tp_touch_item_t
Touch Item Definition.
Definition: tp.h:149
FT5XX6_RUN_MODE_CFG
Definition: ft5xx6.h:541
ft5xx6_generic_write
void ft5xx6_generic_write(ft5xx6_t *ctx, uint8_t reg_addr, uint8_t data_in)
FT5xx6 Generic Write Function.
ft5xx6_t
FT5xx6 Context Object.
Definition: ft5xx6.h:588
ft5xx6_press_detect
tp_event_t ft5xx6_press_detect(ft5xx6_t *ctx)
FT5xx6 Touch Pressure Detect Function.
ft5xx6_run_mode_t
ft5xx6_run_mode_t
FT5xx6 Run Mode Settings.
Definition: ft5xx6.h:539
FT5X16_CONTROLLER
const ft5xx6_controller_t FT5X16_CONTROLLER
FT5x16 Touch Controllers Descriptor.
tp_err_t
tp_err_t
Touch Panel Error Code Definition.
Definition: tp.h:63
FT5X26_CONTROLLER
const ft5xx6_controller_t FT5X26_CONTROLLER
FT5x26 Touch Controllers Descriptor.
ft5xx6_dev_mode_setup
void ft5xx6_dev_mode_setup(ft5xx6_t *ctx, ft5xx6_dev_mode_t mode)
FT5xx6 Device Mode Setup Function.
drv_i2c_master.h
API for I2C master driver.
ft5xx6_process
tp_err_t ft5xx6_process(ft5xx6_t *ctx)
FT5xx6 Process Function.
ft5xx6_cfg_setup
void ft5xx6_cfg_setup(ft5xx6_cfg_t *cfg, const ft5xx6_controller_t *controller)
FT5xx6 Configuration Object Setup Function.
FT5XX6_RUN_MODE_WORK
Definition: ft5xx6.h:542
FT5X06_CONTROLLER
const ft5xx6_controller_t FT5X06_CONTROLLER
FT5x06 Touch Controllers Descriptor.
ft5xx6_controller_t
FT5xx6 Gesture Items.
Definition: ft5xx6.h:564
FT5XX6_RUN_MODE_FACT
Definition: ft5xx6.h:544
pin_name_t
hal_pin_name_t pin_name_t
Definition: drv_name.h:73
ft5xx6_dev_mode_t
ft5xx6_dev_mode_t
FT5xx6 Device Mode Settings.
Definition: ft5xx6.h:527
ft5xx6_run_mode_setup
void ft5xx6_run_mode_setup(ft5xx6_t *ctx, ft5xx6_run_mode_t mode)
FT5xx6 Run Mode Setup Function.
ft5xx6_generic_read_multiple
tp_err_t ft5xx6_generic_read_multiple(ft5xx6_t *ctx, uint8_t reg_addr, uint8_t *data_out, uint16_t n_bytes)
FT5xx6 Generic Multiple Read Function.
tp_drv_t
Touch Panel Driver Interface Items.
Definition: tp.h:197
ft5xx6_cfg_t
FT5xx6 Configuration Object.
Definition: ft5xx6.h:574
i2c_master_config_t
I2C Master initialization configuration structure, consisted of the following fields :
Definition: drv_i2c_master.h:95