focaltech_ts.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * File : focaltech_ts.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017-01-01 Urey first version
  23. */
  24. #ifndef _FOCALTECH_TS_H_
  25. #define _FOCALTECH_TS_H_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include <stdint.h>
  30. /* -- dirver configure -- */
  31. #define FTS_SLAVE_ADDR (0x70 >> 1)
  32. #define CFG_MAX_TOUCH_POINTS 10
  33. #define FTS_PRESS_MAX 0xFF
  34. #define FTS_PRESS 0x08
  35. #define FTS_NAME "FTS"
  36. #define FTS_INPUT_DEV_NAME "focal-touchscreen"
  37. #define FTS_MAX_ID 0x0F
  38. #define FTS_TOUCH_STEP 6
  39. #define FTS_TOUCH_X_H_POS 3
  40. #define FTS_TOUCH_X_L_POS 4
  41. #define FTS_TOUCH_Y_H_POS 5
  42. #define FTS_TOUCH_Y_L_POS 6
  43. #define FTS_TOUCH_XY_POS 7
  44. #define FTS_TOUCH_MISC 8
  45. #define FTS_TOUCH_EVENT_POS 3
  46. #define FTS_TOUCH_ID_POS 5
  47. #define FT_TOUCH_POINT_NUM 2
  48. #define POINT_READ_BUF (3 + FTS_TOUCH_STEP * CFG_MAX_TOUCH_POINTS)
  49. /*register address*/
  50. #define FTS_REG_CHIP_ID 0xA3 //chip ID
  51. #define FTS_REG_FW_VER 0xA6
  52. #define FTS_REG_POINT_RATE 0x88
  53. #define FTS_REG_THGROUP 0x80
  54. #define FTS_REG_VENDOR_ID 0xA8
  55. #define FTS_ENABLE_IRQ 1
  56. #define FTS_DISABLE_IRQ 0
  57. #define TPD_MAX_POINTS_2 2
  58. #define TPD_MAX_POINTS_5 5
  59. #define TPD_MAXPOINTS_10 10
  60. #define AUTO_CLB_NEED 1
  61. #define AUTO_CLB_NONEED 0
  62. #define TOUCH_SWAP_XY 1
  63. #define TOUCH_SWAP_X 0
  64. #define TOUCH_SWAP_Y 1
  65. struct Upgrade_Info
  66. {
  67. uint8_t CHIP_ID;
  68. uint8_t FTS_NAME_INFO[20];
  69. uint8_t TPD_MAX_POINTS;
  70. uint8_t AUTO_CLB;
  71. uint16_t delay_aa; /*delay of write FTS_UPGRADE_AA */
  72. uint16_t delay_55; /*delay of write FTS_UPGRADE_55 */
  73. uint8_t upgrade_id_1; /*upgrade id 1 */
  74. uint8_t upgrade_id_2; /*upgrade id 2 */
  75. uint16_t delay_readid; /*delay of read id */
  76. uint16_t delay_earse_flash; /*delay of earse flash*/
  77. };
  78. /* The platform data for the Focaltech focaltech touchscreen driver */
  79. struct fts_platform_data
  80. {
  81. uint32_t gpio_irq; /* IRQ port*/
  82. uint32_t irq_cfg;
  83. uint32_t gpio_wakeup; /* Wakeup support*/
  84. uint32_t wakeup_cfg;
  85. uint32_t gpio_reset; /* Reset support*/
  86. uint32_t reset_cfg;
  87. int screen_max_x;
  88. int screen_max_y;
  89. int pressure_max;
  90. };
  91. struct fts_event
  92. {
  93. uint16_t au16_x[CFG_MAX_TOUCH_POINTS]; /*x coordinate */
  94. uint16_t au16_y[CFG_MAX_TOUCH_POINTS]; /*y coordinate */
  95. uint8_t au8_touch_event[CFG_MAX_TOUCH_POINTS]; /*touch event:0 -- down; 1-- contact; 2 -- contact */
  96. uint8_t au8_finger_id[CFG_MAX_TOUCH_POINTS]; /*touch ID */
  97. uint8_t au8_finger_weight[CFG_MAX_TOUCH_POINTS]; /*touch weight */
  98. uint8_t pressure[CFG_MAX_TOUCH_POINTS];
  99. uint8_t area[CFG_MAX_TOUCH_POINTS];
  100. uint8_t touch_point;
  101. uint8_t touch_point_num;
  102. };
  103. struct focal_i2c_platform_data
  104. {
  105. uint16_t version;
  106. int abs_x_min;
  107. int abs_x_max;
  108. int abs_y_min;
  109. int abs_y_max;
  110. int intr_gpio;
  111. int rst_gpio;
  112. };
  113. struct fts_ts_data
  114. {
  115. uint8_t addr;
  116. uint8_t fw_ver; //firmware version
  117. uint32_t x_min,x_max;
  118. uint32_t y_min,y_max;
  119. uint32_t init_success;
  120. struct fts_event event;
  121. struct rt_i2c_bus_device *i2c_bus;
  122. struct rt_semaphore sem;
  123. int touchs;
  124. };
  125. void fts_ts_interrupt_cb(struct fts_ts_data *fts_ts);
  126. int fts_ts_probe(struct fts_ts_data *fts_ts,struct rt_i2c_bus_device *i2c_bus, const uint8_t addr);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif /* _FOCALTECH_TS_H_ */