ftsTool.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * FTS Capacitive touch screen controller (FingerTipS)
  4. *
  5. * Copyright (C) 2016-2019, STMicroelectronics Limited.
  6. * Authors: AMG(Analog Mems Group) <[email protected]>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. *
  23. **************************************************************************
  24. ** STMicroelectronics **
  25. **************************************************************************
  26. ** [email protected] **
  27. **************************************************************************
  28. * *
  29. * FTS Utility Functions *
  30. * *
  31. **************************************************************************
  32. **************************************************************************
  33. *
  34. */
  35. #ifndef __FTS_TOOL_H
  36. #define __FTS_TOOL_H
  37. #define GPIO_NOT_DEFINED -1
  38. #define TIMEOUT_RESOLUTION 10 //ms
  39. #define GENERAL_TIMEOUT (50*TIMEOUT_RESOLUTION) //ms
  40. #define RELEASE_INFO_TIMEOUT (15*TIMEOUT_RESOLUTION) //ms
  41. #define FEAT_ENABLE 1
  42. #define FEAT_DISABLE 0
  43. #define SYSTEM_RESET_RETRY 3
  44. #define B2_RETRY 2
  45. //for FTM4 can not be greater than 13 bytes
  46. #define LOCKDOWN_CODE_SIZE 10
  47. #define LOCKDOWN_CODE_MAX_SIZE 63
  48. #define LOCKDOWN_CODE_WRITE_CHUNK 12
  49. #define LOCKDOWN_CODE_READ_CHUNK 4
  50. #define LOCKDOWN_CODE_RETRY 2
  51. int readB2(u16 address, u8 *outBuf, int len);
  52. int readB2U16(u16 address, u8 *outBuf, int byteToRead);
  53. int releaseInformation(void);
  54. int lockDownInfo(u8 *data, int len);
  55. int calculateCRC8(u8 *u8_srcBuff, int size, u8 *crc);
  56. int writeLockDownInfo(u8 *data, int size);
  57. int rewriteLockDownInfo(u8 *data, int size);
  58. int readLockDownInfo(u8 *lockData, int *size);
  59. char *printHex(char *label, u8 *buff, int count);
  60. int pollForEvent(int *event_to_search, int event_bytes,
  61. u8 *readData, int time_to_wait);
  62. int fts_disableInterrupt(void);
  63. int fts_enableInterrupt(void);
  64. int u8ToU16(u8 *src, u16 *dst);
  65. int u8ToU16_le(u8 *src, u16 *dst);
  66. int u8ToU16n(u8 *src, int src_length, u16 *dst);
  67. int u16ToU8(u16 src, u8 *dst);
  68. int u16ToU8_le(u16 src, u8 *dst);
  69. int u16ToU8_be(u16 src, u8 *dst);
  70. int u16ToU8n(u16 *src, int src_length, u8 *dst);
  71. int u8ToU32(u8 *src, u32 *dst);
  72. int u32ToU8(u32 src, u8 *dst);
  73. int attempt_function(int(*code)(void), unsigned long wait_before_retry,
  74. int retry_count);
  75. void setResetGpio(int gpio);
  76. int fts_system_reset(void);
  77. int isSystemResettedUp(void);
  78. int isSystemResettedDown(void);
  79. void setSystemResettedUp(int val);
  80. void setSystemResettedDown(int val);
  81. int senseOn(void);
  82. int senseOff(void);
  83. int keyOn(void);
  84. int keyOff(void);
  85. int featureEnableDisable(int on_off, u32 feature);
  86. int writeNoiseParameters(u8 *noise);
  87. int readNoiseParameters(u8 *noise);
  88. int checkEcho(u8 *cmd, int size);
  89. void print_frame_short(char *label, short **matrix, int row, int column);
  90. short **array1dTo2d_short(short *data, int size, int columns);
  91. u8 **array1dTo2d_u8(u8 *data, int size, int columns);
  92. void print_frame_u8(char *label, u8 **matrix, int row, int column);
  93. void print_frame_u32(char *label, u32 **matrix, int row, int column);
  94. void print_frame_int(char *label, int **matrix, int row, int column);
  95. int cleanUp(int enableTouch);
  96. int flushFIFO(void);
  97. #endif