1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2017 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef _FSL_FT5406_RT_H_ 10 #define _FSL_FT5406_RT_H_ 11 12 #include "fsl_common.h" 13 14 /*! 15 * @addtogroup ft5406_rt 16 * @{ 17 */ 18 19 /******************************************************************************* 20 * Definitions 21 ******************************************************************************/ 22 23 /*! @brief FT5406_RT I2C address. */ 24 #define FT5406_RT_I2C_ADDRESS (0x38) 25 26 /*! @brief FT5406_RT maximum number of simultaneously detected touches. */ 27 #define FT5406_RT_MAX_TOUCHES (5U) 28 29 /*! @brief FT5406_RT register address where touch data begin. */ 30 #define FT5406_RT_TOUCH_DATA_SUBADDR (1) 31 32 /*! @brief FT5406_RT raw touch data length. */ 33 #define FT5406_RT_TOUCH_DATA_LEN (0x20) 34 35 typedef enum _touch_event 36 { 37 kTouch_Down = 0, /*!< The state changed to touched. */ 38 kTouch_Up = 1, /*!< The state changed to not touched. */ 39 kTouch_Contact = 2, /*!< There is a continuous touch being detected. */ 40 kTouch_Reserved = 3 /*!< No touch information available. */ 41 } touch_event_t; 42 43 typedef struct _touch_point 44 { 45 touch_event_t TOUCH_EVENT; /*!< Indicates the state or event of the touch point. */ 46 uint8_t TOUCH_ID; /*!< Id of the touch point. This numeric value stays constant between down and up event. */ 47 uint16_t TOUCH_X; /*!< X coordinate of the touch point */ 48 uint16_t TOUCH_Y; /*!< Y coordinate of the touch point */ 49 } touch_point_t; 50 51 typedef struct _ft5406_rt_handle 52 { 53 LPI2C_Type *base; 54 lpi2c_master_transfer_t xfer; 55 uint8_t touch_buf[FT5406_RT_TOUCH_DATA_LEN]; 56 } ft5406_rt_handle_t; 57 58 status_t FT5406_RT_Init(ft5406_rt_handle_t *handle, LPI2C_Type *base); 59 60 status_t FT5406_RT_Denit(ft5406_rt_handle_t *handle); 61 62 status_t FT5406_RT_GetSingleTouch(ft5406_rt_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y); 63 64 status_t FT5406_RT_GetMultiTouch(ft5406_rt_handle_t *handle, 65 int *touch_count, 66 touch_point_t touch_array[FT5406_RT_MAX_TOUCHES]); 67 68 #endif 69