mxt.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /****************************************************************************
  2. * drivers/input/mxt.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __DRIVERS_INPUT_MXT_H
  21. #define __DRIVERS_INPUT_MXT_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. /****************************************************************************
  27. * Pre-processor Definitions
  28. ****************************************************************************/
  29. /* Configuration ************************************************************/
  30. /* Support T6 only if debug is enabled */
  31. #undef MXT_SUPPORT_T6
  32. #if !defined(CONFIG_DEBUG_FEATURES)
  33. # undef CONFIG_DEBUG_INFO
  34. # undef CONFIG_DEBUG_INPUT
  35. #endif
  36. #if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_INPUT)
  37. # define MXT_SUPPORT_T6 1
  38. #endif
  39. /* MXT Register Definitions *************************************************/
  40. #define MXT_INFO 0x00 /* 7-bit info block */
  41. # define MXT_FAMILY_ID 0x00 /* MXT family ID */
  42. # define MXT_VARIANT_ID 0x01 /* MXT variant ID */
  43. # define MXT_VERSION 0x02 /* MXT version number */
  44. # define MXT_BUILD 0x03 /* MXT build number */
  45. # define MXT_MATRIX_X_SIZE 0x04 /* Matrix X size */
  46. # define MXT_MATRIX_Y_SIZE 0x05 /* Matrix Y size */
  47. # define MXT_OBJECT_NUM 0x06 /* Number of objects */
  48. #define MXT_OBJECT_START 0x07
  49. /* Object types */
  50. #define MXT_GEN_MESSAGE_T5 5
  51. #define MXT_GEN_COMMAND_T6 6
  52. #define MXT_GEN_POWER_T7 7
  53. #define MXT_GEN_ACQUIRE_T8 8
  54. #define MXT_TOUCH_MULTI_T9 9
  55. #define MXT_TOUCH_KEYARRAY_T15 15
  56. #define MXT_SPT_COMMSCONFIG_T18 18
  57. #define MXT_SPT_GPIOPWM_T19 19
  58. #define MXT_PROCI_GRIPFACE_T20 20
  59. #define MXT_PROCG_NOISE_T22 22
  60. #define MXT_TOUCH_PROXIMITY_T23 23
  61. #define MXT_PROCI_ONETOUCH_T24 24
  62. #define MXT_SPT_SELFTEST_T25 25
  63. #define MXT_PROCI_TWOTOUCH_T27 27
  64. #define MXT_SPT_CTECONFIG_T28 28
  65. #define MXT_DEBUG_DIAGNOSTIC_T37 37
  66. #define MXT_SPT_USERDATA_T38 38
  67. #define MXT_PROCI_GRIP_T40 40
  68. #define MXT_PROCI_PALM_T41 41
  69. #define MXT_PROCI_TOUCHSUPPRESSION_T42 42
  70. #define MXT_SPT_DIGITIZER_T43 43
  71. #define MXT_SPT_MESSAGECOUNT_T44 44
  72. #define MXT_SPT_CTECONFIG_T46 46
  73. #define MXT_PROCI_STYLUS_T47 47
  74. #define MXT_PROCG_NOISESUPPRESSION_T48 48
  75. #define MXT_TOUCH_PROXKEY_T52 52
  76. #define MXT_GEN_DATASOURCE_T53 53
  77. /* MXT_GEN_COMMAND_T6 field */
  78. #define MXT_COMMAND_RESET 0
  79. #define MXT_COMMAND_BACKUPNV 1
  80. #define MXT_COMMAND_CALIBRATE 2
  81. #define MXT_COMMAND_REPORTALL 3
  82. #define MXT_COMMAND_DIAGNOSTIC 5
  83. /* MXT_GEN_POWER_T7 field */
  84. #define MXT_POWER_IDLEACQINT 0
  85. #define MXT_POWER_ACTVACQINT 1
  86. #define MXT_POWER_ACTV2IDLETO 2
  87. /* MXT_GEN_ACQUIRE_T8 field */
  88. #define MXT_ACQUIRE_CHRGTIME 0
  89. #define MXT_ACQUIRE_TCHDRIFT 2
  90. #define MXT_ACQUIRE_DRIFTST 3
  91. #define MXT_ACQUIRE_TCHAUTOCAL 4
  92. #define MXT_ACQUIRE_SYNC 5
  93. #define MXT_ACQUIRE_ATCHCALST 6
  94. #define MXT_ACQUIRE_ATCHCALSTHR 7
  95. /* MXT_TOUCH_MULTI_T9 field */
  96. #define MXT_TOUCH_CTRL 0
  97. #define MXT_TOUCH_XORIGIN 1
  98. #define MXT_TOUCH_YORIGIN 2
  99. #define MXT_TOUCH_XSIZE 3
  100. #define MXT_TOUCH_YSIZE 4
  101. #define MXT_TOUCH_BLEN 6
  102. #define MXT_TOUCH_TCHTHR 7
  103. #define MXT_TOUCH_TCHDI 8
  104. #define MXT_TOUCH_ORIENT 9
  105. #define MXT_TOUCH_MOVHYSTI 11
  106. #define MXT_TOUCH_MOVHYSTN 12
  107. #define MXT_TOUCH_NUMTOUCH 14
  108. #define MXT_TOUCH_MRGHYST 15
  109. #define MXT_TOUCH_MRGTHR 16
  110. #define MXT_TOUCH_AMPHYST 17
  111. #define MXT_TOUCH_XRANGE_LSB 18
  112. #define MXT_TOUCH_XRANGE_MSB 19
  113. #define MXT_TOUCH_YRANGE_LSB 20
  114. #define MXT_TOUCH_YRANGE_MSB 21
  115. #define MXT_TOUCH_XLOCLIP 22
  116. #define MXT_TOUCH_XHICLIP 23
  117. #define MXT_TOUCH_YLOCLIP 24
  118. #define MXT_TOUCH_YHICLIP 25
  119. #define MXT_TOUCH_XEDGECTRL 26
  120. #define MXT_TOUCH_XEDGEDIST 27
  121. #define MXT_TOUCH_YEDGECTRL 28
  122. #define MXT_TOUCH_YEDGEDIST 29
  123. #define MXT_TOUCH_JUMPLIMIT 30
  124. /* MXT_PROCI_GRIPFACE_T20 field */
  125. #define MXT_GRIPFACE_CTRL 0
  126. #define MXT_GRIPFACE_XLOGRIP 1
  127. #define MXT_GRIPFACE_XHIGRIP 2
  128. #define MXT_GRIPFACE_YLOGRIP 3
  129. #define MXT_GRIPFACE_YHIGRIP 4
  130. #define MXT_GRIPFACE_MAXTCHS 5
  131. #define MXT_GRIPFACE_SZTHR1 7
  132. #define MXT_GRIPFACE_SZTHR2 8
  133. #define MXT_GRIPFACE_SHPTHR1 9
  134. #define MXT_GRIPFACE_SHPTHR2 10
  135. #define MXT_GRIPFACE_SUPEXTTO 11
  136. /* MXT_PROCI_NOISE field */
  137. #define MXT_NOISE_CTRL 0
  138. #define MXT_NOISE_OUTFLEN 1
  139. #define MXT_NOISE_GCAFUL_LSB 3
  140. #define MXT_NOISE_GCAFUL_MSB 4
  141. #define MXT_NOISE_GCAFLL_LSB 5
  142. #define MXT_NOISE_GCAFLL_MSB 6
  143. #define MXT_NOISE_ACTVGCAFVALID 7
  144. #define MXT_NOISE_NOISETHR 8
  145. #define MXT_NOISE_FREQHOPSCALE 10
  146. #define MXT_NOISE_FREQ0 11
  147. #define MXT_NOISE_FREQ1 12
  148. #define MXT_NOISE_FREQ2 13
  149. #define MXT_NOISE_FREQ3 14
  150. #define MXT_NOISE_FREQ4 15
  151. #define MXT_NOISE_IDLEGCAFVALID 16
  152. /* MXT_SPT_COMMSCONFIG_T18 */
  153. #define MXT_COMMS_CTRL 0
  154. #define MXT_COMMS_CMD 1
  155. /* MXT_SPT_CTECONFIG_T28 field */
  156. #define MXT_CTE_CTRL 0
  157. #define MXT_CTE_CMD 1
  158. #define MXT_CTE_MODE 2
  159. #define MXT_CTE_IDLEGCAFDEPTH 3
  160. #define MXT_CTE_ACTVGCAFDEPTH 4
  161. #define MXT_CTE_VOLTAGE 5
  162. #define MXT_VOLTAGE_DEFAULT 2700000
  163. #define MXT_VOLTAGE_STEP 10000
  164. /* Definitions for MXT_GEN_COMMAND_T6 */
  165. #define MXT_BOOT_VALUE 0xa5
  166. #define MXT_BACKUP_VALUE 0x55
  167. #define MXT_BACKUP_TIME 50000 /* microseconds */
  168. #define MXT_RESET_TIME 500000 /* microseconds */
  169. /* MXT_SPT_GPIOPWM_T19 field */
  170. #define MXT_MAX_BUTTONS 4 /* Up to four buttons */
  171. #define MXT_GPIO0_MASK 0x04
  172. #define MXT_GPIO1_MASK 0x08
  173. #define MXT_GPIO2_MASK 0x10
  174. #define MXT_GPIO3_MASK 0x20
  175. /* Command to unlock bootloader */
  176. #define MXT_UNLOCK_CMD_MSB 0xaa
  177. #define MXT_UNLOCK_CMD_LSB 0xdc
  178. /* Bootloader mode status */
  179. #define MXT_WAITING_BOOTLOAD_CMD 0xc0 /* Valid 7 6 bit only */
  180. #define MXT_WAITING_FRAME_DATA 0x80 /* Valid 7 6 bit only */
  181. #define MXT_FRAME_CRC_CHECK 0x02
  182. #define MXT_FRAME_CRC_FAIL 0x03
  183. #define MXT_FRAME_CRC_PASS 0x04
  184. #define MXT_APP_CRC_FAIL 0x40 /* Valid 7 8 bit only */
  185. #define MXT_BOOT_STATUS_MASK 0x3f
  186. /* Touch status */
  187. #define MXT_UNGRIP (1 << 0)
  188. #define MXT_SUPPRESS (1 << 1)
  189. #define MXT_AMP (1 << 2)
  190. #define MXT_VECTOR (1 << 3)
  191. #define MXT_MOVE (1 << 4)
  192. #define MXT_RELEASE (1 << 5)
  193. #define MXT_PRESS (1 << 6)
  194. #define MXT_DETECT (1 << 7)
  195. /* Touchscreen absolute values */
  196. #define MXT_MAX_AREA 0xff
  197. #define MXT_PIXELS_PER_MM 20
  198. /****************************************************************************
  199. * Public Types
  200. ****************************************************************************/
  201. /* This structure describes one maXTouch object */
  202. struct mxt_object_s
  203. {
  204. uint8_t type; /* Object type */
  205. uint8_t addr[2]; /* Start address */
  206. uint8_t size; /* Size of each instance - 1 */
  207. uint8_t ninstances; /* Number of instances - 1 */
  208. uint8_t nids; /* Number of report IDs */
  209. };
  210. #define MXT_OBJECT_SIZE 6
  211. /* This structure describes one maXTouch message */
  212. struct mxt_msg_s
  213. {
  214. uint8_t id; /* Report ID */
  215. uint8_t body[7]; /* Message body */
  216. };
  217. /****************************************************************************
  218. * Public Data
  219. ****************************************************************************/
  220. #ifdef __cplusplus
  221. #define EXTERN extern "C"
  222. extern "C"
  223. {
  224. #else
  225. #define EXTERN extern
  226. #endif
  227. /****************************************************************************
  228. * Public Function Prototypes
  229. ****************************************************************************/
  230. #undef EXTERN
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif /* __DRIVERS_INPUT_MXT_H */