STM32Cube BSP FW for STM32F769I-Discovery

Dependents:   mbed-os-example-blinky-5 DISCO-F769NI_TOUCHSCREEN_demo_custom_1 Datarecorder2 DISCO-F769NI_TOUCHSCREEN_demo ... more

Committer:
Jerome Coutant
Date:
Fri Feb 10 13:08:21 2017 +0100
Revision:
0:c0f3bbab73d2
Child:
4:72a949940ad6
STM32Cube_FW_F7_V1.5.1 BSP STM32F769I-Discovery

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jerome Coutant 0:c0f3bbab73d2 1 /**
Jerome Coutant 0:c0f3bbab73d2 2 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 3 * @file ft6x06.h
Jerome Coutant 0:c0f3bbab73d2 4 * @author MCD Application Team
Jerome Coutant 0:c0f3bbab73d2 5 * @version V1.0.1
Jerome Coutant 0:c0f3bbab73d2 6 * @date 03-May-2016
Jerome Coutant 0:c0f3bbab73d2 7 * @brief This file contains all the functions prototypes for the
Jerome Coutant 0:c0f3bbab73d2 8 * ft6x06.c IO expander driver.
Jerome Coutant 0:c0f3bbab73d2 9 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 10 * @attention
Jerome Coutant 0:c0f3bbab73d2 11 *
Jerome Coutant 0:c0f3bbab73d2 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Jerome Coutant 0:c0f3bbab73d2 13 *
Jerome Coutant 0:c0f3bbab73d2 14 * Redistribution and use in source and binary forms, with or without modification,
Jerome Coutant 0:c0f3bbab73d2 15 * are permitted provided that the following conditions are met:
Jerome Coutant 0:c0f3bbab73d2 16 * 1. Redistributions of source code must retain the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 17 * this list of conditions and the following disclaimer.
Jerome Coutant 0:c0f3bbab73d2 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jerome Coutant 0:c0f3bbab73d2 19 * this list of conditions and the following disclaimer in the documentation
Jerome Coutant 0:c0f3bbab73d2 20 * and/or other materials provided with the distribution.
Jerome Coutant 0:c0f3bbab73d2 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Jerome Coutant 0:c0f3bbab73d2 22 * may be used to endorse or promote products derived from this software
Jerome Coutant 0:c0f3bbab73d2 23 * without specific prior written permission.
Jerome Coutant 0:c0f3bbab73d2 24 *
Jerome Coutant 0:c0f3bbab73d2 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jerome Coutant 0:c0f3bbab73d2 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jerome Coutant 0:c0f3bbab73d2 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jerome Coutant 0:c0f3bbab73d2 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jerome Coutant 0:c0f3bbab73d2 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jerome Coutant 0:c0f3bbab73d2 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jerome Coutant 0:c0f3bbab73d2 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jerome Coutant 0:c0f3bbab73d2 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jerome Coutant 0:c0f3bbab73d2 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jerome Coutant 0:c0f3bbab73d2 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jerome Coutant 0:c0f3bbab73d2 35 *
Jerome Coutant 0:c0f3bbab73d2 36 ******************************************************************************
Jerome Coutant 0:c0f3bbab73d2 37 */
Jerome Coutant 0:c0f3bbab73d2 38
Jerome Coutant 0:c0f3bbab73d2 39 /* Define to prevent recursive inclusion -------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 40 #ifndef __FT6X06_H
Jerome Coutant 0:c0f3bbab73d2 41 #define __FT6X06_H
Jerome Coutant 0:c0f3bbab73d2 42
Jerome Coutant 0:c0f3bbab73d2 43 #ifdef __cplusplus
Jerome Coutant 0:c0f3bbab73d2 44 extern "C" {
Jerome Coutant 0:c0f3bbab73d2 45 #endif
Jerome Coutant 0:c0f3bbab73d2 46
Jerome Coutant 0:c0f3bbab73d2 47 /* Set Multi-touch as non supported */
Jerome Coutant 0:c0f3bbab73d2 48 #ifndef TS_MULTI_TOUCH_SUPPORTED
Jerome Coutant 0:c0f3bbab73d2 49 #define TS_MULTI_TOUCH_SUPPORTED 0
Jerome Coutant 0:c0f3bbab73d2 50 #endif
Jerome Coutant 0:c0f3bbab73d2 51
Jerome Coutant 0:c0f3bbab73d2 52 /* Set Auto-calibration as non supported */
Jerome Coutant 0:c0f3bbab73d2 53 #ifndef TS_AUTO_CALIBRATION_SUPPORTED
Jerome Coutant 0:c0f3bbab73d2 54 #define TS_AUTO_CALIBRATION_SUPPORTED 0
Jerome Coutant 0:c0f3bbab73d2 55 #endif
Jerome Coutant 0:c0f3bbab73d2 56
Jerome Coutant 0:c0f3bbab73d2 57 /* Includes ------------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 58 #include "../Common/ts.h"
Jerome Coutant 0:c0f3bbab73d2 59
Jerome Coutant 0:c0f3bbab73d2 60 /* Macros --------------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 61
Jerome Coutant 0:c0f3bbab73d2 62 /** @typedef ft6x06_handle_TypeDef
Jerome Coutant 0:c0f3bbab73d2 63 * ft6x06 Handle definition.
Jerome Coutant 0:c0f3bbab73d2 64 */
Jerome Coutant 0:c0f3bbab73d2 65 typedef struct
Jerome Coutant 0:c0f3bbab73d2 66 {
Jerome Coutant 0:c0f3bbab73d2 67 uint8_t i2cInitialized;
Jerome Coutant 0:c0f3bbab73d2 68
Jerome Coutant 0:c0f3bbab73d2 69 /* field holding the current number of simultaneous active touches */
Jerome Coutant 0:c0f3bbab73d2 70 uint8_t currActiveTouchNb;
Jerome Coutant 0:c0f3bbab73d2 71
Jerome Coutant 0:c0f3bbab73d2 72 /* field holding the touch index currently managed */
Jerome Coutant 0:c0f3bbab73d2 73 uint8_t currActiveTouchIdx;
Jerome Coutant 0:c0f3bbab73d2 74
Jerome Coutant 0:c0f3bbab73d2 75 } ft6x06_handle_TypeDef;
Jerome Coutant 0:c0f3bbab73d2 76
Jerome Coutant 0:c0f3bbab73d2 77 /** @addtogroup BSP
Jerome Coutant 0:c0f3bbab73d2 78 * @{
Jerome Coutant 0:c0f3bbab73d2 79 */
Jerome Coutant 0:c0f3bbab73d2 80
Jerome Coutant 0:c0f3bbab73d2 81 /** @addtogroup Component
Jerome Coutant 0:c0f3bbab73d2 82 * @{
Jerome Coutant 0:c0f3bbab73d2 83 */
Jerome Coutant 0:c0f3bbab73d2 84
Jerome Coutant 0:c0f3bbab73d2 85 /** @defgroup FT6X06
Jerome Coutant 0:c0f3bbab73d2 86 * @{
Jerome Coutant 0:c0f3bbab73d2 87 */
Jerome Coutant 0:c0f3bbab73d2 88
Jerome Coutant 0:c0f3bbab73d2 89 /* Exported types ------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 90
Jerome Coutant 0:c0f3bbab73d2 91 /** @defgroup FT6X06_Exported_Types
Jerome Coutant 0:c0f3bbab73d2 92 * @{
Jerome Coutant 0:c0f3bbab73d2 93 */
Jerome Coutant 0:c0f3bbab73d2 94
Jerome Coutant 0:c0f3bbab73d2 95 /* Exported constants --------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 96
Jerome Coutant 0:c0f3bbab73d2 97 /** @defgroup FT6X06_Exported_Constants
Jerome Coutant 0:c0f3bbab73d2 98 * @{
Jerome Coutant 0:c0f3bbab73d2 99 */
Jerome Coutant 0:c0f3bbab73d2 100
Jerome Coutant 0:c0f3bbab73d2 101 /* Maximum border values of the touchscreen pad */
Jerome Coutant 0:c0f3bbab73d2 102 #define FT_6206_MAX_WIDTH ((uint16_t)800) /* Touchscreen pad max width */
Jerome Coutant 0:c0f3bbab73d2 103 #define FT_6206_MAX_HEIGHT ((uint16_t)480) /* Touchscreen pad max height */
Jerome Coutant 0:c0f3bbab73d2 104
Jerome Coutant 0:c0f3bbab73d2 105 /* Touchscreen pad max width and height values for FT6x36 Touch*/
Jerome Coutant 0:c0f3bbab73d2 106 #define FT_6206_MAX_WIDTH_HEIGHT ((uint16_t)240)
Jerome Coutant 0:c0f3bbab73d2 107
Jerome Coutant 0:c0f3bbab73d2 108 /* Possible values of driver functions return status */
Jerome Coutant 0:c0f3bbab73d2 109 #define FT6206_STATUS_OK 0
Jerome Coutant 0:c0f3bbab73d2 110 #define FT6206_STATUS_NOT_OK 1
Jerome Coutant 0:c0f3bbab73d2 111
Jerome Coutant 0:c0f3bbab73d2 112 /* Possible values of global variable 'TS_I2C_Initialized' */
Jerome Coutant 0:c0f3bbab73d2 113 #define FT6206_I2C_NOT_INITIALIZED 0
Jerome Coutant 0:c0f3bbab73d2 114 #define FT6206_I2C_INITIALIZED 1
Jerome Coutant 0:c0f3bbab73d2 115
Jerome Coutant 0:c0f3bbab73d2 116 /* Max detectable simultaneous touches */
Jerome Coutant 0:c0f3bbab73d2 117 #define FT6206_MAX_DETECTABLE_TOUCH 2
Jerome Coutant 0:c0f3bbab73d2 118
Jerome Coutant 0:c0f3bbab73d2 119 /**
Jerome Coutant 0:c0f3bbab73d2 120 * @brief : Definitions for FT6206 I2C register addresses on 8 bit
Jerome Coutant 0:c0f3bbab73d2 121 **/
Jerome Coutant 0:c0f3bbab73d2 122
Jerome Coutant 0:c0f3bbab73d2 123 /* Current mode register of the FT6206 (R/W) */
Jerome Coutant 0:c0f3bbab73d2 124 #define FT6206_DEV_MODE_REG 0x00
Jerome Coutant 0:c0f3bbab73d2 125
Jerome Coutant 0:c0f3bbab73d2 126 /* Possible values of FT6206_DEV_MODE_REG */
Jerome Coutant 0:c0f3bbab73d2 127 #define FT6206_DEV_MODE_WORKING 0x00
Jerome Coutant 0:c0f3bbab73d2 128 #define FT6206_DEV_MODE_FACTORY 0x04
Jerome Coutant 0:c0f3bbab73d2 129
Jerome Coutant 0:c0f3bbab73d2 130 #define FT6206_DEV_MODE_MASK 0x7
Jerome Coutant 0:c0f3bbab73d2 131 #define FT6206_DEV_MODE_SHIFT 4
Jerome Coutant 0:c0f3bbab73d2 132
Jerome Coutant 0:c0f3bbab73d2 133 /* Gesture ID register */
Jerome Coutant 0:c0f3bbab73d2 134 #define FT6206_GEST_ID_REG 0x01
Jerome Coutant 0:c0f3bbab73d2 135
Jerome Coutant 0:c0f3bbab73d2 136 /* Possible values of FT6206_GEST_ID_REG */
Jerome Coutant 0:c0f3bbab73d2 137 #define FT6206_GEST_ID_NO_GESTURE 0x00
Jerome Coutant 0:c0f3bbab73d2 138 #define FT6206_GEST_ID_MOVE_UP 0x10
Jerome Coutant 0:c0f3bbab73d2 139 #define FT6206_GEST_ID_MOVE_RIGHT 0x14
Jerome Coutant 0:c0f3bbab73d2 140 #define FT6206_GEST_ID_MOVE_DOWN 0x18
Jerome Coutant 0:c0f3bbab73d2 141 #define FT6206_GEST_ID_MOVE_LEFT 0x1C
Jerome Coutant 0:c0f3bbab73d2 142 #define FT6206_GEST_ID_ZOOM_IN 0x48
Jerome Coutant 0:c0f3bbab73d2 143 #define FT6206_GEST_ID_ZOOM_OUT 0x49
Jerome Coutant 0:c0f3bbab73d2 144
Jerome Coutant 0:c0f3bbab73d2 145 /* Touch Data Status register : gives number of active touch points (0..2) */
Jerome Coutant 0:c0f3bbab73d2 146 #define FT6206_TD_STAT_REG 0x02
Jerome Coutant 0:c0f3bbab73d2 147
Jerome Coutant 0:c0f3bbab73d2 148 /* Values related to FT6206_TD_STAT_REG */
Jerome Coutant 0:c0f3bbab73d2 149 #define FT6206_TD_STAT_MASK 0x0F
Jerome Coutant 0:c0f3bbab73d2 150 #define FT6206_TD_STAT_SHIFT 0x00
Jerome Coutant 0:c0f3bbab73d2 151
Jerome Coutant 0:c0f3bbab73d2 152 /* Values Pn_XH and Pn_YH related */
Jerome Coutant 0:c0f3bbab73d2 153 #define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00
Jerome Coutant 0:c0f3bbab73d2 154 #define FT6206_TOUCH_EVT_FLAG_LIFT_UP 0x01
Jerome Coutant 0:c0f3bbab73d2 155 #define FT6206_TOUCH_EVT_FLAG_CONTACT 0x02
Jerome Coutant 0:c0f3bbab73d2 156 #define FT6206_TOUCH_EVT_FLAG_NO_EVENT 0x03
Jerome Coutant 0:c0f3bbab73d2 157
Jerome Coutant 0:c0f3bbab73d2 158 #define FT6206_TOUCH_EVT_FLAG_SHIFT 6
Jerome Coutant 0:c0f3bbab73d2 159 #define FT6206_TOUCH_EVT_FLAG_MASK (3 << FT6206_TOUCH_EVT_FLAG_SHIFT)
Jerome Coutant 0:c0f3bbab73d2 160
Jerome Coutant 0:c0f3bbab73d2 161 #define FT6206_MSB_MASK 0x0F
Jerome Coutant 0:c0f3bbab73d2 162 #define FT6206_MSB_SHIFT 0
Jerome Coutant 0:c0f3bbab73d2 163
Jerome Coutant 0:c0f3bbab73d2 164 /* Values Pn_XL and Pn_YL related */
Jerome Coutant 0:c0f3bbab73d2 165 #define FT6206_LSB_MASK 0xFF
Jerome Coutant 0:c0f3bbab73d2 166 #define FT6206_LSB_SHIFT 0
Jerome Coutant 0:c0f3bbab73d2 167
Jerome Coutant 0:c0f3bbab73d2 168 #define FT6206_P1_XH_REG 0x03
Jerome Coutant 0:c0f3bbab73d2 169 #define FT6206_P1_XL_REG 0x04
Jerome Coutant 0:c0f3bbab73d2 170 #define FT6206_P1_YH_REG 0x05
Jerome Coutant 0:c0f3bbab73d2 171 #define FT6206_P1_YL_REG 0x06
Jerome Coutant 0:c0f3bbab73d2 172
Jerome Coutant 0:c0f3bbab73d2 173 /* Touch Pressure register value (R) */
Jerome Coutant 0:c0f3bbab73d2 174 #define FT6206_P1_WEIGHT_REG 0x07
Jerome Coutant 0:c0f3bbab73d2 175
Jerome Coutant 0:c0f3bbab73d2 176 /* Values Pn_WEIGHT related */
Jerome Coutant 0:c0f3bbab73d2 177 #define FT6206_TOUCH_WEIGHT_MASK 0xFF
Jerome Coutant 0:c0f3bbab73d2 178 #define FT6206_TOUCH_WEIGHT_SHIFT 0
Jerome Coutant 0:c0f3bbab73d2 179
Jerome Coutant 0:c0f3bbab73d2 180 /* Touch area register */
Jerome Coutant 0:c0f3bbab73d2 181 #define FT6206_P1_MISC_REG 0x08
Jerome Coutant 0:c0f3bbab73d2 182
Jerome Coutant 0:c0f3bbab73d2 183 /* Values related to FT6206_Pn_MISC_REG */
Jerome Coutant 0:c0f3bbab73d2 184 #define FT6206_TOUCH_AREA_MASK (0x04 << 4)
Jerome Coutant 0:c0f3bbab73d2 185 #define FT6206_TOUCH_AREA_SHIFT 0x04
Jerome Coutant 0:c0f3bbab73d2 186
Jerome Coutant 0:c0f3bbab73d2 187 #define FT6206_P2_XH_REG 0x09
Jerome Coutant 0:c0f3bbab73d2 188 #define FT6206_P2_XL_REG 0x0A
Jerome Coutant 0:c0f3bbab73d2 189 #define FT6206_P2_YH_REG 0x0B
Jerome Coutant 0:c0f3bbab73d2 190 #define FT6206_P2_YL_REG 0x0C
Jerome Coutant 0:c0f3bbab73d2 191 #define FT6206_P2_WEIGHT_REG 0x0D
Jerome Coutant 0:c0f3bbab73d2 192 #define FT6206_P2_MISC_REG 0x0E
Jerome Coutant 0:c0f3bbab73d2 193
Jerome Coutant 0:c0f3bbab73d2 194 /* Threshold for touch detection */
Jerome Coutant 0:c0f3bbab73d2 195 #define FT6206_TH_GROUP_REG 0x80
Jerome Coutant 0:c0f3bbab73d2 196
Jerome Coutant 0:c0f3bbab73d2 197 /* Values FT6206_TH_GROUP_REG : threshold related */
Jerome Coutant 0:c0f3bbab73d2 198 #define FT6206_THRESHOLD_MASK 0xFF
Jerome Coutant 0:c0f3bbab73d2 199 #define FT6206_THRESHOLD_SHIFT 0
Jerome Coutant 0:c0f3bbab73d2 200
Jerome Coutant 0:c0f3bbab73d2 201 /* Filter function coefficients */
Jerome Coutant 0:c0f3bbab73d2 202 #define FT6206_TH_DIFF_REG 0x85
Jerome Coutant 0:c0f3bbab73d2 203
Jerome Coutant 0:c0f3bbab73d2 204 /* Control register */
Jerome Coutant 0:c0f3bbab73d2 205 #define FT6206_CTRL_REG 0x86
Jerome Coutant 0:c0f3bbab73d2 206
Jerome Coutant 0:c0f3bbab73d2 207 /* Values related to FT6206_CTRL_REG */
Jerome Coutant 0:c0f3bbab73d2 208
Jerome Coutant 0:c0f3bbab73d2 209 /* Will keep the Active mode when there is no touching */
Jerome Coutant 0:c0f3bbab73d2 210 #define FT6206_CTRL_KEEP_ACTIVE_MODE 0x00
Jerome Coutant 0:c0f3bbab73d2 211
Jerome Coutant 0:c0f3bbab73d2 212 /* Switching from Active mode to Monitor mode automatically when there is no touching */
Jerome Coutant 0:c0f3bbab73d2 213 #define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01
Jerome Coutant 0:c0f3bbab73d2 214
Jerome Coutant 0:c0f3bbab73d2 215 /* The time period of switching from Active mode to Monitor mode when there is no touching */
Jerome Coutant 0:c0f3bbab73d2 216 #define FT6206_TIMEENTERMONITOR_REG 0x87
Jerome Coutant 0:c0f3bbab73d2 217
Jerome Coutant 0:c0f3bbab73d2 218 /* Report rate in Active mode */
Jerome Coutant 0:c0f3bbab73d2 219 #define FT6206_PERIODACTIVE_REG 0x88
Jerome Coutant 0:c0f3bbab73d2 220
Jerome Coutant 0:c0f3bbab73d2 221 /* Report rate in Monitor mode */
Jerome Coutant 0:c0f3bbab73d2 222 #define FT6206_PERIODMONITOR_REG 0x89
Jerome Coutant 0:c0f3bbab73d2 223
Jerome Coutant 0:c0f3bbab73d2 224 /* The value of the minimum allowed angle while Rotating gesture mode */
Jerome Coutant 0:c0f3bbab73d2 225 #define FT6206_RADIAN_VALUE_REG 0x91
Jerome Coutant 0:c0f3bbab73d2 226
Jerome Coutant 0:c0f3bbab73d2 227 /* Maximum offset while Moving Left and Moving Right gesture */
Jerome Coutant 0:c0f3bbab73d2 228 #define FT6206_OFFSET_LEFT_RIGHT_REG 0x92
Jerome Coutant 0:c0f3bbab73d2 229
Jerome Coutant 0:c0f3bbab73d2 230 /* Maximum offset while Moving Up and Moving Down gesture */
Jerome Coutant 0:c0f3bbab73d2 231 #define FT6206_OFFSET_UP_DOWN_REG 0x93
Jerome Coutant 0:c0f3bbab73d2 232
Jerome Coutant 0:c0f3bbab73d2 233 /* Minimum distance while Moving Left and Moving Right gesture */
Jerome Coutant 0:c0f3bbab73d2 234 #define FT6206_DISTANCE_LEFT_RIGHT_REG 0x94
Jerome Coutant 0:c0f3bbab73d2 235
Jerome Coutant 0:c0f3bbab73d2 236 /* Minimum distance while Moving Up and Moving Down gesture */
Jerome Coutant 0:c0f3bbab73d2 237 #define FT6206_DISTANCE_UP_DOWN_REG 0x95
Jerome Coutant 0:c0f3bbab73d2 238
Jerome Coutant 0:c0f3bbab73d2 239 /* Maximum distance while Zoom In and Zoom Out gesture */
Jerome Coutant 0:c0f3bbab73d2 240 #define FT6206_DISTANCE_ZOOM_REG 0x96
Jerome Coutant 0:c0f3bbab73d2 241
Jerome Coutant 0:c0f3bbab73d2 242 /* High 8-bit of LIB Version info */
Jerome Coutant 0:c0f3bbab73d2 243 #define FT6206_LIB_VER_H_REG 0xA1
Jerome Coutant 0:c0f3bbab73d2 244
Jerome Coutant 0:c0f3bbab73d2 245 /* Low 8-bit of LIB Version info */
Jerome Coutant 0:c0f3bbab73d2 246 #define FT6206_LIB_VER_L_REG 0xA2
Jerome Coutant 0:c0f3bbab73d2 247
Jerome Coutant 0:c0f3bbab73d2 248 /* Chip Selecting */
Jerome Coutant 0:c0f3bbab73d2 249 #define FT6206_CIPHER_REG 0xA3
Jerome Coutant 0:c0f3bbab73d2 250
Jerome Coutant 0:c0f3bbab73d2 251 /* Interrupt mode register (used when in interrupt mode) */
Jerome Coutant 0:c0f3bbab73d2 252 #define FT6206_GMODE_REG 0xA4
Jerome Coutant 0:c0f3bbab73d2 253
Jerome Coutant 0:c0f3bbab73d2 254 #define FT6206_G_MODE_INTERRUPT_MASK 0x03
Jerome Coutant 0:c0f3bbab73d2 255 #define FT6206_G_MODE_INTERRUPT_SHIFT 0x00
Jerome Coutant 0:c0f3bbab73d2 256
Jerome Coutant 0:c0f3bbab73d2 257 /* Possible values of FT6206_GMODE_REG */
Jerome Coutant 0:c0f3bbab73d2 258 #define FT6206_G_MODE_INTERRUPT_POLLING 0x00
Jerome Coutant 0:c0f3bbab73d2 259 #define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01
Jerome Coutant 0:c0f3bbab73d2 260
Jerome Coutant 0:c0f3bbab73d2 261 /* Current power mode the FT6206 system is in (R) */
Jerome Coutant 0:c0f3bbab73d2 262 #define FT6206_PWR_MODE_REG 0xA5
Jerome Coutant 0:c0f3bbab73d2 263
Jerome Coutant 0:c0f3bbab73d2 264 /* FT6206 firmware version */
Jerome Coutant 0:c0f3bbab73d2 265 #define FT6206_FIRMID_REG 0xA6
Jerome Coutant 0:c0f3bbab73d2 266
Jerome Coutant 0:c0f3bbab73d2 267 /* FT6206 Chip identification register */
Jerome Coutant 0:c0f3bbab73d2 268 #define FT6206_CHIP_ID_REG 0xA8
Jerome Coutant 0:c0f3bbab73d2 269
Jerome Coutant 0:c0f3bbab73d2 270 /* Possible values of FT6206_CHIP_ID_REG */
Jerome Coutant 0:c0f3bbab73d2 271 #define FT6206_ID_VALUE 0x11
Jerome Coutant 0:c0f3bbab73d2 272 #define FT6x36_ID_VALUE 0xCD
Jerome Coutant 0:c0f3bbab73d2 273
Jerome Coutant 0:c0f3bbab73d2 274 /* Release code version */
Jerome Coutant 0:c0f3bbab73d2 275 #define FT6206_RELEASE_CODE_ID_REG 0xAF
Jerome Coutant 0:c0f3bbab73d2 276
Jerome Coutant 0:c0f3bbab73d2 277 /* Current operating mode the FT6206 system is in (R) */
Jerome Coutant 0:c0f3bbab73d2 278 #define FT6206_STATE_REG 0xBC
Jerome Coutant 0:c0f3bbab73d2 279
Jerome Coutant 0:c0f3bbab73d2 280 /**
Jerome Coutant 0:c0f3bbab73d2 281 * @}
Jerome Coutant 0:c0f3bbab73d2 282 */
Jerome Coutant 0:c0f3bbab73d2 283
Jerome Coutant 0:c0f3bbab73d2 284 /* Exported macro ------------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 285
Jerome Coutant 0:c0f3bbab73d2 286 /** @defgroup ft6x06_Exported_Macros
Jerome Coutant 0:c0f3bbab73d2 287 * @{
Jerome Coutant 0:c0f3bbab73d2 288 */
Jerome Coutant 0:c0f3bbab73d2 289
Jerome Coutant 0:c0f3bbab73d2 290 /* Exported functions --------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 291
Jerome Coutant 0:c0f3bbab73d2 292 /** @defgroup ft6x06_Exported_Functions
Jerome Coutant 0:c0f3bbab73d2 293 * @{
Jerome Coutant 0:c0f3bbab73d2 294 */
Jerome Coutant 0:c0f3bbab73d2 295
Jerome Coutant 0:c0f3bbab73d2 296 /**
Jerome Coutant 0:c0f3bbab73d2 297 * @brief ft6x06 Control functions
Jerome Coutant 0:c0f3bbab73d2 298 */
Jerome Coutant 0:c0f3bbab73d2 299
Jerome Coutant 0:c0f3bbab73d2 300
Jerome Coutant 0:c0f3bbab73d2 301 /**
Jerome Coutant 0:c0f3bbab73d2 302 * @brief Initialize the ft6x06 communication bus
Jerome Coutant 0:c0f3bbab73d2 303 * from MCU to FT6206 : ie I2C channel initialization (if required).
Jerome Coutant 0:c0f3bbab73d2 304 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 305 * @retval None
Jerome Coutant 0:c0f3bbab73d2 306 */
Jerome Coutant 0:c0f3bbab73d2 307 void ft6x06_Init(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 308
Jerome Coutant 0:c0f3bbab73d2 309 /**
Jerome Coutant 0:c0f3bbab73d2 310 * @brief Software Reset the ft6x06.
Jerome Coutant 0:c0f3bbab73d2 311 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 312 * @retval None
Jerome Coutant 0:c0f3bbab73d2 313 */
Jerome Coutant 0:c0f3bbab73d2 314 void ft6x06_Reset(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 315
Jerome Coutant 0:c0f3bbab73d2 316 /**
Jerome Coutant 0:c0f3bbab73d2 317 * @brief Read the ft6x06 device ID, pre intitalize I2C in case of need to be
Jerome Coutant 0:c0f3bbab73d2 318 * able to read the FT6206 device ID, and verify this is a FT6206.
Jerome Coutant 0:c0f3bbab73d2 319 * @param DeviceAddr: I2C FT6x06 Slave address.
Jerome Coutant 0:c0f3bbab73d2 320 * @retval The Device ID (two bytes).
Jerome Coutant 0:c0f3bbab73d2 321 */
Jerome Coutant 0:c0f3bbab73d2 322 uint16_t ft6x06_ReadID(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 323
Jerome Coutant 0:c0f3bbab73d2 324 /**
Jerome Coutant 0:c0f3bbab73d2 325 * @brief Configures the touch Screen IC device to start detecting touches
Jerome Coutant 0:c0f3bbab73d2 326 * @param DeviceAddr: Device address on communication Bus (I2C slave address).
Jerome Coutant 0:c0f3bbab73d2 327 * @retval None.
Jerome Coutant 0:c0f3bbab73d2 328 */
Jerome Coutant 0:c0f3bbab73d2 329 void ft6x06_TS_Start(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 330
Jerome Coutant 0:c0f3bbab73d2 331 /**
Jerome Coutant 0:c0f3bbab73d2 332 * @brief Return if there is touches detected or not.
Jerome Coutant 0:c0f3bbab73d2 333 * Try to detect new touches and forget the old ones (reset internal global
Jerome Coutant 0:c0f3bbab73d2 334 * variables).
Jerome Coutant 0:c0f3bbab73d2 335 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 336 * @retval : Number of active touches detected (can be 0, 1 or 2).
Jerome Coutant 0:c0f3bbab73d2 337 */
Jerome Coutant 0:c0f3bbab73d2 338 uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 339
Jerome Coutant 0:c0f3bbab73d2 340 /**
Jerome Coutant 0:c0f3bbab73d2 341 * @brief Get the touch screen X and Y positions values
Jerome Coutant 0:c0f3bbab73d2 342 * Manage multi touch thanks to touch Index global
Jerome Coutant 0:c0f3bbab73d2 343 * variable 'ft6x06_handle.currActiveTouchIdx'.
Jerome Coutant 0:c0f3bbab73d2 344 * @param DeviceAddr: Device address on communication Bus.
Jerome Coutant 0:c0f3bbab73d2 345 * @param X: Pointer to X position value
Jerome Coutant 0:c0f3bbab73d2 346 * @param Y: Pointer to Y position value
Jerome Coutant 0:c0f3bbab73d2 347 * @retval None.
Jerome Coutant 0:c0f3bbab73d2 348 */
Jerome Coutant 0:c0f3bbab73d2 349 void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
Jerome Coutant 0:c0f3bbab73d2 350
Jerome Coutant 0:c0f3bbab73d2 351 /**
Jerome Coutant 0:c0f3bbab73d2 352 * @brief Configure the FT6206 device to generate IT on given INT pin
Jerome Coutant 0:c0f3bbab73d2 353 * connected to MCU as EXTI.
Jerome Coutant 0:c0f3bbab73d2 354 * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 355 * @retval None
Jerome Coutant 0:c0f3bbab73d2 356 */
Jerome Coutant 0:c0f3bbab73d2 357 void ft6x06_TS_EnableIT(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 358
Jerome Coutant 0:c0f3bbab73d2 359 /**
Jerome Coutant 0:c0f3bbab73d2 360 * @brief Configure the FT6206 device to stop generating IT on the given INT pin
Jerome Coutant 0:c0f3bbab73d2 361 * connected to MCU as EXTI.
Jerome Coutant 0:c0f3bbab73d2 362 * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 363 * @retval None
Jerome Coutant 0:c0f3bbab73d2 364 */
Jerome Coutant 0:c0f3bbab73d2 365 void ft6x06_TS_DisableIT(uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 366
Jerome Coutant 0:c0f3bbab73d2 367 /**
Jerome Coutant 0:c0f3bbab73d2 368 * @brief Get IT status from FT6206 interrupt status registers
Jerome Coutant 0:c0f3bbab73d2 369 * Should be called Following an EXTI coming to the MCU to know the detailed
Jerome Coutant 0:c0f3bbab73d2 370 * reason of the interrupt.
Jerome Coutant 0:c0f3bbab73d2 371 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 372 * @retval TS interrupts status
Jerome Coutant 0:c0f3bbab73d2 373 */
Jerome Coutant 0:c0f3bbab73d2 374 uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 375
Jerome Coutant 0:c0f3bbab73d2 376 /**
Jerome Coutant 0:c0f3bbab73d2 377 * @brief Clear IT status in FT6206 interrupt status clear registers
Jerome Coutant 0:c0f3bbab73d2 378 * Should be called Following an EXTI coming to the MCU.
Jerome Coutant 0:c0f3bbab73d2 379 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
Jerome Coutant 0:c0f3bbab73d2 380 * @retval TS interrupts status
Jerome Coutant 0:c0f3bbab73d2 381 */
Jerome Coutant 0:c0f3bbab73d2 382 void ft6x06_TS_ClearIT (uint16_t DeviceAddr);
Jerome Coutant 0:c0f3bbab73d2 383
Jerome Coutant 0:c0f3bbab73d2 384 /**** NEW FEATURES enabled when Multi-touch support is enabled ****/
Jerome Coutant 0:c0f3bbab73d2 385
Jerome Coutant 0:c0f3bbab73d2 386 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
Jerome Coutant 0:c0f3bbab73d2 387
Jerome Coutant 0:c0f3bbab73d2 388 /**
Jerome Coutant 0:c0f3bbab73d2 389 * @brief Get the last touch gesture identification (zoom, move up/down...).
Jerome Coutant 0:c0f3bbab73d2 390 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
Jerome Coutant 0:c0f3bbab73d2 391 * @param pGestureId : Pointer to get last touch gesture Identification.
Jerome Coutant 0:c0f3bbab73d2 392 * @retval None.
Jerome Coutant 0:c0f3bbab73d2 393 */
Jerome Coutant 0:c0f3bbab73d2 394 void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
Jerome Coutant 0:c0f3bbab73d2 395
Jerome Coutant 0:c0f3bbab73d2 396 /**
Jerome Coutant 0:c0f3bbab73d2 397 * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
Jerome Coutant 0:c0f3bbab73d2 398 * This touch detailed information contains :
Jerome Coutant 0:c0f3bbab73d2 399 * - weight that was applied to this touch
Jerome Coutant 0:c0f3bbab73d2 400 * - sub-area of the touch in the touch panel
Jerome Coutant 0:c0f3bbab73d2 401 * - event of linked to the touch (press down, lift up, ...)
Jerome Coutant 0:c0f3bbab73d2 402 * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
Jerome Coutant 0:c0f3bbab73d2 403 * @param touchIdx : Passed index of the touch (0..1) on which we want to get the
Jerome Coutant 0:c0f3bbab73d2 404 * detailed information.
Jerome Coutant 0:c0f3bbab73d2 405 * @param pWeight : Pointer to to get the weight information of 'touchIdx'.
Jerome Coutant 0:c0f3bbab73d2 406 * @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
Jerome Coutant 0:c0f3bbab73d2 407 * @param pEvent : Pointer to to get the event information of 'touchIdx'.
Jerome Coutant 0:c0f3bbab73d2 408
Jerome Coutant 0:c0f3bbab73d2 409 * @retval None.
Jerome Coutant 0:c0f3bbab73d2 410 */
Jerome Coutant 0:c0f3bbab73d2 411 void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
Jerome Coutant 0:c0f3bbab73d2 412 uint32_t touchIdx,
Jerome Coutant 0:c0f3bbab73d2 413 uint32_t * pWeight,
Jerome Coutant 0:c0f3bbab73d2 414 uint32_t * pArea,
Jerome Coutant 0:c0f3bbab73d2 415 uint32_t * pEvent);
Jerome Coutant 0:c0f3bbab73d2 416
Jerome Coutant 0:c0f3bbab73d2 417 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
Jerome Coutant 0:c0f3bbab73d2 418
Jerome Coutant 0:c0f3bbab73d2 419 /* Imported TS IO functions --------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 420
Jerome Coutant 0:c0f3bbab73d2 421 /** @defgroup ft6x06_Imported_Functions
Jerome Coutant 0:c0f3bbab73d2 422 * @{
Jerome Coutant 0:c0f3bbab73d2 423 */
Jerome Coutant 0:c0f3bbab73d2 424
Jerome Coutant 0:c0f3bbab73d2 425 /* TouchScreen (TS) external IO functions */
Jerome Coutant 0:c0f3bbab73d2 426 extern void TS_IO_Init(void);
Jerome Coutant 0:c0f3bbab73d2 427 extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
Jerome Coutant 0:c0f3bbab73d2 428 extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
Jerome Coutant 0:c0f3bbab73d2 429 extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
Jerome Coutant 0:c0f3bbab73d2 430 extern void TS_IO_Delay(uint32_t Delay);
Jerome Coutant 0:c0f3bbab73d2 431
Jerome Coutant 0:c0f3bbab73d2 432 /**
Jerome Coutant 0:c0f3bbab73d2 433 * @}
Jerome Coutant 0:c0f3bbab73d2 434 */
Jerome Coutant 0:c0f3bbab73d2 435
Jerome Coutant 0:c0f3bbab73d2 436 /* Imported global variables --------------------------------------------------------*/
Jerome Coutant 0:c0f3bbab73d2 437
Jerome Coutant 0:c0f3bbab73d2 438 /** @defgroup ft6x06_Imported_Globals
Jerome Coutant 0:c0f3bbab73d2 439 * @{
Jerome Coutant 0:c0f3bbab73d2 440 */
Jerome Coutant 0:c0f3bbab73d2 441
Jerome Coutant 0:c0f3bbab73d2 442
Jerome Coutant 0:c0f3bbab73d2 443 /* Touch screen driver structure */
Jerome Coutant 0:c0f3bbab73d2 444 extern TS_DrvTypeDef ft6x06_ts_drv;
Jerome Coutant 0:c0f3bbab73d2 445
Jerome Coutant 0:c0f3bbab73d2 446 /**
Jerome Coutant 0:c0f3bbab73d2 447 * @}
Jerome Coutant 0:c0f3bbab73d2 448 */
Jerome Coutant 0:c0f3bbab73d2 449
Jerome Coutant 0:c0f3bbab73d2 450 #ifdef __cplusplus
Jerome Coutant 0:c0f3bbab73d2 451 }
Jerome Coutant 0:c0f3bbab73d2 452 #endif
Jerome Coutant 0:c0f3bbab73d2 453 #endif /* __FT6X06_H */
Jerome Coutant 0:c0f3bbab73d2 454
Jerome Coutant 0:c0f3bbab73d2 455
Jerome Coutant 0:c0f3bbab73d2 456 /**
Jerome Coutant 0:c0f3bbab73d2 457 * @}
Jerome Coutant 0:c0f3bbab73d2 458 */
Jerome Coutant 0:c0f3bbab73d2 459
Jerome Coutant 0:c0f3bbab73d2 460 /**
Jerome Coutant 0:c0f3bbab73d2 461 * @}
Jerome Coutant 0:c0f3bbab73d2 462 */
Jerome Coutant 0:c0f3bbab73d2 463
Jerome Coutant 0:c0f3bbab73d2 464 /**
Jerome Coutant 0:c0f3bbab73d2 465 * @}
Jerome Coutant 0:c0f3bbab73d2 466 */
Jerome Coutant 0:c0f3bbab73d2 467
Jerome Coutant 0:c0f3bbab73d2 468 /**
Jerome Coutant 0:c0f3bbab73d2 469 * @}
Jerome Coutant 0:c0f3bbab73d2 470 */
Jerome Coutant 0:c0f3bbab73d2 471 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/