ST / BSP_DISCO_L4R9I

Dependents:   DISCO_L4R9I-LCD-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ft3x67.h Source File

ft3x67.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    ft3x67.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains all the functions prototypes for the
00006   *          ft3x67.c touch screen driver.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
00011   * All rights reserved.</center></h2>
00012   *
00013   * This software component is licensed by ST under BSD 3-Clause license,
00014   * the "License"; You may not use this file except in compliance with the
00015   * License. You may obtain a copy of the License at:
00016   *                        opensource.org/licenses/BSD-3-Clause
00017   *
00018   ******************************************************************************
00019   */
00020 
00021 /* Define to prevent recursive inclusion -------------------------------------*/
00022 #ifndef __FT3X67_H
00023 #define __FT3X67_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /* Includes ------------------------------------------------------------------*/
00030 #include "../Common/ts.h"
00031 
00032 /** @addtogroup BSP
00033   * @{
00034   */
00035 
00036 /** @addtogroup Component
00037   * @{
00038   */
00039 
00040 /** @defgroup FT3X67
00041   * @{
00042   */
00043 
00044 /* Exported types ------------------------------------------------------------*/
00045 /* Exported constants --------------------------------------------------------*/
00046 
00047 /** @defgroup FT3X67_Exported_Constants
00048   * @{
00049   */
00050 
00051 /* Maximum border values of the touchscreen pad */
00052 #define FT3X67_MAX_WIDTH                    390U     /* Touchscreen pad max width   */
00053 #define FT3X67_MAX_HEIGHT                   390U     /* Touchscreen pad max height  */
00054 
00055 /* Possible values of driver functions return status */
00056 #define FT3X67_STATUS_OK                    0x00U
00057 #define FT3X67_STATUS_NOT_OK                0x01U
00058 
00059 /* Possible values of global variable 'TS_I2C_Initialized' */
00060 #define FT3X67_I2C_NOT_INITIALIZED          0x00U
00061 #define FT3X67_I2C_INITIALIZED              0x01U
00062 
00063 /* Max detectable simultaneous touches */
00064 #define FT3X67_MAX_DETECTABLE_TOUCH         0x02U
00065 
00066 /* Definitions for FT3X67 registers */
00067 
00068 /* Current mode register of the FT3X67 (R/W) */
00069 #define FT3X67_DEV_MODE_REG                 0x00U
00070 /* Possible values of FT3X67_DEV_MODE_REG */
00071 #define FT3X67_DEV_MODE_WORKING             0x00U
00072 #define FT3X67_DEV_MODE_FACTORY             0x40U
00073 
00074 /* Touch Data Status register : gives number of active touch points (0..2) */
00075 #define FT3X67_TD_STAT_REG                  0x02U
00076 /* Values related to FT3X67_TD_STAT_REG */
00077 #define FT3X67_TD_STAT_MASK                 0x0FU
00078 
00079 /* Values Pn_XH and Pn_YH related */
00080 #define FT3X67_TOUCH_EVT_FLAG_PRESS_DOWN    0x00U
00081 #define FT3X67_TOUCH_EVT_FLAG_LIFT_UP       0x01U
00082 #define FT3X67_TOUCH_EVT_FLAG_CONTACT       0x02U
00083 #define FT3X67_TOUCH_EVT_FLAG_NO_EVENT      0x03U
00084 #define FT3X67_TOUCH_EVT_FLAG_SHIFT         0x06U
00085 #define FT3X67_TOUCH_EVT_FLAG_MASK          (3U << FT3X67_TOUCH_EVT_FLAG_SHIFT)
00086 #define FT3X67_TOUCH_POS_MSB_MASK           0x0FU
00087 
00088 /* Point 1 registers */
00089 #define FT3X67_P1_XH_REG                    0x03U
00090 #define FT3X67_P1_XL_REG                    0x04U
00091 #define FT3X67_P1_YH_REG                    0x05U
00092 #define FT3X67_P1_YL_REG                    0x06U
00093 #define FT3X67_P1_WEIGHT_REG                0x07U
00094 #define FT3X67_P1_MISC_REG                  0x08U
00095 
00096 /* Point 2 registers */
00097 #define FT3X67_P2_XH_REG                    0x09U
00098 #define FT3X67_P2_XL_REG                    0x0AU
00099 #define FT3X67_P2_YH_REG                    0x0BU
00100 #define FT3X67_P2_YL_REG                    0x0CU
00101 #define FT3X67_P2_WEIGHT_REG                0x0DU
00102 #define FT3X67_P2_MISC_REG                  0x0EU
00103 
00104 /* Values related to Pn_MISC register */
00105 #define FT3X67_TOUCH_AREA_MASK              (0xFU << FT3X67_TOUCH_AREA_SHIFT)
00106 #define FT3X67_TOUCH_AREA_SHIFT             0x04U
00107 
00108 /* Threshold for touch detection register */
00109 #define FT3X67_TH_GROUP_REG                 0x80U
00110 
00111 /* Filter function coefficients register */
00112 #define FT3X67_TH_DIFF_REG                  0x85U
00113 
00114 /* Control register */
00115 #define FT3X67_CTRL_REG                     0x86U
00116 /* Values related to FT3X67_CTRL_REG */
00117 #define FT3X67_CTRL_KEEP_ACTIVE_MODE               0x00U
00118 #define FT3X67_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE  0x01U
00119 
00120 /* The time period of switching from Active mode to Monitor mode when there is no touching */
00121 #define FT3X67_TIMEENTERMONITOR_REG         0x87U
00122 
00123 /* Report rate in Active mode */
00124 #define FT3X67_PERIODACTIVE_REG             0x88U
00125 
00126 /* Report rate in Monitor mode */
00127 #define FT3X67_PERIODMONITOR_REG            0x89U
00128 
00129 /* High 8-bit of LIB Version info */
00130 #define FT3X67_LIB_VER_H_REG                0xA1U
00131 
00132 /* Low 8-bit of LIB Version info */
00133 #define FT3X67_LIB_VER_L_REG                0xA2U
00134 
00135 /* Chip Selecting */
00136 #define FT3X67_CIPHER_REG                   0xA3U
00137 
00138 /* Interrupt mode register (used when in interrupt mode) */
00139 #define FT3X67_GMODE_REG                    0xA4U
00140 /* Possible values of FT3X67_GMODE_REG */
00141 #define FT3X67_G_MODE_INTERRUPT_POLLING     0x00U
00142 #define FT3X67_G_MODE_INTERRUPT_TRIGGER     0x01U
00143 
00144 /* Current power mode */
00145 #define FT3X67_PWR_MODE_REG                 0xA5U
00146 
00147 /* Firmware version */
00148 #define FT3X67_FIRMID_REG                   0xA6U
00149 
00150 /* Chip identification register */
00151 #define FT3X67_CHIP_ID_REG                  0xA8U
00152 /* Possible values of FT3X67_CHIP_ID_REG */
00153 #define FT3X67_ID_VALUE                     0x11U
00154 
00155 /* Release code version */
00156 #define FT3X67_RELEASE_CODE_ID_REG          0xAFU
00157 
00158 /* Current operating mode register */
00159 #define FT3X67_STATE_REG                    0xBCU
00160 /* Possible values of FT3X67_STATE_REG */
00161 #define FT3X67_STATE_INFO_MODE              0x00U
00162 #define FT3X67_STATE_NORMAL_MODE            0x01U
00163 #define FT3X67_STATE_FACTORY_MODE           0x03U
00164 #define FT3X67_STATE_AUTO_CALIB_MODE        0x04U
00165 
00166 /* Gesture enable register */
00167 #define FT3X67_GESTURE_ENABLE_REG           0xD0U
00168 /* Possible values of FT3X67_GESTURE_ENABLE_REG */
00169 #define FT3X67_GESTURE_DISABLE              0x00U
00170 #define FT3X67_GESTURE_ENABLE               0x01U
00171 
00172 /* Gesture flag register */
00173 #define FT3X67_GESTURE_FLAG_REG             0xD1U
00174 /* Possible values of FT3X67_GESTURE_FLAG_REG can be any combination of following values */
00175 #define FT3X67_GEST_LINE_RIGHT_TO_LEFT_ENABLE  0x01U
00176 #define FT3X67_GEST_LINE_LEFT_TO_RIGHT_ENABLE  0x02U
00177 #define FT3X67_GEST_LINE_DOWN_TO_UP_ENABLE     0x04U
00178 #define FT3X67_GEST_LINE_UP_TO_DOWN_ENABLE     0x08U
00179 #define FT3X67_GEST_DOUBLE_TAP_ENABLE          0x10U
00180 #define FT3X67_GEST_ALL_FLAGS_ENABLE           0x1FU
00181 #define FT3X67_GEST_ALL_FLAGS_DISABLE          0x00U
00182 
00183 /* Gesture ID register */
00184 #define FT3X67_GEST_ID_REG                  0xD3U
00185 /* Possible values of FT3X67_GEST_ID_REG */
00186 #define FT3X67_GEST_ID_NO_GESTURE           0x00U
00187 #define FT3X67_GEST_ID_MOVE_UP              0x22U
00188 #define FT3X67_GEST_ID_MOVE_RIGHT           0x21U
00189 #define FT3X67_GEST_ID_MOVE_DOWN            0x23U
00190 #define FT3X67_GEST_ID_MOVE_LEFT            0x20U
00191 #define FT3X67_GEST_ID_DOUBLE_CLICK         0x24U
00192 
00193 /**
00194   * @}
00195   */
00196 
00197 /* Exported macro ------------------------------------------------------------*/
00198 /* Exported functions --------------------------------------------------------*/
00199 
00200 /** @defgroup FT3X67_Exported_Functions
00201   * @{
00202   */
00203 
00204 void     ft3x67_Init(uint16_t DeviceAddr);
00205 void     ft3x67_Reset(uint16_t DeviceAddr);
00206 uint16_t ft3x67_ReadID(uint16_t DeviceAddr);
00207 void     ft3x67_TS_Start(uint16_t DeviceAddr);
00208 uint8_t  ft3x67_TS_DetectTouch(uint16_t DeviceAddr);
00209 void     ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
00210 void     ft3x67_TS_EnableIT(uint16_t DeviceAddr);
00211 void     ft3x67_TS_DisableIT(uint16_t DeviceAddr);
00212 uint8_t  ft3x67_TS_ITStatus (uint16_t DeviceAddr);
00213 void     ft3x67_TS_ClearIT (uint16_t DeviceAddr);
00214 void     ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
00215 void     ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
00216 void     ft3x67_TS_GetTouchInfo(uint16_t   DeviceAddr,
00217                                 uint32_t   touchIdx,
00218                                 uint32_t * pWeight,
00219                                 uint32_t * pArea,
00220                                 uint32_t * pEvent);
00221 
00222 /**
00223   * @}
00224   */
00225 
00226 /* Imported TS IO functions --------------------------------------------------------*/
00227 
00228 /** @defgroup FT3X67_Imported_Functions
00229   * @{
00230   */
00231 
00232 /* TouchScreen (TS) external IO functions */
00233 extern void     TS_IO_Init(void);
00234 extern void     TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
00235 extern uint8_t  TS_IO_Read(uint8_t Addr, uint8_t Reg);
00236 extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
00237 extern void     TS_IO_Delay(uint32_t Delay);
00238 
00239 /**
00240   * @}
00241   */
00242 
00243 /* Imported global variables --------------------------------------------------------*/
00244 
00245 /** @defgroup FT3X67_Imported_Globals
00246   * @{
00247   */
00248 
00249 /* Touch screen driver structure */
00250 extern TS_DrvTypeDef ft3x67_ts_drv;
00251 
00252 /**
00253   * @}
00254   */
00255 
00256 /**
00257   * @}
00258   */
00259 
00260 /**
00261   * @}
00262   */
00263 
00264 /**
00265   * @}
00266   */
00267 
00268 #ifdef __cplusplus
00269 }
00270 #endif
00271 #endif /* __FT3X67_H */
00272 
00273 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/