ST / BSP_DISCO_L496AG

Dependents:   DISCO_L496AG-LCD-prova_1 DISCO_L496AG-LCD-prova_2 DISCO_L496AG-LCD-demo DISCO_L496AG-SRAM-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ft6x06.h Source File

ft6x06.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    ft6x06.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains all the functions prototypes for the
00006   *          ft6x06.c IO expander driver.
00007   ******************************************************************************
00008   * @attention
00009   *
00010   * <h2><center>&copy; Copyright (c) 2016 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 __FT6X06_H
00023 #define __FT6X06_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /* Set Multi-touch as non supported */
00030 #ifndef TS_MULTI_TOUCH_SUPPORTED
00031   #define TS_MULTI_TOUCH_SUPPORTED 0
00032 #endif
00033 
00034 /* Set Auto-calibration as non supported */  
00035 #ifndef TS_AUTO_CALIBRATION_SUPPORTED
00036   #define TS_AUTO_CALIBRATION_SUPPORTED 0
00037 #endif
00038   
00039 /* Includes ------------------------------------------------------------------*/
00040 #include "../Common/ts.h"
00041 
00042 /* Macros --------------------------------------------------------------------*/
00043 
00044 /** @typedef ft6x06_handle_TypeDef
00045  *  ft6x06 Handle definition.
00046  */
00047 typedef struct
00048 {
00049   uint8_t i2cInitialized;
00050 
00051   /* field holding the current number of simultaneous active touches */
00052   uint8_t currActiveTouchNb;
00053 
00054   /* field holding the touch index currently managed */
00055   uint8_t currActiveTouchIdx;
00056 
00057 } ft6x06_handle_TypeDef;
00058 
00059   /** @addtogroup BSP
00060    * @{
00061    */
00062 
00063   /** @addtogroup Component
00064    * @{
00065    */
00066 
00067   /** @defgroup FT6X06
00068    * @{
00069    */
00070 
00071   /* Exported types ------------------------------------------------------------*/
00072 
00073   /** @defgroup FT6X06_Exported_Types
00074    * @{
00075    */
00076 
00077   /* Exported constants --------------------------------------------------------*/
00078 
00079   /** @defgroup FT6X06_Exported_Constants
00080    * @{
00081    */
00082 
00083   /* Maximum border values of the touchscreen pad */
00084 #define  FT_6206_MAX_WIDTH              ((uint16_t)800)     /* Touchscreen pad max width   */
00085 #define  FT_6206_MAX_HEIGHT             ((uint16_t)480)     /* Touchscreen pad max height  */
00086 
00087   /* Touchscreen pad max width and height values for FT6x36 Touch*/
00088 #define  FT_6206_MAX_WIDTH_HEIGHT       ((uint16_t)240)     
00089 
00090   /* Possible values of driver functions return status */
00091 #define FT6206_STATUS_OK                0
00092 #define FT6206_STATUS_NOT_OK            1
00093 
00094   /* Possible values of global variable 'TS_I2C_Initialized' */
00095 #define FT6206_I2C_NOT_INITIALIZED      0
00096 #define FT6206_I2C_INITIALIZED          1
00097 
00098   /* Max detectable simultaneous touches */
00099 #define FT6206_MAX_DETECTABLE_TOUCH     2
00100 
00101   /**
00102    * @brief : Definitions for FT6206 I2C register addresses on 8 bit
00103    **/
00104 
00105   /* Current mode register of the FT6206 (R/W) */
00106 #define FT6206_DEV_MODE_REG             0x00
00107 
00108   /* Possible values of FT6206_DEV_MODE_REG */
00109 #define FT6206_DEV_MODE_WORKING         0x00
00110 #define FT6206_DEV_MODE_FACTORY         0x04
00111 
00112 #define FT6206_DEV_MODE_MASK            0x7
00113 #define FT6206_DEV_MODE_SHIFT           4
00114 
00115   /* Gesture ID register */
00116 #define FT6206_GEST_ID_REG              0x01
00117 
00118   /* Possible values of FT6206_GEST_ID_REG */
00119 #define FT6206_GEST_ID_NO_GESTURE       0x00
00120 #define FT6206_GEST_ID_MOVE_UP          0x10
00121 #define FT6206_GEST_ID_MOVE_RIGHT       0x14
00122 #define FT6206_GEST_ID_MOVE_DOWN        0x18
00123 #define FT6206_GEST_ID_MOVE_LEFT        0x1C
00124 #define FT6206_GEST_ID_ZOOM_IN          0x48
00125 #define FT6206_GEST_ID_ZOOM_OUT         0x49
00126 
00127   /* Touch Data Status register : gives number of active touch points (0..2) */
00128 #define FT6206_TD_STAT_REG              0x02
00129 
00130   /* Values related to FT6206_TD_STAT_REG */
00131 #define FT6206_TD_STAT_MASK             0x0F
00132 #define FT6206_TD_STAT_SHIFT            0x00
00133 
00134   /* Values Pn_XH and Pn_YH related */
00135 #define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00
00136 #define FT6206_TOUCH_EVT_FLAG_LIFT_UP    0x01
00137 #define FT6206_TOUCH_EVT_FLAG_CONTACT    0x02
00138 #define FT6206_TOUCH_EVT_FLAG_NO_EVENT   0x03
00139 
00140 #define FT6206_TOUCH_EVT_FLAG_SHIFT     6
00141 #define FT6206_TOUCH_EVT_FLAG_MASK      (3 << FT6206_TOUCH_EVT_FLAG_SHIFT)
00142 
00143 #define FT6206_MSB_MASK                 0x0F
00144 #define FT6206_MSB_SHIFT                0
00145 
00146   /* Values Pn_XL and Pn_YL related */
00147 #define FT6206_LSB_MASK                 0xFF
00148 #define FT6206_LSB_SHIFT                0
00149 
00150 #define FT6206_P1_XH_REG                0x03
00151 #define FT6206_P1_XL_REG                0x04
00152 #define FT6206_P1_YH_REG                0x05
00153 #define FT6206_P1_YL_REG                0x06
00154 
00155   /* Touch Pressure register value (R) */
00156 #define FT6206_P1_WEIGHT_REG            0x07
00157 
00158   /* Values Pn_WEIGHT related  */
00159 #define FT6206_TOUCH_WEIGHT_MASK        0xFF
00160 #define FT6206_TOUCH_WEIGHT_SHIFT       0
00161 
00162   /* Touch area register */
00163 #define FT6206_P1_MISC_REG              0x08
00164 
00165   /* Values related to FT6206_Pn_MISC_REG */
00166 #define FT6206_TOUCH_AREA_MASK         (0x04 << 4)
00167 #define FT6206_TOUCH_AREA_SHIFT        0x04
00168 
00169 #define FT6206_P2_XH_REG               0x09
00170 #define FT6206_P2_XL_REG               0x0A
00171 #define FT6206_P2_YH_REG               0x0B
00172 #define FT6206_P2_YL_REG               0x0C
00173 #define FT6206_P2_WEIGHT_REG           0x0D
00174 #define FT6206_P2_MISC_REG             0x0E
00175 
00176   /* Threshold for touch detection */
00177 #define FT6206_TH_GROUP_REG            0x80
00178 
00179   /* Values FT6206_TH_GROUP_REG : threshold related  */
00180 #define FT6206_THRESHOLD_MASK          0xFF
00181 #define FT6206_THRESHOLD_SHIFT         0
00182 
00183   /* Filter function coefficients */
00184 #define FT6206_TH_DIFF_REG             0x85
00185 
00186   /* Control register */
00187 #define FT6206_CTRL_REG                0x86
00188 
00189   /* Values related to FT6206_CTRL_REG */
00190 
00191   /* Will keep the Active mode when there is no touching */
00192 #define FT6206_CTRL_KEEP_ACTIVE_MODE    0x00
00193 
00194   /* Switching from Active mode to Monitor mode automatically when there is no touching */
00195 #define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE  0x01
00196 
00197   /* The time period of switching from Active mode to Monitor mode when there is no touching */
00198 #define FT6206_TIMEENTERMONITOR_REG     0x87
00199 
00200   /* Report rate in Active mode */
00201 #define FT6206_PERIODACTIVE_REG         0x88
00202 
00203   /* Report rate in Monitor mode */
00204 #define FT6206_PERIODMONITOR_REG        0x89
00205 
00206   /* The value of the minimum allowed angle while Rotating gesture mode */
00207 #define FT6206_RADIAN_VALUE_REG         0x91
00208 
00209   /* Maximum offset while Moving Left and Moving Right gesture */
00210 #define FT6206_OFFSET_LEFT_RIGHT_REG    0x92
00211 
00212   /* Maximum offset while Moving Up and Moving Down gesture */
00213 #define FT6206_OFFSET_UP_DOWN_REG       0x93
00214 
00215   /* Minimum distance while Moving Left and Moving Right gesture */
00216 #define FT6206_DISTANCE_LEFT_RIGHT_REG  0x94
00217 
00218   /* Minimum distance while Moving Up and Moving Down gesture */
00219 #define FT6206_DISTANCE_UP_DOWN_REG     0x95
00220 
00221   /* Maximum distance while Zoom In and Zoom Out gesture */
00222 #define FT6206_DISTANCE_ZOOM_REG        0x96
00223 
00224   /* High 8-bit of LIB Version info */
00225 #define FT6206_LIB_VER_H_REG            0xA1
00226 
00227   /* Low 8-bit of LIB Version info */
00228 #define FT6206_LIB_VER_L_REG            0xA2
00229 
00230   /* Chip Selecting */
00231 #define FT6206_CIPHER_REG               0xA3
00232 
00233   /* Interrupt mode register (used when in interrupt mode) */
00234 #define FT6206_GMODE_REG                0xA4
00235 
00236 #define FT6206_G_MODE_INTERRUPT_MASK    0x03
00237 #define FT6206_G_MODE_INTERRUPT_SHIFT   0x00
00238 
00239   /* Possible values of FT6206_GMODE_REG */
00240 #define FT6206_G_MODE_INTERRUPT_POLLING 0x00
00241 #define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01
00242 
00243   /* Current power mode the FT6206 system is in (R) */
00244 #define FT6206_PWR_MODE_REG             0xA5
00245 
00246   /* FT6206 firmware version */
00247 #define FT6206_FIRMID_REG               0xA6
00248 
00249   /* FT6206 Chip identification register */
00250 #define FT6206_CHIP_ID_REG              0xA8
00251 
00252   /*  Possible values of FT6206_CHIP_ID_REG */
00253 #define FT6206_ID_VALUE                 0x11
00254 #define FT6x36_ID_VALUE                 0xCD
00255 
00256   /* Release code version */
00257 #define FT6206_RELEASE_CODE_ID_REG      0xAF
00258 
00259   /* Current operating mode the FT6206 system is in (R) */
00260 #define FT6206_STATE_REG                0xBC
00261 
00262   /**
00263    * @}
00264    */
00265 
00266   /* Exported macro ------------------------------------------------------------*/
00267 
00268   /** @defgroup ft6x06_Exported_Macros
00269    * @{
00270    */
00271 
00272   /* Exported functions --------------------------------------------------------*/
00273 
00274   /** @defgroup ft6x06_Exported_Functions
00275    * @{
00276    */
00277 
00278   /**
00279    * @brief ft6x06 Control functions
00280    */
00281 
00282 
00283 /**
00284  * @brief  Initialize the ft6x06 communication bus
00285  *         from MCU to FT6206 : ie I2C channel initialization (if required).
00286  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
00287  * @retval None
00288  */
00289 void ft6x06_Init(uint16_t DeviceAddr);
00290 
00291 /**
00292  * @brief  Software Reset the ft6x06.
00293  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
00294  * @retval None
00295  */
00296 void ft6x06_Reset(uint16_t DeviceAddr);
00297 
00298 /**
00299  * @brief  Read the ft6x06 device ID, pre intitalize I2C in case of need to be
00300  *         able to read the FT6206 device ID, and verify this is a FT6206.
00301  * @param  DeviceAddr: I2C FT6x06 Slave address.
00302  * @retval The Device ID (two bytes).
00303  */
00304 uint16_t ft6x06_ReadID(uint16_t DeviceAddr);
00305 
00306 /**
00307  * @brief  Configures the touch Screen IC device to start detecting touches
00308  * @param  DeviceAddr: Device address on communication Bus (I2C slave address).
00309  * @retval None.
00310  */
00311 void ft6x06_TS_Start(uint16_t DeviceAddr);
00312 
00313 /**
00314  * @brief  Return if there is touches detected or not.
00315  *         Try to detect new touches and forget the old ones (reset internal global
00316  *         variables).
00317  * @param  DeviceAddr: Device address on communication Bus.
00318  * @retval : Number of active touches detected (can be 0, 1 or 2).
00319  */
00320 uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr);
00321 
00322 /**
00323  * @brief  Get the touch screen X and Y positions values
00324  *         Manage multi touch thanks to touch Index global
00325  *         variable 'ft6x06_handle.currActiveTouchIdx'.
00326  * @param  DeviceAddr: Device address on communication Bus.
00327  * @param  X: Pointer to X position value
00328  * @param  Y: Pointer to Y position value
00329  * @retval None.
00330  */
00331 void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
00332 
00333 /**
00334  * @brief  Configure the FT6206 device to generate IT on given INT pin
00335  *         connected to MCU as EXTI.
00336  * @param  DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
00337  * @retval None
00338  */
00339 void ft6x06_TS_EnableIT(uint16_t DeviceAddr);
00340 
00341 /**
00342  * @brief  Configure the FT6206 device to stop generating IT on the given INT pin
00343  *         connected to MCU as EXTI.
00344  * @param  DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
00345  * @retval None
00346  */
00347 void ft6x06_TS_DisableIT(uint16_t DeviceAddr);
00348 
00349 /**
00350  * @brief  Get IT status from FT6206 interrupt status registers
00351  *         Should be called Following an EXTI coming to the MCU to know the detailed
00352  *         reason of the interrupt.
00353  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
00354  * @retval TS interrupts status
00355  */
00356 uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr);
00357 
00358 /**
00359  * @brief  Clear IT status in FT6206 interrupt status clear registers
00360  *         Should be called Following an EXTI coming to the MCU.
00361  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
00362  * @retval TS interrupts status
00363  */
00364 void ft6x06_TS_ClearIT (uint16_t DeviceAddr);
00365 
00366 /**** NEW FEATURES enabled when Multi-touch support is enabled ****/
00367 
00368 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
00369 
00370 /**
00371  * @brief  Get the last touch gesture identification (zoom, move up/down...).
00372  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
00373  * @param  pGestureId : Pointer to get last touch gesture Identification.
00374  * @retval None.
00375  */
00376 void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
00377 
00378 /**
00379  * @brief  Get the touch detailed informations on touch number 'touchIdx' (0..1)
00380  *         This touch detailed information contains :
00381  *         - weight that was applied to this touch
00382  *         - sub-area of the touch in the touch panel
00383  *         - event of linked to the touch (press down, lift up, ...)
00384  * @param  DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
00385  * @param  touchIdx : Passed index of the touch (0..1) on which we want to get the
00386  *                    detailed information.
00387  * @param  pWeight : Pointer to to get the weight information of 'touchIdx'.
00388  * @param  pArea   : Pointer to to get the sub-area information of 'touchIdx'.
00389  * @param  pEvent  : Pointer to to get the event information of 'touchIdx'.
00390 
00391  * @retval None.
00392  */
00393 void ft6x06_TS_GetTouchInfo(uint16_t   DeviceAddr,
00394                             uint32_t   touchIdx,
00395                             uint32_t * pWeight,
00396                             uint32_t * pArea,
00397                             uint32_t * pEvent);
00398 
00399 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
00400 
00401 /* Imported TS IO functions --------------------------------------------------------*/
00402 
00403 /** @defgroup ft6x06_Imported_Functions
00404  * @{
00405  */
00406 
00407 /* TouchScreen (TS) external IO functions */
00408 extern void     TS_IO_Init(void);
00409 extern void     TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
00410 extern uint8_t  TS_IO_Read(uint8_t Addr, uint8_t Reg);
00411 extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
00412 extern void     TS_IO_Delay(uint32_t Delay);
00413 
00414   /**
00415    * @}
00416    */
00417 
00418   /* Imported global variables --------------------------------------------------------*/
00419 
00420   /** @defgroup ft6x06_Imported_Globals
00421    * @{
00422    */
00423 
00424 
00425 /* Touch screen driver structure */
00426 extern TS_DrvTypeDef ft6x06_ts_drv;
00427 
00428   /**
00429    * @}
00430    */
00431 
00432 #ifdef __cplusplus
00433 }
00434 #endif
00435 #endif /* __FT6X06_H */
00436 
00437 
00438 /**
00439  * @}
00440  */
00441 
00442 /**
00443  * @}
00444  */
00445 
00446 /**
00447  * @}
00448  */
00449 
00450 /**
00451  * @}
00452  */
00453 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/