Library to control Silicon Labs SI570 10 MHZ TO 1.4 GHZ I2C PROGRAMMABLE XO/VCXO.

Dependencies:   mbed

Fork of SI570 by Gerrit Polder

Committer:
DL3LD
Date:
Sun Mar 27 06:55:59 2016 +0000
Revision:
1:1556bcaaf759
STM32F746NG SI570 VFO Test

Who changed what in which revision?

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