Clone

Dependents:   SignalProcessLab DigitalSignalAlgorithm_Lab DigitalSignal_Lab

Committer:
ngtkien
Date:
Mon Aug 26 16:33:09 2019 +0000
Revision:
0:fc80425b677a
Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ngtkien 0:fc80425b677a 1 /**
ngtkien 0:fc80425b677a 2 ******************************************************************************
ngtkien 0:fc80425b677a 3 * @file ft5336.h
ngtkien 0:fc80425b677a 4 * @author MCD Application Team
ngtkien 0:fc80425b677a 5 * @version V1.0.0
ngtkien 0:fc80425b677a 6 * @date 25-June-2015
ngtkien 0:fc80425b677a 7 * @brief This file contains all the functions prototypes for the
ngtkien 0:fc80425b677a 8 * ft5336.c Touch screen driver.
ngtkien 0:fc80425b677a 9 ******************************************************************************
ngtkien 0:fc80425b677a 10 * @attention
ngtkien 0:fc80425b677a 11 *
ngtkien 0:fc80425b677a 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
ngtkien 0:fc80425b677a 13 *
ngtkien 0:fc80425b677a 14 * Redistribution and use in source and binary forms, with or without modification,
ngtkien 0:fc80425b677a 15 * are permitted provided that the following conditions are met:
ngtkien 0:fc80425b677a 16 * 1. Redistributions of source code must retain the above copyright notice,
ngtkien 0:fc80425b677a 17 * this list of conditions and the following disclaimer.
ngtkien 0:fc80425b677a 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
ngtkien 0:fc80425b677a 19 * this list of conditions and the following disclaimer in the documentation
ngtkien 0:fc80425b677a 20 * and/or other materials provided with the distribution.
ngtkien 0:fc80425b677a 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ngtkien 0:fc80425b677a 22 * may be used to endorse or promote products derived from this software
ngtkien 0:fc80425b677a 23 * without specific prior written permission.
ngtkien 0:fc80425b677a 24 *
ngtkien 0:fc80425b677a 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ngtkien 0:fc80425b677a 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ngtkien 0:fc80425b677a 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ngtkien 0:fc80425b677a 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ngtkien 0:fc80425b677a 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ngtkien 0:fc80425b677a 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ngtkien 0:fc80425b677a 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ngtkien 0:fc80425b677a 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ngtkien 0:fc80425b677a 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ngtkien 0:fc80425b677a 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ngtkien 0:fc80425b677a 35 *
ngtkien 0:fc80425b677a 36 ******************************************************************************
ngtkien 0:fc80425b677a 37 */
ngtkien 0:fc80425b677a 38
ngtkien 0:fc80425b677a 39 /* Define to prevent recursive inclusion -------------------------------------*/
ngtkien 0:fc80425b677a 40 #ifndef __FT5336_H
ngtkien 0:fc80425b677a 41 #define __FT5336_H
ngtkien 0:fc80425b677a 42
ngtkien 0:fc80425b677a 43 #ifdef __cplusplus
ngtkien 0:fc80425b677a 44 extern "C" {
ngtkien 0:fc80425b677a 45 #endif
ngtkien 0:fc80425b677a 46
ngtkien 0:fc80425b677a 47 /* Set Multi-touch as supported */
ngtkien 0:fc80425b677a 48 #if !defined(TS_MONO_TOUCH_SUPPORTED)
ngtkien 0:fc80425b677a 49 #define TS_MULTI_TOUCH_SUPPORTED 1
ngtkien 0:fc80425b677a 50 #endif /* TS_MONO_TOUCH_SUPPORTED */
ngtkien 0:fc80425b677a 51
ngtkien 0:fc80425b677a 52 /* Includes ------------------------------------------------------------------*/
ngtkien 0:fc80425b677a 53 #include "../Common/ts.h"
ngtkien 0:fc80425b677a 54
ngtkien 0:fc80425b677a 55 /* Macros --------------------------------------------------------------------*/
ngtkien 0:fc80425b677a 56
ngtkien 0:fc80425b677a 57 #if defined(FT5336_ENABLE_ASSERT)
ngtkien 0:fc80425b677a 58 /* Assert activated */
ngtkien 0:fc80425b677a 59 #define FT5336_ASSERT(__condition__) do { if(__condition__) \
ngtkien 0:fc80425b677a 60 { \
ngtkien 0:fc80425b677a 61 while(1); \
ngtkien 0:fc80425b677a 62 } \
ngtkien 0:fc80425b677a 63 }while(0)
ngtkien 0:fc80425b677a 64 #else
ngtkien 0:fc80425b677a 65 /* Assert not activated : macro has no effect */
ngtkien 0:fc80425b677a 66 #define FT5336_ASSERT(__condition__) do { if(__condition__) \
ngtkien 0:fc80425b677a 67 { \
ngtkien 0:fc80425b677a 68 ; \
ngtkien 0:fc80425b677a 69 } \
ngtkien 0:fc80425b677a 70 }while(0)
ngtkien 0:fc80425b677a 71 #endif /* FT5336_ENABLE_ASSERT == 1 */
ngtkien 0:fc80425b677a 72
ngtkien 0:fc80425b677a 73 /** @typedef ft5336_handle_TypeDef
ngtkien 0:fc80425b677a 74 * ft5336 Handle definition.
ngtkien 0:fc80425b677a 75 */
ngtkien 0:fc80425b677a 76 typedef struct
ngtkien 0:fc80425b677a 77 {
ngtkien 0:fc80425b677a 78 uint8_t i2cInitialized;
ngtkien 0:fc80425b677a 79
ngtkien 0:fc80425b677a 80 /* field holding the current number of simultaneous active touches */
ngtkien 0:fc80425b677a 81 uint8_t currActiveTouchNb;
ngtkien 0:fc80425b677a 82
ngtkien 0:fc80425b677a 83 /* field holding the touch index currently managed */
ngtkien 0:fc80425b677a 84 uint8_t currActiveTouchIdx;
ngtkien 0:fc80425b677a 85
ngtkien 0:fc80425b677a 86 } ft5336_handle_TypeDef;
ngtkien 0:fc80425b677a 87
ngtkien 0:fc80425b677a 88 /** @addtogroup BSP
ngtkien 0:fc80425b677a 89 * @{
ngtkien 0:fc80425b677a 90 */
ngtkien 0:fc80425b677a 91
ngtkien 0:fc80425b677a 92 /** @addtogroup Component
ngtkien 0:fc80425b677a 93 * @{
ngtkien 0:fc80425b677a 94 */
ngtkien 0:fc80425b677a 95
ngtkien 0:fc80425b677a 96 /** @defgroup FT5336
ngtkien 0:fc80425b677a 97 * @{
ngtkien 0:fc80425b677a 98 */
ngtkien 0:fc80425b677a 99
ngtkien 0:fc80425b677a 100 /* Exported types ------------------------------------------------------------*/
ngtkien 0:fc80425b677a 101
ngtkien 0:fc80425b677a 102 /** @defgroup FT5336_Exported_Types
ngtkien 0:fc80425b677a 103 * @{
ngtkien 0:fc80425b677a 104 */
ngtkien 0:fc80425b677a 105
ngtkien 0:fc80425b677a 106 /* Exported constants --------------------------------------------------------*/
ngtkien 0:fc80425b677a 107
ngtkien 0:fc80425b677a 108 /** @defgroup FT5336_Exported_Constants
ngtkien 0:fc80425b677a 109 * @{
ngtkien 0:fc80425b677a 110 */
ngtkien 0:fc80425b677a 111
ngtkien 0:fc80425b677a 112 /* I2C Slave address of touchscreen FocalTech FT5336 */
ngtkien 0:fc80425b677a 113 #define FT5336_I2C_SLAVE_ADDRESS ((uint8_t)0x70)
ngtkien 0:fc80425b677a 114
ngtkien 0:fc80425b677a 115 /* Maximum border values of the touchscreen pad */
ngtkien 0:fc80425b677a 116 #define FT5336_MAX_WIDTH ((uint16_t)480) /* Touchscreen pad max width */
ngtkien 0:fc80425b677a 117 #define FT5336_MAX_HEIGHT ((uint16_t)272) /* Touchscreen pad max height */
ngtkien 0:fc80425b677a 118
ngtkien 0:fc80425b677a 119 /* Possible values of driver functions return status */
ngtkien 0:fc80425b677a 120 #define FT5336_STATUS_OK ((uint8_t)0x00)
ngtkien 0:fc80425b677a 121 #define FT5336_STATUS_NOT_OK ((uint8_t)0x01)
ngtkien 0:fc80425b677a 122
ngtkien 0:fc80425b677a 123 /* Possible values of global variable 'TS_I2C_Initialized' */
ngtkien 0:fc80425b677a 124 #define FT5336_I2C_NOT_INITIALIZED ((uint8_t)0x00)
ngtkien 0:fc80425b677a 125 #define FT5336_I2C_INITIALIZED ((uint8_t)0x01)
ngtkien 0:fc80425b677a 126
ngtkien 0:fc80425b677a 127 /* Max detectable simultaneous touches */
ngtkien 0:fc80425b677a 128 #define FT5336_MAX_DETECTABLE_TOUCH ((uint8_t)0x05)
ngtkien 0:fc80425b677a 129
ngtkien 0:fc80425b677a 130 /**
ngtkien 0:fc80425b677a 131 * @brief : Definitions for FT5336 I2C register addresses on 8 bit
ngtkien 0:fc80425b677a 132 **/
ngtkien 0:fc80425b677a 133
ngtkien 0:fc80425b677a 134 /* Current mode register of the FT5336 (R/W) */
ngtkien 0:fc80425b677a 135 #define FT5336_DEV_MODE_REG ((uint8_t)0x00)
ngtkien 0:fc80425b677a 136
ngtkien 0:fc80425b677a 137 /* Possible values of FT5336_DEV_MODE_REG */
ngtkien 0:fc80425b677a 138 #define FT5336_DEV_MODE_WORKING ((uint8_t)0x00)
ngtkien 0:fc80425b677a 139 #define FT5336_DEV_MODE_FACTORY ((uint8_t)0x04)
ngtkien 0:fc80425b677a 140
ngtkien 0:fc80425b677a 141 #define FT5336_DEV_MODE_MASK ((uint8_t)0x07)
ngtkien 0:fc80425b677a 142 #define FT5336_DEV_MODE_SHIFT ((uint8_t)0x04)
ngtkien 0:fc80425b677a 143
ngtkien 0:fc80425b677a 144 /* Gesture ID register */
ngtkien 0:fc80425b677a 145 #define FT5336_GEST_ID_REG ((uint8_t)0x01)
ngtkien 0:fc80425b677a 146
ngtkien 0:fc80425b677a 147 /* Possible values of FT5336_GEST_ID_REG */
ngtkien 0:fc80425b677a 148 #define FT5336_GEST_ID_NO_GESTURE ((uint8_t)0x00)
ngtkien 0:fc80425b677a 149 #define FT5336_GEST_ID_MOVE_UP ((uint8_t)0x10)
ngtkien 0:fc80425b677a 150 #define FT5336_GEST_ID_MOVE_RIGHT ((uint8_t)0x14)
ngtkien 0:fc80425b677a 151 #define FT5336_GEST_ID_MOVE_DOWN ((uint8_t)0x18)
ngtkien 0:fc80425b677a 152 #define FT5336_GEST_ID_MOVE_LEFT ((uint8_t)0x1C)
ngtkien 0:fc80425b677a 153 #define FT5336_GEST_ID_SINGLE_CLICK ((uint8_t)0x20)
ngtkien 0:fc80425b677a 154 #define FT5336_GEST_ID_DOUBLE_CLICK ((uint8_t)0x22)
ngtkien 0:fc80425b677a 155 #define FT5336_GEST_ID_ROTATE_CLOCKWISE ((uint8_t)0x28)
ngtkien 0:fc80425b677a 156 #define FT5336_GEST_ID_ROTATE_C_CLOCKWISE ((uint8_t)0x29)
ngtkien 0:fc80425b677a 157 #define FT5336_GEST_ID_ZOOM_IN ((uint8_t)0x40)
ngtkien 0:fc80425b677a 158 #define FT5336_GEST_ID_ZOOM_OUT ((uint8_t)0x49)
ngtkien 0:fc80425b677a 159
ngtkien 0:fc80425b677a 160 /* Touch Data Status register : gives number of active touch points (0..5) */
ngtkien 0:fc80425b677a 161 #define FT5336_TD_STAT_REG ((uint8_t)0x02)
ngtkien 0:fc80425b677a 162
ngtkien 0:fc80425b677a 163 /* Values related to FT5336_TD_STAT_REG */
ngtkien 0:fc80425b677a 164 #define FT5336_TD_STAT_MASK ((uint8_t)0x0F)
ngtkien 0:fc80425b677a 165 #define FT5336_TD_STAT_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 166
ngtkien 0:fc80425b677a 167 /* Values Pn_XH and Pn_YH related */
ngtkien 0:fc80425b677a 168 #define FT5336_TOUCH_EVT_FLAG_PRESS_DOWN ((uint8_t)0x00)
ngtkien 0:fc80425b677a 169 #define FT5336_TOUCH_EVT_FLAG_LIFT_UP ((uint8_t)0x01)
ngtkien 0:fc80425b677a 170 #define FT5336_TOUCH_EVT_FLAG_CONTACT ((uint8_t)0x02)
ngtkien 0:fc80425b677a 171 #define FT5336_TOUCH_EVT_FLAG_NO_EVENT ((uint8_t)0x03)
ngtkien 0:fc80425b677a 172
ngtkien 0:fc80425b677a 173 #define FT5336_TOUCH_EVT_FLAG_SHIFT ((uint8_t)0x06)
ngtkien 0:fc80425b677a 174 #define FT5336_TOUCH_EVT_FLAG_MASK ((uint8_t)(3 << FT5336_TOUCH_EVT_FLAG_SHIFT))
ngtkien 0:fc80425b677a 175
ngtkien 0:fc80425b677a 176 #define FT5336_TOUCH_POS_MSB_MASK ((uint8_t)0x0F)
ngtkien 0:fc80425b677a 177 #define FT5336_TOUCH_POS_MSB_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 178
ngtkien 0:fc80425b677a 179 /* Values Pn_XL and Pn_YL related */
ngtkien 0:fc80425b677a 180 #define FT5336_TOUCH_POS_LSB_MASK ((uint8_t)0xFF)
ngtkien 0:fc80425b677a 181 #define FT5336_TOUCH_POS_LSB_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 182
ngtkien 0:fc80425b677a 183 #define FT5336_P1_XH_REG ((uint8_t)0x03)
ngtkien 0:fc80425b677a 184 #define FT5336_P1_XL_REG ((uint8_t)0x04)
ngtkien 0:fc80425b677a 185 #define FT5336_P1_YH_REG ((uint8_t)0x05)
ngtkien 0:fc80425b677a 186 #define FT5336_P1_YL_REG ((uint8_t)0x06)
ngtkien 0:fc80425b677a 187
ngtkien 0:fc80425b677a 188 /* Touch Pressure register value (R) */
ngtkien 0:fc80425b677a 189 #define FT5336_P1_WEIGHT_REG ((uint8_t)0x07)
ngtkien 0:fc80425b677a 190
ngtkien 0:fc80425b677a 191 /* Values Pn_WEIGHT related */
ngtkien 0:fc80425b677a 192 #define FT5336_TOUCH_WEIGHT_MASK ((uint8_t)0xFF)
ngtkien 0:fc80425b677a 193 #define FT5336_TOUCH_WEIGHT_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 194
ngtkien 0:fc80425b677a 195 /* Touch area register */
ngtkien 0:fc80425b677a 196 #define FT5336_P1_MISC_REG ((uint8_t)0x08)
ngtkien 0:fc80425b677a 197
ngtkien 0:fc80425b677a 198 /* Values related to FT5336_Pn_MISC_REG */
ngtkien 0:fc80425b677a 199 #define FT5336_TOUCH_AREA_MASK ((uint8_t)(0x04 << 4))
ngtkien 0:fc80425b677a 200 #define FT5336_TOUCH_AREA_SHIFT ((uint8_t)0x04)
ngtkien 0:fc80425b677a 201
ngtkien 0:fc80425b677a 202 #define FT5336_P2_XH_REG ((uint8_t)0x09)
ngtkien 0:fc80425b677a 203 #define FT5336_P2_XL_REG ((uint8_t)0x0A)
ngtkien 0:fc80425b677a 204 #define FT5336_P2_YH_REG ((uint8_t)0x0B)
ngtkien 0:fc80425b677a 205 #define FT5336_P2_YL_REG ((uint8_t)0x0C)
ngtkien 0:fc80425b677a 206 #define FT5336_P2_WEIGHT_REG ((uint8_t)0x0D)
ngtkien 0:fc80425b677a 207 #define FT5336_P2_MISC_REG ((uint8_t)0x0E)
ngtkien 0:fc80425b677a 208
ngtkien 0:fc80425b677a 209 #define FT5336_P3_XH_REG ((uint8_t)0x0F)
ngtkien 0:fc80425b677a 210 #define FT5336_P3_XL_REG ((uint8_t)0x10)
ngtkien 0:fc80425b677a 211 #define FT5336_P3_YH_REG ((uint8_t)0x11)
ngtkien 0:fc80425b677a 212 #define FT5336_P3_YL_REG ((uint8_t)0x12)
ngtkien 0:fc80425b677a 213 #define FT5336_P3_WEIGHT_REG ((uint8_t)0x13)
ngtkien 0:fc80425b677a 214 #define FT5336_P3_MISC_REG ((uint8_t)0x14)
ngtkien 0:fc80425b677a 215
ngtkien 0:fc80425b677a 216 #define FT5336_P4_XH_REG ((uint8_t)0x15)
ngtkien 0:fc80425b677a 217 #define FT5336_P4_XL_REG ((uint8_t)0x16)
ngtkien 0:fc80425b677a 218 #define FT5336_P4_YH_REG ((uint8_t)0x17)
ngtkien 0:fc80425b677a 219 #define FT5336_P4_YL_REG ((uint8_t)0x18)
ngtkien 0:fc80425b677a 220 #define FT5336_P4_WEIGHT_REG ((uint8_t)0x19)
ngtkien 0:fc80425b677a 221 #define FT5336_P4_MISC_REG ((uint8_t)0x1A)
ngtkien 0:fc80425b677a 222
ngtkien 0:fc80425b677a 223 #define FT5336_P5_XH_REG ((uint8_t)0x1B)
ngtkien 0:fc80425b677a 224 #define FT5336_P5_XL_REG ((uint8_t)0x1C)
ngtkien 0:fc80425b677a 225 #define FT5336_P5_YH_REG ((uint8_t)0x1D)
ngtkien 0:fc80425b677a 226 #define FT5336_P5_YL_REG ((uint8_t)0x1E)
ngtkien 0:fc80425b677a 227 #define FT5336_P5_WEIGHT_REG ((uint8_t)0x1F)
ngtkien 0:fc80425b677a 228 #define FT5336_P5_MISC_REG ((uint8_t)0x20)
ngtkien 0:fc80425b677a 229
ngtkien 0:fc80425b677a 230 #define FT5336_P6_XH_REG ((uint8_t)0x21)
ngtkien 0:fc80425b677a 231 #define FT5336_P6_XL_REG ((uint8_t)0x22)
ngtkien 0:fc80425b677a 232 #define FT5336_P6_YH_REG ((uint8_t)0x23)
ngtkien 0:fc80425b677a 233 #define FT5336_P6_YL_REG ((uint8_t)0x24)
ngtkien 0:fc80425b677a 234 #define FT5336_P6_WEIGHT_REG ((uint8_t)0x25)
ngtkien 0:fc80425b677a 235 #define FT5336_P6_MISC_REG ((uint8_t)0x26)
ngtkien 0:fc80425b677a 236
ngtkien 0:fc80425b677a 237 #define FT5336_P7_XH_REG ((uint8_t)0x27)
ngtkien 0:fc80425b677a 238 #define FT5336_P7_XL_REG ((uint8_t)0x28)
ngtkien 0:fc80425b677a 239 #define FT5336_P7_YH_REG ((uint8_t)0x29)
ngtkien 0:fc80425b677a 240 #define FT5336_P7_YL_REG ((uint8_t)0x2A)
ngtkien 0:fc80425b677a 241 #define FT5336_P7_WEIGHT_REG ((uint8_t)0x2B)
ngtkien 0:fc80425b677a 242 #define FT5336_P7_MISC_REG ((uint8_t)0x2C)
ngtkien 0:fc80425b677a 243
ngtkien 0:fc80425b677a 244 #define FT5336_P8_XH_REG ((uint8_t)0x2D)
ngtkien 0:fc80425b677a 245 #define FT5336_P8_XL_REG ((uint8_t)0x2E)
ngtkien 0:fc80425b677a 246 #define FT5336_P8_YH_REG ((uint8_t)0x2F)
ngtkien 0:fc80425b677a 247 #define FT5336_P8_YL_REG ((uint8_t)0x30)
ngtkien 0:fc80425b677a 248 #define FT5336_P8_WEIGHT_REG ((uint8_t)0x31)
ngtkien 0:fc80425b677a 249 #define FT5336_P8_MISC_REG ((uint8_t)0x32)
ngtkien 0:fc80425b677a 250
ngtkien 0:fc80425b677a 251 #define FT5336_P9_XH_REG ((uint8_t)0x33)
ngtkien 0:fc80425b677a 252 #define FT5336_P9_XL_REG ((uint8_t)0x34)
ngtkien 0:fc80425b677a 253 #define FT5336_P9_YH_REG ((uint8_t)0x35)
ngtkien 0:fc80425b677a 254 #define FT5336_P9_YL_REG ((uint8_t)0x36)
ngtkien 0:fc80425b677a 255 #define FT5336_P9_WEIGHT_REG ((uint8_t)0x37)
ngtkien 0:fc80425b677a 256 #define FT5336_P9_MISC_REG ((uint8_t)0x38)
ngtkien 0:fc80425b677a 257
ngtkien 0:fc80425b677a 258 #define FT5336_P10_XH_REG ((uint8_t)0x39)
ngtkien 0:fc80425b677a 259 #define FT5336_P10_XL_REG ((uint8_t)0x3A)
ngtkien 0:fc80425b677a 260 #define FT5336_P10_YH_REG ((uint8_t)0x3B)
ngtkien 0:fc80425b677a 261 #define FT5336_P10_YL_REG ((uint8_t)0x3C)
ngtkien 0:fc80425b677a 262 #define FT5336_P10_WEIGHT_REG ((uint8_t)0x3D)
ngtkien 0:fc80425b677a 263 #define FT5336_P10_MISC_REG ((uint8_t)0x3E)
ngtkien 0:fc80425b677a 264
ngtkien 0:fc80425b677a 265 /* Threshold for touch detection */
ngtkien 0:fc80425b677a 266 #define FT5336_TH_GROUP_REG ((uint8_t)0x80)
ngtkien 0:fc80425b677a 267
ngtkien 0:fc80425b677a 268 /* Values FT5336_TH_GROUP_REG : threshold related */
ngtkien 0:fc80425b677a 269 #define FT5336_THRESHOLD_MASK ((uint8_t)0xFF)
ngtkien 0:fc80425b677a 270 #define FT5336_THRESHOLD_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 271
ngtkien 0:fc80425b677a 272 /* Filter function coefficients */
ngtkien 0:fc80425b677a 273 #define FT5336_TH_DIFF_REG ((uint8_t)0x85)
ngtkien 0:fc80425b677a 274
ngtkien 0:fc80425b677a 275 /* Control register */
ngtkien 0:fc80425b677a 276 #define FT5336_CTRL_REG ((uint8_t)0x86)
ngtkien 0:fc80425b677a 277
ngtkien 0:fc80425b677a 278 /* Values related to FT5336_CTRL_REG */
ngtkien 0:fc80425b677a 279
ngtkien 0:fc80425b677a 280 /* Will keep the Active mode when there is no touching */
ngtkien 0:fc80425b677a 281 #define FT5336_CTRL_KEEP_ACTIVE_MODE ((uint8_t)0x00)
ngtkien 0:fc80425b677a 282
ngtkien 0:fc80425b677a 283 /* Switching from Active mode to Monitor mode automatically when there is no touching */
ngtkien 0:fc80425b677a 284 #define FT5336_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE ((uint8_t)0x01
ngtkien 0:fc80425b677a 285
ngtkien 0:fc80425b677a 286 /* The time period of switching from Active mode to Monitor mode when there is no touching */
ngtkien 0:fc80425b677a 287 #define FT5336_TIMEENTERMONITOR_REG ((uint8_t)0x87)
ngtkien 0:fc80425b677a 288
ngtkien 0:fc80425b677a 289 /* Report rate in Active mode */
ngtkien 0:fc80425b677a 290 #define FT5336_PERIODACTIVE_REG ((uint8_t)0x88)
ngtkien 0:fc80425b677a 291
ngtkien 0:fc80425b677a 292 /* Report rate in Monitor mode */
ngtkien 0:fc80425b677a 293 #define FT5336_PERIODMONITOR_REG ((uint8_t)0x89)
ngtkien 0:fc80425b677a 294
ngtkien 0:fc80425b677a 295 /* The value of the minimum allowed angle while Rotating gesture mode */
ngtkien 0:fc80425b677a 296 #define FT5336_RADIAN_VALUE_REG ((uint8_t)0x91)
ngtkien 0:fc80425b677a 297
ngtkien 0:fc80425b677a 298 /* Maximum offset while Moving Left and Moving Right gesture */
ngtkien 0:fc80425b677a 299 #define FT5336_OFFSET_LEFT_RIGHT_REG ((uint8_t)0x92)
ngtkien 0:fc80425b677a 300
ngtkien 0:fc80425b677a 301 /* Maximum offset while Moving Up and Moving Down gesture */
ngtkien 0:fc80425b677a 302 #define FT5336_OFFSET_UP_DOWN_REG ((uint8_t)0x93)
ngtkien 0:fc80425b677a 303
ngtkien 0:fc80425b677a 304 /* Minimum distance while Moving Left and Moving Right gesture */
ngtkien 0:fc80425b677a 305 #define FT5336_DISTANCE_LEFT_RIGHT_REG ((uint8_t)0x94)
ngtkien 0:fc80425b677a 306
ngtkien 0:fc80425b677a 307 /* Minimum distance while Moving Up and Moving Down gesture */
ngtkien 0:fc80425b677a 308 #define FT5336_DISTANCE_UP_DOWN_REG ((uint8_t)0x95)
ngtkien 0:fc80425b677a 309
ngtkien 0:fc80425b677a 310 /* Maximum distance while Zoom In and Zoom Out gesture */
ngtkien 0:fc80425b677a 311 #define FT5336_DISTANCE_ZOOM_REG ((uint8_t)0x96)
ngtkien 0:fc80425b677a 312
ngtkien 0:fc80425b677a 313 /* High 8-bit of LIB Version info */
ngtkien 0:fc80425b677a 314 #define FT5336_LIB_VER_H_REG ((uint8_t)0xA1)
ngtkien 0:fc80425b677a 315
ngtkien 0:fc80425b677a 316 /* Low 8-bit of LIB Version info */
ngtkien 0:fc80425b677a 317 #define FT5336_LIB_VER_L_REG ((uint8_t)0xA2)
ngtkien 0:fc80425b677a 318
ngtkien 0:fc80425b677a 319 /* Chip Selecting */
ngtkien 0:fc80425b677a 320 #define FT5336_CIPHER_REG ((uint8_t)0xA3)
ngtkien 0:fc80425b677a 321
ngtkien 0:fc80425b677a 322 /* Interrupt mode register (used when in interrupt mode) */
ngtkien 0:fc80425b677a 323 #define FT5336_GMODE_REG ((uint8_t)0xA4)
ngtkien 0:fc80425b677a 324
ngtkien 0:fc80425b677a 325 #define FT5336_G_MODE_INTERRUPT_MASK ((uint8_t)0x03)
ngtkien 0:fc80425b677a 326 #define FT5336_G_MODE_INTERRUPT_SHIFT ((uint8_t)0x00)
ngtkien 0:fc80425b677a 327
ngtkien 0:fc80425b677a 328 /* Possible values of FT5336_GMODE_REG */
ngtkien 0:fc80425b677a 329 #define FT5336_G_MODE_INTERRUPT_POLLING ((uint8_t)0x00)
ngtkien 0:fc80425b677a 330 #define FT5336_G_MODE_INTERRUPT_TRIGGER ((uint8_t)0x01)
ngtkien 0:fc80425b677a 331
ngtkien 0:fc80425b677a 332 /* Current power mode the FT5336 system is in (R) */
ngtkien 0:fc80425b677a 333 #define FT5336_PWR_MODE_REG ((uint8_t)0xA5)
ngtkien 0:fc80425b677a 334
ngtkien 0:fc80425b677a 335 /* FT5336 firmware version */
ngtkien 0:fc80425b677a 336 #define FT5336_FIRMID_REG ((uint8_t)0xA6)
ngtkien 0:fc80425b677a 337
ngtkien 0:fc80425b677a 338 /* FT5336 Chip identification register */
ngtkien 0:fc80425b677a 339 #define FT5336_CHIP_ID_REG ((uint8_t)0xA8)
ngtkien 0:fc80425b677a 340
ngtkien 0:fc80425b677a 341 /* Possible values of FT5336_CHIP_ID_REG */
ngtkien 0:fc80425b677a 342 #define FT5336_ID_VALUE ((uint8_t)0x51)
ngtkien 0:fc80425b677a 343
ngtkien 0:fc80425b677a 344 /* Release code version */
ngtkien 0:fc80425b677a 345 #define FT5336_RELEASE_CODE_ID_REG ((uint8_t)0xAF)
ngtkien 0:fc80425b677a 346
ngtkien 0:fc80425b677a 347 /* Current operating mode the FT5336 system is in (R) */
ngtkien 0:fc80425b677a 348 #define FT5336_STATE_REG ((uint8_t)0xBC)
ngtkien 0:fc80425b677a 349
ngtkien 0:fc80425b677a 350 /**
ngtkien 0:fc80425b677a 351 * @}
ngtkien 0:fc80425b677a 352 */
ngtkien 0:fc80425b677a 353
ngtkien 0:fc80425b677a 354 /* Exported macro ------------------------------------------------------------*/
ngtkien 0:fc80425b677a 355
ngtkien 0:fc80425b677a 356 /** @defgroup ft5336_Exported_Macros
ngtkien 0:fc80425b677a 357 * @{
ngtkien 0:fc80425b677a 358 */
ngtkien 0:fc80425b677a 359
ngtkien 0:fc80425b677a 360 /* Exported functions --------------------------------------------------------*/
ngtkien 0:fc80425b677a 361
ngtkien 0:fc80425b677a 362 /** @defgroup ft5336_Exported_Functions
ngtkien 0:fc80425b677a 363 * @{
ngtkien 0:fc80425b677a 364 */
ngtkien 0:fc80425b677a 365
ngtkien 0:fc80425b677a 366 /**
ngtkien 0:fc80425b677a 367 * @brief ft5336 Control functions
ngtkien 0:fc80425b677a 368 */
ngtkien 0:fc80425b677a 369
ngtkien 0:fc80425b677a 370
ngtkien 0:fc80425b677a 371 /**
ngtkien 0:fc80425b677a 372 * @brief Initialize the ft5336 communication bus
ngtkien 0:fc80425b677a 373 * from MCU to FT5336 : ie I2C channel initialization (if required).
ngtkien 0:fc80425b677a 374 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 375 * @retval None
ngtkien 0:fc80425b677a 376 */
ngtkien 0:fc80425b677a 377 void ft5336_Init(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 378
ngtkien 0:fc80425b677a 379 /**
ngtkien 0:fc80425b677a 380 * @brief Software Reset the ft5336.
ngtkien 0:fc80425b677a 381 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 382 * @retval None
ngtkien 0:fc80425b677a 383 */
ngtkien 0:fc80425b677a 384 void ft5336_Reset(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 385
ngtkien 0:fc80425b677a 386 /**
ngtkien 0:fc80425b677a 387 * @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
ngtkien 0:fc80425b677a 388 * able to read the FT5336 device ID, and verify this is a FT5336.
ngtkien 0:fc80425b677a 389 * @param DeviceAddr: I2C FT5336 Slave address.
ngtkien 0:fc80425b677a 390 * @retval The Device ID (two bytes).
ngtkien 0:fc80425b677a 391 */
ngtkien 0:fc80425b677a 392 uint16_t ft5336_ReadID(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 393
ngtkien 0:fc80425b677a 394 /**
ngtkien 0:fc80425b677a 395 * @brief Configures the touch Screen IC device to start detecting touches
ngtkien 0:fc80425b677a 396 * @param DeviceAddr: Device address on communication Bus (I2C slave address).
ngtkien 0:fc80425b677a 397 * @retval None.
ngtkien 0:fc80425b677a 398 */
ngtkien 0:fc80425b677a 399 void ft5336_TS_Start(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 400
ngtkien 0:fc80425b677a 401 /**
ngtkien 0:fc80425b677a 402 * @brief Return if there is touches detected or not.
ngtkien 0:fc80425b677a 403 * Try to detect new touches and forget the old ones (reset internal global
ngtkien 0:fc80425b677a 404 * variables).
ngtkien 0:fc80425b677a 405 * @param DeviceAddr: Device address on communication Bus.
ngtkien 0:fc80425b677a 406 * @retval : Number of active touches detected (can be 0, 1 or 2).
ngtkien 0:fc80425b677a 407 */
ngtkien 0:fc80425b677a 408 uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 409
ngtkien 0:fc80425b677a 410 /**
ngtkien 0:fc80425b677a 411 * @brief Get the touch screen X and Y positions values
ngtkien 0:fc80425b677a 412 * Manage multi touch thanks to touch Index global
ngtkien 0:fc80425b677a 413 * variable 'ft5336_handle.currActiveTouchIdx'.
ngtkien 0:fc80425b677a 414 * @param DeviceAddr: Device address on communication Bus.
ngtkien 0:fc80425b677a 415 * @param X: Pointer to X position value
ngtkien 0:fc80425b677a 416 * @param Y: Pointer to Y position value
ngtkien 0:fc80425b677a 417 * @retval None.
ngtkien 0:fc80425b677a 418 */
ngtkien 0:fc80425b677a 419 void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
ngtkien 0:fc80425b677a 420
ngtkien 0:fc80425b677a 421 /**
ngtkien 0:fc80425b677a 422 * @brief Configure the FT5336 device to generate IT on given INT pin
ngtkien 0:fc80425b677a 423 * connected to MCU as EXTI.
ngtkien 0:fc80425b677a 424 * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
ngtkien 0:fc80425b677a 425 * @retval None
ngtkien 0:fc80425b677a 426 */
ngtkien 0:fc80425b677a 427 void ft5336_TS_EnableIT(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 428
ngtkien 0:fc80425b677a 429 /**
ngtkien 0:fc80425b677a 430 * @brief Configure the FT5336 device to stop generating IT on the given INT pin
ngtkien 0:fc80425b677a 431 * connected to MCU as EXTI.
ngtkien 0:fc80425b677a 432 * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
ngtkien 0:fc80425b677a 433 * @retval None
ngtkien 0:fc80425b677a 434 */
ngtkien 0:fc80425b677a 435 void ft5336_TS_DisableIT(uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 436
ngtkien 0:fc80425b677a 437 /**
ngtkien 0:fc80425b677a 438 * @brief Get IT status from FT5336 interrupt status registers
ngtkien 0:fc80425b677a 439 * Should be called Following an EXTI coming to the MCU to know the detailed
ngtkien 0:fc80425b677a 440 * reason of the interrupt.
ngtkien 0:fc80425b677a 441 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 442 * @retval TS interrupts status
ngtkien 0:fc80425b677a 443 */
ngtkien 0:fc80425b677a 444 uint8_t ft5336_TS_ITStatus (uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 445
ngtkien 0:fc80425b677a 446 /**
ngtkien 0:fc80425b677a 447 * @brief Clear IT status in FT5336 interrupt status clear registers
ngtkien 0:fc80425b677a 448 * Should be called Following an EXTI coming to the MCU.
ngtkien 0:fc80425b677a 449 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 450 * @retval TS interrupts status
ngtkien 0:fc80425b677a 451 */
ngtkien 0:fc80425b677a 452 void ft5336_TS_ClearIT (uint16_t DeviceAddr);
ngtkien 0:fc80425b677a 453
ngtkien 0:fc80425b677a 454 /**** NEW FEATURES enabled when Multi-touch support is enabled ****/
ngtkien 0:fc80425b677a 455
ngtkien 0:fc80425b677a 456 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
ngtkien 0:fc80425b677a 457
ngtkien 0:fc80425b677a 458 /**
ngtkien 0:fc80425b677a 459 * @brief Get the last touch gesture identification (zoom, move up/down...).
ngtkien 0:fc80425b677a 460 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 461 * @param pGestureId : Pointer to get last touch gesture Identification.
ngtkien 0:fc80425b677a 462 * @retval None.
ngtkien 0:fc80425b677a 463 */
ngtkien 0:fc80425b677a 464 void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
ngtkien 0:fc80425b677a 465
ngtkien 0:fc80425b677a 466 /**
ngtkien 0:fc80425b677a 467 * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
ngtkien 0:fc80425b677a 468 * This touch detailed information contains :
ngtkien 0:fc80425b677a 469 * - weight that was applied to this touch
ngtkien 0:fc80425b677a 470 * - sub-area of the touch in the touch panel
ngtkien 0:fc80425b677a 471 * - event of linked to the touch (press down, lift up, ...)
ngtkien 0:fc80425b677a 472 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
ngtkien 0:fc80425b677a 473 * @param touchIdx : Passed index of the touch (0..1) on which we want to get the
ngtkien 0:fc80425b677a 474 * detailed information.
ngtkien 0:fc80425b677a 475 * @param pWeight : Pointer to to get the weight information of 'touchIdx'.
ngtkien 0:fc80425b677a 476 * @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
ngtkien 0:fc80425b677a 477 * @param pEvent : Pointer to to get the event information of 'touchIdx'.
ngtkien 0:fc80425b677a 478
ngtkien 0:fc80425b677a 479 * @retval None.
ngtkien 0:fc80425b677a 480 */
ngtkien 0:fc80425b677a 481 void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
ngtkien 0:fc80425b677a 482 uint32_t touchIdx,
ngtkien 0:fc80425b677a 483 uint32_t * pWeight,
ngtkien 0:fc80425b677a 484 uint32_t * pArea,
ngtkien 0:fc80425b677a 485 uint32_t * pEvent);
ngtkien 0:fc80425b677a 486
ngtkien 0:fc80425b677a 487 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
ngtkien 0:fc80425b677a 488
ngtkien 0:fc80425b677a 489 /* Imported TS IO functions --------------------------------------------------------*/
ngtkien 0:fc80425b677a 490
ngtkien 0:fc80425b677a 491 /** @defgroup ft5336_Imported_Functions
ngtkien 0:fc80425b677a 492 * @{
ngtkien 0:fc80425b677a 493 */
ngtkien 0:fc80425b677a 494
ngtkien 0:fc80425b677a 495 /* TouchScreen (TS) external IO functions */
ngtkien 0:fc80425b677a 496 extern void TS_IO_Init(void);
ngtkien 0:fc80425b677a 497 extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
ngtkien 0:fc80425b677a 498 extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
ngtkien 0:fc80425b677a 499 extern void TS_IO_Delay(uint32_t Delay);
ngtkien 0:fc80425b677a 500
ngtkien 0:fc80425b677a 501 /**
ngtkien 0:fc80425b677a 502 * @}
ngtkien 0:fc80425b677a 503 */
ngtkien 0:fc80425b677a 504
ngtkien 0:fc80425b677a 505 /* Imported global variables --------------------------------------------------------*/
ngtkien 0:fc80425b677a 506
ngtkien 0:fc80425b677a 507 /** @defgroup ft5336_Imported_Globals
ngtkien 0:fc80425b677a 508 * @{
ngtkien 0:fc80425b677a 509 */
ngtkien 0:fc80425b677a 510
ngtkien 0:fc80425b677a 511
ngtkien 0:fc80425b677a 512 /* Touch screen driver structure */
ngtkien 0:fc80425b677a 513 extern TS_DrvTypeDef ft5336_ts_drv;
ngtkien 0:fc80425b677a 514
ngtkien 0:fc80425b677a 515 /**
ngtkien 0:fc80425b677a 516 * @}
ngtkien 0:fc80425b677a 517 */
ngtkien 0:fc80425b677a 518
ngtkien 0:fc80425b677a 519 #ifdef __cplusplus
ngtkien 0:fc80425b677a 520 }
ngtkien 0:fc80425b677a 521 #endif
ngtkien 0:fc80425b677a 522 #endif /* __FT5336_H */
ngtkien 0:fc80425b677a 523
ngtkien 0:fc80425b677a 524
ngtkien 0:fc80425b677a 525 /**
ngtkien 0:fc80425b677a 526 * @}
ngtkien 0:fc80425b677a 527 */
ngtkien 0:fc80425b677a 528
ngtkien 0:fc80425b677a 529 /**
ngtkien 0:fc80425b677a 530 * @}
ngtkien 0:fc80425b677a 531 */
ngtkien 0:fc80425b677a 532
ngtkien 0:fc80425b677a 533 /**
ngtkien 0:fc80425b677a 534 * @}
ngtkien 0:fc80425b677a 535 */
ngtkien 0:fc80425b677a 536
ngtkien 0:fc80425b677a 537 /**
ngtkien 0:fc80425b677a 538 * @}
ngtkien 0:fc80425b677a 539 */
ngtkien 0:fc80425b677a 540 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/