This demo reads a bitmap from a FAT formatted SD-card, copies it to flash and displays it on the screen. The demo is based on the following project: https://os.mbed.com/users/DieterGraef/code/DISCO-F746NG_SDFileSystem/

Dependencies:   LCD_DISCO_F746NG TS_DISCO_F746NG mbed FATFileSystem

Fork of DISCO-F746NG_SDFileSystem by Dieter Graef

Committer:
Lightsource
Date:
Thu Apr 19 19:59:54 2018 +0000
Revision:
4:95e30a911d97
Demo that reads a bitmap from SD-card, copies it to flash and displays it on the screen.

Who changed what in which revision?

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