ft5336.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /**
  2. ******************************************************************************
  3. * @file ft5336.c
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 25-June-2015
  7. * @brief This file provides a set of functions needed to manage the FT5336
  8. * touch screen devices.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Includes ------------------------------------------------------------------*/
  39. #include "ft5336.h"
  40. /** @addtogroup BSP
  41. * @{
  42. */
  43. /** @addtogroup Component
  44. * @{
  45. */
  46. /** @defgroup FT5336
  47. * @{
  48. */
  49. /* Private typedef -----------------------------------------------------------*/
  50. /** @defgroup FT5336_Private_Types_Definitions
  51. * @{
  52. */
  53. /* Private define ------------------------------------------------------------*/
  54. /** @defgroup FT5336_Private_Defines
  55. * @{
  56. */
  57. /* Private macro -------------------------------------------------------------*/
  58. /** @defgroup FT5336_Private_Macros
  59. * @{
  60. */
  61. /* Private variables ---------------------------------------------------------*/
  62. /** @defgroup FT5336_Private_Variables
  63. * @{
  64. */
  65. #if 0
  66. /* Touch screen driver structure initialization */
  67. TS_DrvTypeDef ft5336_ts_drv =
  68. {
  69. ft5336_Init,
  70. ft5336_ReadID,
  71. ft5336_Reset,
  72. ft5336_TS_Start,
  73. ft5336_TS_DetectTouch,
  74. ft5336_TS_GetXY,
  75. ft5336_TS_EnableIT,
  76. ft5336_TS_ClearIT,
  77. ft5336_TS_ITStatus,
  78. ft5336_TS_DisableIT
  79. };
  80. #endif
  81. /* Global ft5336 handle */
  82. static ft5336_handle_TypeDef ft5336_handle = { FT5336_I2C_NOT_INITIALIZED, 0, 0};
  83. /**
  84. * @}
  85. */
  86. /** @defgroup ft5336_Private_Function_Prototypes
  87. * @{
  88. */
  89. /* Private functions prototypes-----------------------------------------------*/
  90. /**
  91. * @brief Return the status of I2C was initialized or not.
  92. * @param None.
  93. * @retval : I2C initialization status.
  94. */
  95. static uint8_t ft5336_Get_I2C_InitializedStatus(void);
  96. /**
  97. * @brief I2C initialize if needed.
  98. * @param None.
  99. * @retval : None.
  100. */
  101. static void ft5336_I2C_InitializeIfRequired(void);
  102. /**
  103. * @brief Basic static configuration of TouchScreen
  104. * @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
  105. * @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
  106. */
  107. static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr);
  108. /** @defgroup ft5336_Private_Functions
  109. * @{
  110. */
  111. /** @defgroup ft5336_Public_Function_Body
  112. * @{
  113. */
  114. /* Public functions bodies-----------------------------------------------*/
  115. /**
  116. * @brief Initialize the ft5336 communication bus
  117. * from MCU to FT5336 : ie I2C channel initialization (if required).
  118. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  119. * @retval None
  120. */
  121. void ft5336_Init(uint16_t DeviceAddr)
  122. {
  123. /* Wait at least 200ms after power up before accessing registers
  124. * Trsi timing (Time of starting to report point after resetting) from FT5336GQQ datasheet */
  125. TS_IO_Delay(200);
  126. /* Initialize I2C link if needed */
  127. ft5336_I2C_InitializeIfRequired();
  128. }
  129. /**
  130. * @brief Software Reset the ft5336.
  131. * @note : Not applicable to FT5336.
  132. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  133. * @retval None
  134. */
  135. void ft5336_Reset(uint16_t DeviceAddr)
  136. {
  137. /* Do nothing */
  138. /* No software reset sequence available in FT5336 IC */
  139. }
  140. /**
  141. * @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
  142. * able to read the FT5336 device ID, and verify this is a FT5336.
  143. * @param DeviceAddr: I2C FT5336 Slave address.
  144. * @retval The Device ID (two bytes).
  145. */
  146. uint16_t ft5336_ReadID(uint16_t DeviceAddr)
  147. {
  148. volatile uint8_t ucReadId = 0;
  149. uint8_t nbReadAttempts = 0;
  150. uint8_t bFoundDevice = 0; /* Device not found by default */
  151. /* Initialize I2C link if needed */
  152. ft5336_I2C_InitializeIfRequired();
  153. /* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */
  154. for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++)
  155. {
  156. /* Read register FT5336_CHIP_ID_REG as DeviceID detection */
  157. ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG);
  158. /* Found the searched device ID ? */
  159. if(ucReadId == FT5336_ID_VALUE)
  160. {
  161. /* Set device as found */
  162. bFoundDevice = 1;
  163. }
  164. }
  165. /* Return the device ID value */
  166. return (ucReadId);
  167. }
  168. /**
  169. * @brief Configures the touch Screen IC device to start detecting touches
  170. * @param DeviceAddr: Device address on communication Bus (I2C slave address).
  171. * @retval None.
  172. */
  173. void ft5336_TS_Start(uint16_t DeviceAddr)
  174. {
  175. /* Minimum static configuration of FT5336 */
  176. FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr));
  177. /* By default set FT5336 IC in Polling mode : no INT generation on FT5336 for new touch available */
  178. /* Note TS_INT is active low */
  179. ft5336_TS_DisableIT(DeviceAddr);
  180. }
  181. /**
  182. * @brief Return if there is touches detected or not.
  183. * Try to detect new touches and forget the old ones (reset internal global
  184. * variables).
  185. * @param DeviceAddr: Device address on communication Bus.
  186. * @retval : Number of active touches detected (can be 0, 1 or 2).
  187. */
  188. uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
  189. {
  190. volatile uint8_t nbTouch = 0;
  191. /* Read register FT5336_TD_STAT_REG to check number of touches detection */
  192. nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG);
  193. nbTouch &= FT5336_TD_STAT_MASK;
  194. if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH)
  195. {
  196. /* If invalid number of touch detected, set it to zero */
  197. nbTouch = 0;
  198. }
  199. /* Update ft5336 driver internal global : current number of active touches */
  200. ft5336_handle.currActiveTouchNb = nbTouch;
  201. /* Reset current active touch index on which to work on */
  202. ft5336_handle.currActiveTouchIdx = 0;
  203. return(nbTouch);
  204. }
  205. /**
  206. * @brief Get the touch screen X and Y positions values
  207. * Manage multi touch thanks to touch Index global
  208. * variable 'ft5336_handle.currActiveTouchIdx'.
  209. * @param DeviceAddr: Device address on communication Bus.
  210. * @param X: Pointer to X position value
  211. * @param Y: Pointer to Y position value
  212. * @retval None.
  213. */
  214. void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
  215. {
  216. volatile uint8_t ucReadData = 0;
  217. static uint16_t coord;
  218. uint8_t regAddressXLow = 0;
  219. uint8_t regAddressXHigh = 0;
  220. uint8_t regAddressYLow = 0;
  221. uint8_t regAddressYHigh = 0;
  222. if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb)
  223. {
  224. switch(ft5336_handle.currActiveTouchIdx)
  225. {
  226. case 0 :
  227. regAddressXLow = FT5336_P1_XL_REG;
  228. regAddressXHigh = FT5336_P1_XH_REG;
  229. regAddressYLow = FT5336_P1_YL_REG;
  230. regAddressYHigh = FT5336_P1_YH_REG;
  231. break;
  232. case 1 :
  233. regAddressXLow = FT5336_P2_XL_REG;
  234. regAddressXHigh = FT5336_P2_XH_REG;
  235. regAddressYLow = FT5336_P2_YL_REG;
  236. regAddressYHigh = FT5336_P2_YH_REG;
  237. break;
  238. case 2 :
  239. regAddressXLow = FT5336_P3_XL_REG;
  240. regAddressXHigh = FT5336_P3_XH_REG;
  241. regAddressYLow = FT5336_P3_YL_REG;
  242. regAddressYHigh = FT5336_P3_YH_REG;
  243. break;
  244. case 3 :
  245. regAddressXLow = FT5336_P4_XL_REG;
  246. regAddressXHigh = FT5336_P4_XH_REG;
  247. regAddressYLow = FT5336_P4_YL_REG;
  248. regAddressYHigh = FT5336_P4_YH_REG;
  249. break;
  250. case 4 :
  251. regAddressXLow = FT5336_P5_XL_REG;
  252. regAddressXHigh = FT5336_P5_XH_REG;
  253. regAddressYLow = FT5336_P5_YL_REG;
  254. regAddressYHigh = FT5336_P5_YH_REG;
  255. break;
  256. case 5 :
  257. regAddressXLow = FT5336_P6_XL_REG;
  258. regAddressXHigh = FT5336_P6_XH_REG;
  259. regAddressYLow = FT5336_P6_YL_REG;
  260. regAddressYHigh = FT5336_P6_YH_REG;
  261. break;
  262. case 6 :
  263. regAddressXLow = FT5336_P7_XL_REG;
  264. regAddressXHigh = FT5336_P7_XH_REG;
  265. regAddressYLow = FT5336_P7_YL_REG;
  266. regAddressYHigh = FT5336_P7_YH_REG;
  267. break;
  268. case 7 :
  269. regAddressXLow = FT5336_P8_XL_REG;
  270. regAddressXHigh = FT5336_P8_XH_REG;
  271. regAddressYLow = FT5336_P8_YL_REG;
  272. regAddressYHigh = FT5336_P8_YH_REG;
  273. break;
  274. case 8 :
  275. regAddressXLow = FT5336_P9_XL_REG;
  276. regAddressXHigh = FT5336_P9_XH_REG;
  277. regAddressYLow = FT5336_P9_YL_REG;
  278. regAddressYHigh = FT5336_P9_YH_REG;
  279. break;
  280. case 9 :
  281. regAddressXLow = FT5336_P10_XL_REG;
  282. regAddressXHigh = FT5336_P10_XH_REG;
  283. regAddressYLow = FT5336_P10_YL_REG;
  284. regAddressYHigh = FT5336_P10_YH_REG;
  285. break;
  286. default :
  287. break;
  288. } /* end switch(ft5336_handle.currActiveTouchIdx) */
  289. /* Read low part of X position */
  290. ucReadData = TS_IO_Read(DeviceAddr, regAddressXLow);
  291. coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
  292. /* Read high part of X position */
  293. ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
  294. coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
  295. /* Send back ready X position to caller */
  296. *X = coord;
  297. /* Read low part of Y position */
  298. ucReadData = TS_IO_Read(DeviceAddr, regAddressYLow);
  299. coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
  300. /* Read high part of Y position */
  301. ucReadData = TS_IO_Read(DeviceAddr, regAddressYHigh);
  302. coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
  303. /* Send back ready Y position to caller */
  304. *Y = coord;
  305. ft5336_handle.currActiveTouchIdx++; /* next call will work on next touch */
  306. } /* of if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) */
  307. }
  308. /**
  309. * @brief Configure the FT5336 device to generate IT on given INT pin
  310. * connected to MCU as EXTI.
  311. * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
  312. * @retval None
  313. */
  314. void ft5336_TS_EnableIT(uint16_t DeviceAddr)
  315. {
  316. uint8_t regValue = 0;
  317. regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
  318. /* Set interrupt trigger mode in FT5336_GMODE_REG */
  319. TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
  320. }
  321. /**
  322. * @brief Configure the FT5336 device to stop generating IT on the given INT pin
  323. * connected to MCU as EXTI.
  324. * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
  325. * @retval None
  326. */
  327. void ft5336_TS_DisableIT(uint16_t DeviceAddr)
  328. {
  329. uint8_t regValue = 0;
  330. regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
  331. /* Set interrupt polling mode in FT5336_GMODE_REG */
  332. TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
  333. }
  334. /**
  335. * @brief Get IT status from FT5336 interrupt status registers
  336. * Should be called Following an EXTI coming to the MCU to know the detailed
  337. * reason of the interrupt.
  338. * @note : This feature is not applicable to FT5336.
  339. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  340. * @retval TS interrupts status : always return 0 here
  341. */
  342. uint8_t ft5336_TS_ITStatus(uint16_t DeviceAddr)
  343. {
  344. /* Always return 0 as feature not applicable to FT5336 */
  345. return 0;
  346. }
  347. /**
  348. * @brief Clear IT status in FT5336 interrupt status clear registers
  349. * Should be called Following an EXTI coming to the MCU.
  350. * @note : This feature is not applicable to FT5336.
  351. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  352. * @retval None
  353. */
  354. void ft5336_TS_ClearIT(uint16_t DeviceAddr)
  355. {
  356. /* Nothing to be done here for FT5336 */
  357. }
  358. /**** NEW FEATURES enabled when Multi-touch support is enabled ****/
  359. #if (TS_MULTI_TOUCH_SUPPORTED == 1)
  360. /**
  361. * @brief Get the last touch gesture identification (zoom, move up/down...).
  362. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  363. * @param pGestureId : Pointer to get last touch gesture Identification.
  364. * @retval None.
  365. */
  366. void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
  367. {
  368. volatile uint8_t ucReadData = 0;
  369. ucReadData = TS_IO_Read(DeviceAddr, FT5336_GEST_ID_REG);
  370. * pGestureId = ucReadData;
  371. }
  372. /**
  373. * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
  374. * This touch detailed information contains :
  375. * - weight that was applied to this touch
  376. * - sub-area of the touch in the touch panel
  377. * - event of linked to the touch (press down, lift up, ...)
  378. * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
  379. * @param touchIdx : Passed index of the touch (0..1) on which we want to get the
  380. * detailed information.
  381. * @param pWeight : Pointer to to get the weight information of 'touchIdx'.
  382. * @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
  383. * @param pEvent : Pointer to to get the event information of 'touchIdx'.
  384. * @retval None.
  385. */
  386. void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
  387. uint32_t touchIdx,
  388. uint32_t * pWeight,
  389. uint32_t * pArea,
  390. uint32_t * pEvent)
  391. {
  392. volatile uint8_t ucReadData = 0;
  393. uint8_t regAddressXHigh = 0;
  394. uint8_t regAddressPWeight = 0;
  395. uint8_t regAddressPMisc = 0;
  396. if(touchIdx < ft5336_handle.currActiveTouchNb)
  397. {
  398. switch(touchIdx)
  399. {
  400. case 0 :
  401. regAddressXHigh = FT5336_P1_XH_REG;
  402. regAddressPWeight = FT5336_P1_WEIGHT_REG;
  403. regAddressPMisc = FT5336_P1_MISC_REG;
  404. break;
  405. case 1 :
  406. regAddressXHigh = FT5336_P2_XH_REG;
  407. regAddressPWeight = FT5336_P2_WEIGHT_REG;
  408. regAddressPMisc = FT5336_P2_MISC_REG;
  409. break;
  410. case 2 :
  411. regAddressXHigh = FT5336_P3_XH_REG;
  412. regAddressPWeight = FT5336_P3_WEIGHT_REG;
  413. regAddressPMisc = FT5336_P3_MISC_REG;
  414. break;
  415. case 3 :
  416. regAddressXHigh = FT5336_P4_XH_REG;
  417. regAddressPWeight = FT5336_P4_WEIGHT_REG;
  418. regAddressPMisc = FT5336_P4_MISC_REG;
  419. break;
  420. case 4 :
  421. regAddressXHigh = FT5336_P5_XH_REG;
  422. regAddressPWeight = FT5336_P5_WEIGHT_REG;
  423. regAddressPMisc = FT5336_P5_MISC_REG;
  424. break;
  425. case 5 :
  426. regAddressXHigh = FT5336_P6_XH_REG;
  427. regAddressPWeight = FT5336_P6_WEIGHT_REG;
  428. regAddressPMisc = FT5336_P6_MISC_REG;
  429. break;
  430. case 6 :
  431. regAddressXHigh = FT5336_P7_XH_REG;
  432. regAddressPWeight = FT5336_P7_WEIGHT_REG;
  433. regAddressPMisc = FT5336_P7_MISC_REG;
  434. break;
  435. case 7 :
  436. regAddressXHigh = FT5336_P8_XH_REG;
  437. regAddressPWeight = FT5336_P8_WEIGHT_REG;
  438. regAddressPMisc = FT5336_P8_MISC_REG;
  439. break;
  440. case 8 :
  441. regAddressXHigh = FT5336_P9_XH_REG;
  442. regAddressPWeight = FT5336_P9_WEIGHT_REG;
  443. regAddressPMisc = FT5336_P9_MISC_REG;
  444. break;
  445. case 9 :
  446. regAddressXHigh = FT5336_P10_XH_REG;
  447. regAddressPWeight = FT5336_P10_WEIGHT_REG;
  448. regAddressPMisc = FT5336_P10_MISC_REG;
  449. break;
  450. default :
  451. break;
  452. } /* end switch(touchIdx) */
  453. /* Read Event Id of touch index */
  454. ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
  455. * pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT;
  456. /* Read weight of touch index */
  457. ucReadData = TS_IO_Read(DeviceAddr, regAddressPWeight);
  458. * pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT;
  459. /* Read area of touch index */
  460. ucReadData = TS_IO_Read(DeviceAddr, regAddressPMisc);
  461. * pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT;
  462. } /* of if(touchIdx < ft5336_handle.currActiveTouchNb) */
  463. }
  464. #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
  465. /** @defgroup ft5336_Static_Function_Body
  466. * @{
  467. */
  468. /* Static functions bodies-----------------------------------------------*/
  469. /**
  470. * @brief Return the status of I2C was initialized or not.
  471. * @param None.
  472. * @retval : I2C initialization status.
  473. */
  474. static uint8_t ft5336_Get_I2C_InitializedStatus(void)
  475. {
  476. return(ft5336_handle.i2cInitialized);
  477. }
  478. /**
  479. * @brief I2C initialize if needed.
  480. * @param None.
  481. * @retval : None.
  482. */
  483. static void ft5336_I2C_InitializeIfRequired(void)
  484. {
  485. if(ft5336_Get_I2C_InitializedStatus() == FT5336_I2C_NOT_INITIALIZED)
  486. {
  487. /* Initialize TS IO BUS layer (I2C) */
  488. TS_IO_Init();
  489. /* Set state to initialized */
  490. ft5336_handle.i2cInitialized = FT5336_I2C_INITIALIZED;
  491. }
  492. }
  493. /**
  494. * @brief Basic static configuration of TouchScreen
  495. * @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
  496. * @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
  497. */
  498. static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr)
  499. {
  500. uint32_t status = FT5336_STATUS_OK;
  501. /* Nothing special to be done for FT5336 */
  502. return(status);
  503. }
  504. /**
  505. * @}
  506. */
  507. /**
  508. * @}
  509. */
  510. /**
  511. * @}
  512. */
  513. /**
  514. * @}
  515. */
  516. /**
  517. * @}
  518. */
  519. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/