Clone
Dependents: SignalProcessLab DigitalSignalAlgorithm_Lab DigitalSignal_Lab
Drivers/BSP/Components/ft5336/ft5336.c@0:fc80425b677a, 2019-08-26 (annotated)
- Committer:
- ngtkien
- Date:
- Mon Aug 26 16:33:09 2019 +0000
- Revision:
- 0:fc80425b677a
Library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ngtkien | 0:fc80425b677a | 1 | /** |
ngtkien | 0:fc80425b677a | 2 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 3 | * @file ft5336.c |
ngtkien | 0:fc80425b677a | 4 | * @author MCD Application Team |
ngtkien | 0:fc80425b677a | 5 | * @version V1.0.0 |
ngtkien | 0:fc80425b677a | 6 | * @date 25-June-2015 |
ngtkien | 0:fc80425b677a | 7 | * @brief This file provides a set of functions needed to manage the FT5336 |
ngtkien | 0:fc80425b677a | 8 | * touch screen devices. |
ngtkien | 0:fc80425b677a | 9 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 10 | * @attention |
ngtkien | 0:fc80425b677a | 11 | * |
ngtkien | 0:fc80425b677a | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
ngtkien | 0:fc80425b677a | 13 | * |
ngtkien | 0:fc80425b677a | 14 | * Redistribution and use in source and binary forms, with or without modification, |
ngtkien | 0:fc80425b677a | 15 | * are permitted provided that the following conditions are met: |
ngtkien | 0:fc80425b677a | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
ngtkien | 0:fc80425b677a | 17 | * this list of conditions and the following disclaimer. |
ngtkien | 0:fc80425b677a | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
ngtkien | 0:fc80425b677a | 19 | * this list of conditions and the following disclaimer in the documentation |
ngtkien | 0:fc80425b677a | 20 | * and/or other materials provided with the distribution. |
ngtkien | 0:fc80425b677a | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
ngtkien | 0:fc80425b677a | 22 | * may be used to endorse or promote products derived from this software |
ngtkien | 0:fc80425b677a | 23 | * without specific prior written permission. |
ngtkien | 0:fc80425b677a | 24 | * |
ngtkien | 0:fc80425b677a | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ngtkien | 0:fc80425b677a | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ngtkien | 0:fc80425b677a | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
ngtkien | 0:fc80425b677a | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
ngtkien | 0:fc80425b677a | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
ngtkien | 0:fc80425b677a | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
ngtkien | 0:fc80425b677a | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
ngtkien | 0:fc80425b677a | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
ngtkien | 0:fc80425b677a | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
ngtkien | 0:fc80425b677a | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ngtkien | 0:fc80425b677a | 35 | * |
ngtkien | 0:fc80425b677a | 36 | ****************************************************************************** |
ngtkien | 0:fc80425b677a | 37 | */ |
ngtkien | 0:fc80425b677a | 38 | |
ngtkien | 0:fc80425b677a | 39 | /* Includes ------------------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 40 | #include "ft5336.h" |
ngtkien | 0:fc80425b677a | 41 | |
ngtkien | 0:fc80425b677a | 42 | /** @addtogroup BSP |
ngtkien | 0:fc80425b677a | 43 | * @{ |
ngtkien | 0:fc80425b677a | 44 | */ |
ngtkien | 0:fc80425b677a | 45 | |
ngtkien | 0:fc80425b677a | 46 | /** @addtogroup Component |
ngtkien | 0:fc80425b677a | 47 | * @{ |
ngtkien | 0:fc80425b677a | 48 | */ |
ngtkien | 0:fc80425b677a | 49 | |
ngtkien | 0:fc80425b677a | 50 | /** @defgroup FT5336 |
ngtkien | 0:fc80425b677a | 51 | * @{ |
ngtkien | 0:fc80425b677a | 52 | */ |
ngtkien | 0:fc80425b677a | 53 | |
ngtkien | 0:fc80425b677a | 54 | /* Private typedef -----------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 55 | |
ngtkien | 0:fc80425b677a | 56 | /** @defgroup FT5336_Private_Types_Definitions |
ngtkien | 0:fc80425b677a | 57 | * @{ |
ngtkien | 0:fc80425b677a | 58 | */ |
ngtkien | 0:fc80425b677a | 59 | |
ngtkien | 0:fc80425b677a | 60 | /* Private define ------------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 61 | |
ngtkien | 0:fc80425b677a | 62 | /** @defgroup FT5336_Private_Defines |
ngtkien | 0:fc80425b677a | 63 | * @{ |
ngtkien | 0:fc80425b677a | 64 | */ |
ngtkien | 0:fc80425b677a | 65 | |
ngtkien | 0:fc80425b677a | 66 | /* Private macro -------------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 67 | |
ngtkien | 0:fc80425b677a | 68 | /** @defgroup FT5336_Private_Macros |
ngtkien | 0:fc80425b677a | 69 | * @{ |
ngtkien | 0:fc80425b677a | 70 | */ |
ngtkien | 0:fc80425b677a | 71 | |
ngtkien | 0:fc80425b677a | 72 | /* Private variables ---------------------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 73 | |
ngtkien | 0:fc80425b677a | 74 | /** @defgroup FT5336_Private_Variables |
ngtkien | 0:fc80425b677a | 75 | * @{ |
ngtkien | 0:fc80425b677a | 76 | */ |
ngtkien | 0:fc80425b677a | 77 | |
ngtkien | 0:fc80425b677a | 78 | /* Touch screen driver structure initialization */ |
ngtkien | 0:fc80425b677a | 79 | TS_DrvTypeDef ft5336_ts_drv = |
ngtkien | 0:fc80425b677a | 80 | { |
ngtkien | 0:fc80425b677a | 81 | ft5336_Init, |
ngtkien | 0:fc80425b677a | 82 | ft5336_ReadID, |
ngtkien | 0:fc80425b677a | 83 | ft5336_Reset, |
ngtkien | 0:fc80425b677a | 84 | |
ngtkien | 0:fc80425b677a | 85 | ft5336_TS_Start, |
ngtkien | 0:fc80425b677a | 86 | ft5336_TS_DetectTouch, |
ngtkien | 0:fc80425b677a | 87 | ft5336_TS_GetXY, |
ngtkien | 0:fc80425b677a | 88 | |
ngtkien | 0:fc80425b677a | 89 | ft5336_TS_EnableIT, |
ngtkien | 0:fc80425b677a | 90 | ft5336_TS_ClearIT, |
ngtkien | 0:fc80425b677a | 91 | ft5336_TS_ITStatus, |
ngtkien | 0:fc80425b677a | 92 | ft5336_TS_DisableIT |
ngtkien | 0:fc80425b677a | 93 | |
ngtkien | 0:fc80425b677a | 94 | }; |
ngtkien | 0:fc80425b677a | 95 | |
ngtkien | 0:fc80425b677a | 96 | /* Global ft5336 handle */ |
ngtkien | 0:fc80425b677a | 97 | static ft5336_handle_TypeDef ft5336_handle = { FT5336_I2C_NOT_INITIALIZED, 0, 0}; |
ngtkien | 0:fc80425b677a | 98 | |
ngtkien | 0:fc80425b677a | 99 | /** |
ngtkien | 0:fc80425b677a | 100 | * @} |
ngtkien | 0:fc80425b677a | 101 | */ |
ngtkien | 0:fc80425b677a | 102 | |
ngtkien | 0:fc80425b677a | 103 | /** @defgroup ft5336_Private_Function_Prototypes |
ngtkien | 0:fc80425b677a | 104 | * @{ |
ngtkien | 0:fc80425b677a | 105 | */ |
ngtkien | 0:fc80425b677a | 106 | |
ngtkien | 0:fc80425b677a | 107 | /* Private functions prototypes-----------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 108 | |
ngtkien | 0:fc80425b677a | 109 | /** |
ngtkien | 0:fc80425b677a | 110 | * @brief Return the status of I2C was initialized or not. |
ngtkien | 0:fc80425b677a | 111 | * @param None. |
ngtkien | 0:fc80425b677a | 112 | * @retval : I2C initialization status. |
ngtkien | 0:fc80425b677a | 113 | */ |
ngtkien | 0:fc80425b677a | 114 | static uint8_t ft5336_Get_I2C_InitializedStatus(void); |
ngtkien | 0:fc80425b677a | 115 | |
ngtkien | 0:fc80425b677a | 116 | /** |
ngtkien | 0:fc80425b677a | 117 | * @brief I2C initialize if needed. |
ngtkien | 0:fc80425b677a | 118 | * @param None. |
ngtkien | 0:fc80425b677a | 119 | * @retval : None. |
ngtkien | 0:fc80425b677a | 120 | */ |
ngtkien | 0:fc80425b677a | 121 | static void ft5336_I2C_InitializeIfRequired(void); |
ngtkien | 0:fc80425b677a | 122 | |
ngtkien | 0:fc80425b677a | 123 | /** |
ngtkien | 0:fc80425b677a | 124 | * @brief Basic static configuration of TouchScreen |
ngtkien | 0:fc80425b677a | 125 | * @param DeviceAddr: FT5336 Device address for communication on I2C Bus. |
ngtkien | 0:fc80425b677a | 126 | * @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK. |
ngtkien | 0:fc80425b677a | 127 | */ |
ngtkien | 0:fc80425b677a | 128 | static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr); |
ngtkien | 0:fc80425b677a | 129 | |
ngtkien | 0:fc80425b677a | 130 | /** @defgroup ft5336_Private_Functions |
ngtkien | 0:fc80425b677a | 131 | * @{ |
ngtkien | 0:fc80425b677a | 132 | */ |
ngtkien | 0:fc80425b677a | 133 | |
ngtkien | 0:fc80425b677a | 134 | /** @defgroup ft5336_Public_Function_Body |
ngtkien | 0:fc80425b677a | 135 | * @{ |
ngtkien | 0:fc80425b677a | 136 | */ |
ngtkien | 0:fc80425b677a | 137 | |
ngtkien | 0:fc80425b677a | 138 | /* Public functions bodies-----------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 139 | |
ngtkien | 0:fc80425b677a | 140 | |
ngtkien | 0:fc80425b677a | 141 | /** |
ngtkien | 0:fc80425b677a | 142 | * @brief Initialize the ft5336 communication bus |
ngtkien | 0:fc80425b677a | 143 | * from MCU to FT5336 : ie I2C channel initialization (if required). |
ngtkien | 0:fc80425b677a | 144 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 145 | * @retval None |
ngtkien | 0:fc80425b677a | 146 | */ |
ngtkien | 0:fc80425b677a | 147 | void ft5336_Init(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 148 | { |
ngtkien | 0:fc80425b677a | 149 | /* Wait at least 200ms after power up before accessing registers |
ngtkien | 0:fc80425b677a | 150 | * Trsi timing (Time of starting to report point after resetting) from FT5336GQQ datasheet */ |
ngtkien | 0:fc80425b677a | 151 | TS_IO_Delay(200); |
ngtkien | 0:fc80425b677a | 152 | |
ngtkien | 0:fc80425b677a | 153 | /* Initialize I2C link if needed */ |
ngtkien | 0:fc80425b677a | 154 | ft5336_I2C_InitializeIfRequired(); |
ngtkien | 0:fc80425b677a | 155 | } |
ngtkien | 0:fc80425b677a | 156 | |
ngtkien | 0:fc80425b677a | 157 | /** |
ngtkien | 0:fc80425b677a | 158 | * @brief Software Reset the ft5336. |
ngtkien | 0:fc80425b677a | 159 | * @note : Not applicable to FT5336. |
ngtkien | 0:fc80425b677a | 160 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 161 | * @retval None |
ngtkien | 0:fc80425b677a | 162 | */ |
ngtkien | 0:fc80425b677a | 163 | void ft5336_Reset(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 164 | { |
ngtkien | 0:fc80425b677a | 165 | /* Do nothing */ |
ngtkien | 0:fc80425b677a | 166 | /* No software reset sequence available in FT5336 IC */ |
ngtkien | 0:fc80425b677a | 167 | } |
ngtkien | 0:fc80425b677a | 168 | |
ngtkien | 0:fc80425b677a | 169 | /** |
ngtkien | 0:fc80425b677a | 170 | * @brief Read the ft5336 device ID, pre initialize I2C in case of need to be |
ngtkien | 0:fc80425b677a | 171 | * able to read the FT5336 device ID, and verify this is a FT5336. |
ngtkien | 0:fc80425b677a | 172 | * @param DeviceAddr: I2C FT5336 Slave address. |
ngtkien | 0:fc80425b677a | 173 | * @retval The Device ID (two bytes). |
ngtkien | 0:fc80425b677a | 174 | */ |
ngtkien | 0:fc80425b677a | 175 | uint16_t ft5336_ReadID(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 176 | { |
ngtkien | 0:fc80425b677a | 177 | volatile uint8_t ucReadId = 0; |
ngtkien | 0:fc80425b677a | 178 | uint8_t nbReadAttempts = 0; |
ngtkien | 0:fc80425b677a | 179 | uint8_t bFoundDevice = 0; /* Device not found by default */ |
ngtkien | 0:fc80425b677a | 180 | |
ngtkien | 0:fc80425b677a | 181 | /* Initialize I2C link if needed */ |
ngtkien | 0:fc80425b677a | 182 | ft5336_I2C_InitializeIfRequired(); |
ngtkien | 0:fc80425b677a | 183 | |
ngtkien | 0:fc80425b677a | 184 | /* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */ |
ngtkien | 0:fc80425b677a | 185 | for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++) |
ngtkien | 0:fc80425b677a | 186 | { |
ngtkien | 0:fc80425b677a | 187 | /* Read register FT5336_CHIP_ID_REG as DeviceID detection */ |
ngtkien | 0:fc80425b677a | 188 | ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG); |
ngtkien | 0:fc80425b677a | 189 | |
ngtkien | 0:fc80425b677a | 190 | /* Found the searched device ID ? */ |
ngtkien | 0:fc80425b677a | 191 | if(ucReadId == FT5336_ID_VALUE) |
ngtkien | 0:fc80425b677a | 192 | { |
ngtkien | 0:fc80425b677a | 193 | /* Set device as found */ |
ngtkien | 0:fc80425b677a | 194 | bFoundDevice = 1; |
ngtkien | 0:fc80425b677a | 195 | } |
ngtkien | 0:fc80425b677a | 196 | } |
ngtkien | 0:fc80425b677a | 197 | |
ngtkien | 0:fc80425b677a | 198 | /* Return the device ID value */ |
ngtkien | 0:fc80425b677a | 199 | return (ucReadId); |
ngtkien | 0:fc80425b677a | 200 | } |
ngtkien | 0:fc80425b677a | 201 | |
ngtkien | 0:fc80425b677a | 202 | /** |
ngtkien | 0:fc80425b677a | 203 | * @brief Configures the touch Screen IC device to start detecting touches |
ngtkien | 0:fc80425b677a | 204 | * @param DeviceAddr: Device address on communication Bus (I2C slave address). |
ngtkien | 0:fc80425b677a | 205 | * @retval None. |
ngtkien | 0:fc80425b677a | 206 | */ |
ngtkien | 0:fc80425b677a | 207 | void ft5336_TS_Start(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 208 | { |
ngtkien | 0:fc80425b677a | 209 | /* Minimum static configuration of FT5336 */ |
ngtkien | 0:fc80425b677a | 210 | FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr)); |
ngtkien | 0:fc80425b677a | 211 | |
ngtkien | 0:fc80425b677a | 212 | /* By default set FT5336 IC in Polling mode : no INT generation on FT5336 for new touch available */ |
ngtkien | 0:fc80425b677a | 213 | /* Note TS_INT is active low */ |
ngtkien | 0:fc80425b677a | 214 | ft5336_TS_DisableIT(DeviceAddr); |
ngtkien | 0:fc80425b677a | 215 | } |
ngtkien | 0:fc80425b677a | 216 | |
ngtkien | 0:fc80425b677a | 217 | /** |
ngtkien | 0:fc80425b677a | 218 | * @brief Return if there is touches detected or not. |
ngtkien | 0:fc80425b677a | 219 | * Try to detect new touches and forget the old ones (reset internal global |
ngtkien | 0:fc80425b677a | 220 | * variables). |
ngtkien | 0:fc80425b677a | 221 | * @param DeviceAddr: Device address on communication Bus. |
ngtkien | 0:fc80425b677a | 222 | * @retval : Number of active touches detected (can be 0, 1 or 2). |
ngtkien | 0:fc80425b677a | 223 | */ |
ngtkien | 0:fc80425b677a | 224 | uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 225 | { |
ngtkien | 0:fc80425b677a | 226 | volatile uint8_t nbTouch = 0; |
ngtkien | 0:fc80425b677a | 227 | |
ngtkien | 0:fc80425b677a | 228 | /* Read register FT5336_TD_STAT_REG to check number of touches detection */ |
ngtkien | 0:fc80425b677a | 229 | nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG); |
ngtkien | 0:fc80425b677a | 230 | nbTouch &= FT5336_TD_STAT_MASK; |
ngtkien | 0:fc80425b677a | 231 | |
ngtkien | 0:fc80425b677a | 232 | if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH) |
ngtkien | 0:fc80425b677a | 233 | { |
ngtkien | 0:fc80425b677a | 234 | /* If invalid number of touch detected, set it to zero */ |
ngtkien | 0:fc80425b677a | 235 | nbTouch = 0; |
ngtkien | 0:fc80425b677a | 236 | } |
ngtkien | 0:fc80425b677a | 237 | |
ngtkien | 0:fc80425b677a | 238 | /* Update ft5336 driver internal global : current number of active touches */ |
ngtkien | 0:fc80425b677a | 239 | ft5336_handle.currActiveTouchNb = nbTouch; |
ngtkien | 0:fc80425b677a | 240 | |
ngtkien | 0:fc80425b677a | 241 | /* Reset current active touch index on which to work on */ |
ngtkien | 0:fc80425b677a | 242 | ft5336_handle.currActiveTouchIdx = 0; |
ngtkien | 0:fc80425b677a | 243 | |
ngtkien | 0:fc80425b677a | 244 | return(nbTouch); |
ngtkien | 0:fc80425b677a | 245 | } |
ngtkien | 0:fc80425b677a | 246 | |
ngtkien | 0:fc80425b677a | 247 | /** |
ngtkien | 0:fc80425b677a | 248 | * @brief Get the touch screen X and Y positions values |
ngtkien | 0:fc80425b677a | 249 | * Manage multi touch thanks to touch Index global |
ngtkien | 0:fc80425b677a | 250 | * variable 'ft5336_handle.currActiveTouchIdx'. |
ngtkien | 0:fc80425b677a | 251 | * @param DeviceAddr: Device address on communication Bus. |
ngtkien | 0:fc80425b677a | 252 | * @param X: Pointer to X position value |
ngtkien | 0:fc80425b677a | 253 | * @param Y: Pointer to Y position value |
ngtkien | 0:fc80425b677a | 254 | * @retval None. |
ngtkien | 0:fc80425b677a | 255 | */ |
ngtkien | 0:fc80425b677a | 256 | void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y) |
ngtkien | 0:fc80425b677a | 257 | { |
ngtkien | 0:fc80425b677a | 258 | volatile uint8_t ucReadData = 0; |
ngtkien | 0:fc80425b677a | 259 | static uint16_t coord; |
ngtkien | 0:fc80425b677a | 260 | uint8_t regAddressXLow = 0; |
ngtkien | 0:fc80425b677a | 261 | uint8_t regAddressXHigh = 0; |
ngtkien | 0:fc80425b677a | 262 | uint8_t regAddressYLow = 0; |
ngtkien | 0:fc80425b677a | 263 | uint8_t regAddressYHigh = 0; |
ngtkien | 0:fc80425b677a | 264 | |
ngtkien | 0:fc80425b677a | 265 | if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) |
ngtkien | 0:fc80425b677a | 266 | { |
ngtkien | 0:fc80425b677a | 267 | switch(ft5336_handle.currActiveTouchIdx) |
ngtkien | 0:fc80425b677a | 268 | { |
ngtkien | 0:fc80425b677a | 269 | case 0 : |
ngtkien | 0:fc80425b677a | 270 | regAddressXLow = FT5336_P1_XL_REG; |
ngtkien | 0:fc80425b677a | 271 | regAddressXHigh = FT5336_P1_XH_REG; |
ngtkien | 0:fc80425b677a | 272 | regAddressYLow = FT5336_P1_YL_REG; |
ngtkien | 0:fc80425b677a | 273 | regAddressYHigh = FT5336_P1_YH_REG; |
ngtkien | 0:fc80425b677a | 274 | break; |
ngtkien | 0:fc80425b677a | 275 | |
ngtkien | 0:fc80425b677a | 276 | case 1 : |
ngtkien | 0:fc80425b677a | 277 | regAddressXLow = FT5336_P2_XL_REG; |
ngtkien | 0:fc80425b677a | 278 | regAddressXHigh = FT5336_P2_XH_REG; |
ngtkien | 0:fc80425b677a | 279 | regAddressYLow = FT5336_P2_YL_REG; |
ngtkien | 0:fc80425b677a | 280 | regAddressYHigh = FT5336_P2_YH_REG; |
ngtkien | 0:fc80425b677a | 281 | break; |
ngtkien | 0:fc80425b677a | 282 | |
ngtkien | 0:fc80425b677a | 283 | case 2 : |
ngtkien | 0:fc80425b677a | 284 | regAddressXLow = FT5336_P3_XL_REG; |
ngtkien | 0:fc80425b677a | 285 | regAddressXHigh = FT5336_P3_XH_REG; |
ngtkien | 0:fc80425b677a | 286 | regAddressYLow = FT5336_P3_YL_REG; |
ngtkien | 0:fc80425b677a | 287 | regAddressYHigh = FT5336_P3_YH_REG; |
ngtkien | 0:fc80425b677a | 288 | break; |
ngtkien | 0:fc80425b677a | 289 | |
ngtkien | 0:fc80425b677a | 290 | case 3 : |
ngtkien | 0:fc80425b677a | 291 | regAddressXLow = FT5336_P4_XL_REG; |
ngtkien | 0:fc80425b677a | 292 | regAddressXHigh = FT5336_P4_XH_REG; |
ngtkien | 0:fc80425b677a | 293 | regAddressYLow = FT5336_P4_YL_REG; |
ngtkien | 0:fc80425b677a | 294 | regAddressYHigh = FT5336_P4_YH_REG; |
ngtkien | 0:fc80425b677a | 295 | break; |
ngtkien | 0:fc80425b677a | 296 | |
ngtkien | 0:fc80425b677a | 297 | case 4 : |
ngtkien | 0:fc80425b677a | 298 | regAddressXLow = FT5336_P5_XL_REG; |
ngtkien | 0:fc80425b677a | 299 | regAddressXHigh = FT5336_P5_XH_REG; |
ngtkien | 0:fc80425b677a | 300 | regAddressYLow = FT5336_P5_YL_REG; |
ngtkien | 0:fc80425b677a | 301 | regAddressYHigh = FT5336_P5_YH_REG; |
ngtkien | 0:fc80425b677a | 302 | break; |
ngtkien | 0:fc80425b677a | 303 | |
ngtkien | 0:fc80425b677a | 304 | case 5 : |
ngtkien | 0:fc80425b677a | 305 | regAddressXLow = FT5336_P6_XL_REG; |
ngtkien | 0:fc80425b677a | 306 | regAddressXHigh = FT5336_P6_XH_REG; |
ngtkien | 0:fc80425b677a | 307 | regAddressYLow = FT5336_P6_YL_REG; |
ngtkien | 0:fc80425b677a | 308 | regAddressYHigh = FT5336_P6_YH_REG; |
ngtkien | 0:fc80425b677a | 309 | break; |
ngtkien | 0:fc80425b677a | 310 | |
ngtkien | 0:fc80425b677a | 311 | case 6 : |
ngtkien | 0:fc80425b677a | 312 | regAddressXLow = FT5336_P7_XL_REG; |
ngtkien | 0:fc80425b677a | 313 | regAddressXHigh = FT5336_P7_XH_REG; |
ngtkien | 0:fc80425b677a | 314 | regAddressYLow = FT5336_P7_YL_REG; |
ngtkien | 0:fc80425b677a | 315 | regAddressYHigh = FT5336_P7_YH_REG; |
ngtkien | 0:fc80425b677a | 316 | break; |
ngtkien | 0:fc80425b677a | 317 | |
ngtkien | 0:fc80425b677a | 318 | case 7 : |
ngtkien | 0:fc80425b677a | 319 | regAddressXLow = FT5336_P8_XL_REG; |
ngtkien | 0:fc80425b677a | 320 | regAddressXHigh = FT5336_P8_XH_REG; |
ngtkien | 0:fc80425b677a | 321 | regAddressYLow = FT5336_P8_YL_REG; |
ngtkien | 0:fc80425b677a | 322 | regAddressYHigh = FT5336_P8_YH_REG; |
ngtkien | 0:fc80425b677a | 323 | break; |
ngtkien | 0:fc80425b677a | 324 | |
ngtkien | 0:fc80425b677a | 325 | case 8 : |
ngtkien | 0:fc80425b677a | 326 | regAddressXLow = FT5336_P9_XL_REG; |
ngtkien | 0:fc80425b677a | 327 | regAddressXHigh = FT5336_P9_XH_REG; |
ngtkien | 0:fc80425b677a | 328 | regAddressYLow = FT5336_P9_YL_REG; |
ngtkien | 0:fc80425b677a | 329 | regAddressYHigh = FT5336_P9_YH_REG; |
ngtkien | 0:fc80425b677a | 330 | break; |
ngtkien | 0:fc80425b677a | 331 | |
ngtkien | 0:fc80425b677a | 332 | case 9 : |
ngtkien | 0:fc80425b677a | 333 | regAddressXLow = FT5336_P10_XL_REG; |
ngtkien | 0:fc80425b677a | 334 | regAddressXHigh = FT5336_P10_XH_REG; |
ngtkien | 0:fc80425b677a | 335 | regAddressYLow = FT5336_P10_YL_REG; |
ngtkien | 0:fc80425b677a | 336 | regAddressYHigh = FT5336_P10_YH_REG; |
ngtkien | 0:fc80425b677a | 337 | break; |
ngtkien | 0:fc80425b677a | 338 | |
ngtkien | 0:fc80425b677a | 339 | default : |
ngtkien | 0:fc80425b677a | 340 | break; |
ngtkien | 0:fc80425b677a | 341 | |
ngtkien | 0:fc80425b677a | 342 | } /* end switch(ft5336_handle.currActiveTouchIdx) */ |
ngtkien | 0:fc80425b677a | 343 | |
ngtkien | 0:fc80425b677a | 344 | /* Read low part of X position */ |
ngtkien | 0:fc80425b677a | 345 | ucReadData = TS_IO_Read(DeviceAddr, regAddressXLow); |
ngtkien | 0:fc80425b677a | 346 | coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT; |
ngtkien | 0:fc80425b677a | 347 | |
ngtkien | 0:fc80425b677a | 348 | /* Read high part of X position */ |
ngtkien | 0:fc80425b677a | 349 | ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh); |
ngtkien | 0:fc80425b677a | 350 | coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8; |
ngtkien | 0:fc80425b677a | 351 | |
ngtkien | 0:fc80425b677a | 352 | /* Send back ready X position to caller */ |
ngtkien | 0:fc80425b677a | 353 | *X = coord; |
ngtkien | 0:fc80425b677a | 354 | |
ngtkien | 0:fc80425b677a | 355 | /* Read low part of Y position */ |
ngtkien | 0:fc80425b677a | 356 | ucReadData = TS_IO_Read(DeviceAddr, regAddressYLow); |
ngtkien | 0:fc80425b677a | 357 | coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT; |
ngtkien | 0:fc80425b677a | 358 | |
ngtkien | 0:fc80425b677a | 359 | /* Read high part of Y position */ |
ngtkien | 0:fc80425b677a | 360 | ucReadData = TS_IO_Read(DeviceAddr, regAddressYHigh); |
ngtkien | 0:fc80425b677a | 361 | coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8; |
ngtkien | 0:fc80425b677a | 362 | |
ngtkien | 0:fc80425b677a | 363 | /* Send back ready Y position to caller */ |
ngtkien | 0:fc80425b677a | 364 | *Y = coord; |
ngtkien | 0:fc80425b677a | 365 | |
ngtkien | 0:fc80425b677a | 366 | ft5336_handle.currActiveTouchIdx++; /* next call will work on next touch */ |
ngtkien | 0:fc80425b677a | 367 | |
ngtkien | 0:fc80425b677a | 368 | } /* of if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) */ |
ngtkien | 0:fc80425b677a | 369 | } |
ngtkien | 0:fc80425b677a | 370 | |
ngtkien | 0:fc80425b677a | 371 | /** |
ngtkien | 0:fc80425b677a | 372 | * @brief Configure the FT5336 device to generate IT on given INT pin |
ngtkien | 0:fc80425b677a | 373 | * connected to MCU as EXTI. |
ngtkien | 0:fc80425b677a | 374 | * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336). |
ngtkien | 0:fc80425b677a | 375 | * @retval None |
ngtkien | 0:fc80425b677a | 376 | */ |
ngtkien | 0:fc80425b677a | 377 | void ft5336_TS_EnableIT(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 378 | { |
ngtkien | 0:fc80425b677a | 379 | uint8_t regValue = 0; |
ngtkien | 0:fc80425b677a | 380 | regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT; |
ngtkien | 0:fc80425b677a | 381 | |
ngtkien | 0:fc80425b677a | 382 | /* Set interrupt trigger mode in FT5336_GMODE_REG */ |
ngtkien | 0:fc80425b677a | 383 | TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue); |
ngtkien | 0:fc80425b677a | 384 | } |
ngtkien | 0:fc80425b677a | 385 | |
ngtkien | 0:fc80425b677a | 386 | /** |
ngtkien | 0:fc80425b677a | 387 | * @brief Configure the FT5336 device to stop generating IT on the given INT pin |
ngtkien | 0:fc80425b677a | 388 | * connected to MCU as EXTI. |
ngtkien | 0:fc80425b677a | 389 | * @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336). |
ngtkien | 0:fc80425b677a | 390 | * @retval None |
ngtkien | 0:fc80425b677a | 391 | */ |
ngtkien | 0:fc80425b677a | 392 | void ft5336_TS_DisableIT(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 393 | { |
ngtkien | 0:fc80425b677a | 394 | uint8_t regValue = 0; |
ngtkien | 0:fc80425b677a | 395 | regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT; |
ngtkien | 0:fc80425b677a | 396 | |
ngtkien | 0:fc80425b677a | 397 | /* Set interrupt polling mode in FT5336_GMODE_REG */ |
ngtkien | 0:fc80425b677a | 398 | TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue); |
ngtkien | 0:fc80425b677a | 399 | } |
ngtkien | 0:fc80425b677a | 400 | |
ngtkien | 0:fc80425b677a | 401 | /** |
ngtkien | 0:fc80425b677a | 402 | * @brief Get IT status from FT5336 interrupt status registers |
ngtkien | 0:fc80425b677a | 403 | * Should be called Following an EXTI coming to the MCU to know the detailed |
ngtkien | 0:fc80425b677a | 404 | * reason of the interrupt. |
ngtkien | 0:fc80425b677a | 405 | * @note : This feature is not applicable to FT5336. |
ngtkien | 0:fc80425b677a | 406 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 407 | * @retval TS interrupts status : always return 0 here |
ngtkien | 0:fc80425b677a | 408 | */ |
ngtkien | 0:fc80425b677a | 409 | uint8_t ft5336_TS_ITStatus(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 410 | { |
ngtkien | 0:fc80425b677a | 411 | /* Always return 0 as feature not applicable to FT5336 */ |
ngtkien | 0:fc80425b677a | 412 | return 0; |
ngtkien | 0:fc80425b677a | 413 | } |
ngtkien | 0:fc80425b677a | 414 | |
ngtkien | 0:fc80425b677a | 415 | /** |
ngtkien | 0:fc80425b677a | 416 | * @brief Clear IT status in FT5336 interrupt status clear registers |
ngtkien | 0:fc80425b677a | 417 | * Should be called Following an EXTI coming to the MCU. |
ngtkien | 0:fc80425b677a | 418 | * @note : This feature is not applicable to FT5336. |
ngtkien | 0:fc80425b677a | 419 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 420 | * @retval None |
ngtkien | 0:fc80425b677a | 421 | */ |
ngtkien | 0:fc80425b677a | 422 | void ft5336_TS_ClearIT(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 423 | { |
ngtkien | 0:fc80425b677a | 424 | /* Nothing to be done here for FT5336 */ |
ngtkien | 0:fc80425b677a | 425 | } |
ngtkien | 0:fc80425b677a | 426 | |
ngtkien | 0:fc80425b677a | 427 | /**** NEW FEATURES enabled when Multi-touch support is enabled ****/ |
ngtkien | 0:fc80425b677a | 428 | |
ngtkien | 0:fc80425b677a | 429 | #if (TS_MULTI_TOUCH_SUPPORTED == 1) |
ngtkien | 0:fc80425b677a | 430 | |
ngtkien | 0:fc80425b677a | 431 | /** |
ngtkien | 0:fc80425b677a | 432 | * @brief Get the last touch gesture identification (zoom, move up/down...). |
ngtkien | 0:fc80425b677a | 433 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 434 | * @param pGestureId : Pointer to get last touch gesture Identification. |
ngtkien | 0:fc80425b677a | 435 | * @retval None. |
ngtkien | 0:fc80425b677a | 436 | */ |
ngtkien | 0:fc80425b677a | 437 | void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId) |
ngtkien | 0:fc80425b677a | 438 | { |
ngtkien | 0:fc80425b677a | 439 | volatile uint8_t ucReadData = 0; |
ngtkien | 0:fc80425b677a | 440 | |
ngtkien | 0:fc80425b677a | 441 | ucReadData = TS_IO_Read(DeviceAddr, FT5336_GEST_ID_REG); |
ngtkien | 0:fc80425b677a | 442 | |
ngtkien | 0:fc80425b677a | 443 | * pGestureId = ucReadData; |
ngtkien | 0:fc80425b677a | 444 | } |
ngtkien | 0:fc80425b677a | 445 | |
ngtkien | 0:fc80425b677a | 446 | /** |
ngtkien | 0:fc80425b677a | 447 | * @brief Get the touch detailed informations on touch number 'touchIdx' (0..1) |
ngtkien | 0:fc80425b677a | 448 | * This touch detailed information contains : |
ngtkien | 0:fc80425b677a | 449 | * - weight that was applied to this touch |
ngtkien | 0:fc80425b677a | 450 | * - sub-area of the touch in the touch panel |
ngtkien | 0:fc80425b677a | 451 | * - event of linked to the touch (press down, lift up, ...) |
ngtkien | 0:fc80425b677a | 452 | * @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336). |
ngtkien | 0:fc80425b677a | 453 | * @param touchIdx : Passed index of the touch (0..1) on which we want to get the |
ngtkien | 0:fc80425b677a | 454 | * detailed information. |
ngtkien | 0:fc80425b677a | 455 | * @param pWeight : Pointer to to get the weight information of 'touchIdx'. |
ngtkien | 0:fc80425b677a | 456 | * @param pArea : Pointer to to get the sub-area information of 'touchIdx'. |
ngtkien | 0:fc80425b677a | 457 | * @param pEvent : Pointer to to get the event information of 'touchIdx'. |
ngtkien | 0:fc80425b677a | 458 | |
ngtkien | 0:fc80425b677a | 459 | * @retval None. |
ngtkien | 0:fc80425b677a | 460 | */ |
ngtkien | 0:fc80425b677a | 461 | void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr, |
ngtkien | 0:fc80425b677a | 462 | uint32_t touchIdx, |
ngtkien | 0:fc80425b677a | 463 | uint32_t * pWeight, |
ngtkien | 0:fc80425b677a | 464 | uint32_t * pArea, |
ngtkien | 0:fc80425b677a | 465 | uint32_t * pEvent) |
ngtkien | 0:fc80425b677a | 466 | { |
ngtkien | 0:fc80425b677a | 467 | volatile uint8_t ucReadData = 0; |
ngtkien | 0:fc80425b677a | 468 | uint8_t regAddressXHigh = 0; |
ngtkien | 0:fc80425b677a | 469 | uint8_t regAddressPWeight = 0; |
ngtkien | 0:fc80425b677a | 470 | uint8_t regAddressPMisc = 0; |
ngtkien | 0:fc80425b677a | 471 | |
ngtkien | 0:fc80425b677a | 472 | if(touchIdx < ft5336_handle.currActiveTouchNb) |
ngtkien | 0:fc80425b677a | 473 | { |
ngtkien | 0:fc80425b677a | 474 | switch(touchIdx) |
ngtkien | 0:fc80425b677a | 475 | { |
ngtkien | 0:fc80425b677a | 476 | case 0 : |
ngtkien | 0:fc80425b677a | 477 | regAddressXHigh = FT5336_P1_XH_REG; |
ngtkien | 0:fc80425b677a | 478 | regAddressPWeight = FT5336_P1_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 479 | regAddressPMisc = FT5336_P1_MISC_REG; |
ngtkien | 0:fc80425b677a | 480 | break; |
ngtkien | 0:fc80425b677a | 481 | |
ngtkien | 0:fc80425b677a | 482 | case 1 : |
ngtkien | 0:fc80425b677a | 483 | regAddressXHigh = FT5336_P2_XH_REG; |
ngtkien | 0:fc80425b677a | 484 | regAddressPWeight = FT5336_P2_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 485 | regAddressPMisc = FT5336_P2_MISC_REG; |
ngtkien | 0:fc80425b677a | 486 | break; |
ngtkien | 0:fc80425b677a | 487 | |
ngtkien | 0:fc80425b677a | 488 | case 2 : |
ngtkien | 0:fc80425b677a | 489 | regAddressXHigh = FT5336_P3_XH_REG; |
ngtkien | 0:fc80425b677a | 490 | regAddressPWeight = FT5336_P3_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 491 | regAddressPMisc = FT5336_P3_MISC_REG; |
ngtkien | 0:fc80425b677a | 492 | break; |
ngtkien | 0:fc80425b677a | 493 | |
ngtkien | 0:fc80425b677a | 494 | case 3 : |
ngtkien | 0:fc80425b677a | 495 | regAddressXHigh = FT5336_P4_XH_REG; |
ngtkien | 0:fc80425b677a | 496 | regAddressPWeight = FT5336_P4_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 497 | regAddressPMisc = FT5336_P4_MISC_REG; |
ngtkien | 0:fc80425b677a | 498 | break; |
ngtkien | 0:fc80425b677a | 499 | |
ngtkien | 0:fc80425b677a | 500 | case 4 : |
ngtkien | 0:fc80425b677a | 501 | regAddressXHigh = FT5336_P5_XH_REG; |
ngtkien | 0:fc80425b677a | 502 | regAddressPWeight = FT5336_P5_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 503 | regAddressPMisc = FT5336_P5_MISC_REG; |
ngtkien | 0:fc80425b677a | 504 | break; |
ngtkien | 0:fc80425b677a | 505 | |
ngtkien | 0:fc80425b677a | 506 | case 5 : |
ngtkien | 0:fc80425b677a | 507 | regAddressXHigh = FT5336_P6_XH_REG; |
ngtkien | 0:fc80425b677a | 508 | regAddressPWeight = FT5336_P6_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 509 | regAddressPMisc = FT5336_P6_MISC_REG; |
ngtkien | 0:fc80425b677a | 510 | break; |
ngtkien | 0:fc80425b677a | 511 | |
ngtkien | 0:fc80425b677a | 512 | case 6 : |
ngtkien | 0:fc80425b677a | 513 | regAddressXHigh = FT5336_P7_XH_REG; |
ngtkien | 0:fc80425b677a | 514 | regAddressPWeight = FT5336_P7_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 515 | regAddressPMisc = FT5336_P7_MISC_REG; |
ngtkien | 0:fc80425b677a | 516 | break; |
ngtkien | 0:fc80425b677a | 517 | |
ngtkien | 0:fc80425b677a | 518 | case 7 : |
ngtkien | 0:fc80425b677a | 519 | regAddressXHigh = FT5336_P8_XH_REG; |
ngtkien | 0:fc80425b677a | 520 | regAddressPWeight = FT5336_P8_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 521 | regAddressPMisc = FT5336_P8_MISC_REG; |
ngtkien | 0:fc80425b677a | 522 | break; |
ngtkien | 0:fc80425b677a | 523 | |
ngtkien | 0:fc80425b677a | 524 | case 8 : |
ngtkien | 0:fc80425b677a | 525 | regAddressXHigh = FT5336_P9_XH_REG; |
ngtkien | 0:fc80425b677a | 526 | regAddressPWeight = FT5336_P9_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 527 | regAddressPMisc = FT5336_P9_MISC_REG; |
ngtkien | 0:fc80425b677a | 528 | break; |
ngtkien | 0:fc80425b677a | 529 | |
ngtkien | 0:fc80425b677a | 530 | case 9 : |
ngtkien | 0:fc80425b677a | 531 | regAddressXHigh = FT5336_P10_XH_REG; |
ngtkien | 0:fc80425b677a | 532 | regAddressPWeight = FT5336_P10_WEIGHT_REG; |
ngtkien | 0:fc80425b677a | 533 | regAddressPMisc = FT5336_P10_MISC_REG; |
ngtkien | 0:fc80425b677a | 534 | break; |
ngtkien | 0:fc80425b677a | 535 | |
ngtkien | 0:fc80425b677a | 536 | default : |
ngtkien | 0:fc80425b677a | 537 | break; |
ngtkien | 0:fc80425b677a | 538 | |
ngtkien | 0:fc80425b677a | 539 | } /* end switch(touchIdx) */ |
ngtkien | 0:fc80425b677a | 540 | |
ngtkien | 0:fc80425b677a | 541 | /* Read Event Id of touch index */ |
ngtkien | 0:fc80425b677a | 542 | ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh); |
ngtkien | 0:fc80425b677a | 543 | * pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT; |
ngtkien | 0:fc80425b677a | 544 | |
ngtkien | 0:fc80425b677a | 545 | /* Read weight of touch index */ |
ngtkien | 0:fc80425b677a | 546 | ucReadData = TS_IO_Read(DeviceAddr, regAddressPWeight); |
ngtkien | 0:fc80425b677a | 547 | * pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT; |
ngtkien | 0:fc80425b677a | 548 | |
ngtkien | 0:fc80425b677a | 549 | /* Read area of touch index */ |
ngtkien | 0:fc80425b677a | 550 | ucReadData = TS_IO_Read(DeviceAddr, regAddressPMisc); |
ngtkien | 0:fc80425b677a | 551 | * pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT; |
ngtkien | 0:fc80425b677a | 552 | |
ngtkien | 0:fc80425b677a | 553 | } /* of if(touchIdx < ft5336_handle.currActiveTouchNb) */ |
ngtkien | 0:fc80425b677a | 554 | } |
ngtkien | 0:fc80425b677a | 555 | |
ngtkien | 0:fc80425b677a | 556 | #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */ |
ngtkien | 0:fc80425b677a | 557 | |
ngtkien | 0:fc80425b677a | 558 | /** @defgroup ft5336_Static_Function_Body |
ngtkien | 0:fc80425b677a | 559 | * @{ |
ngtkien | 0:fc80425b677a | 560 | */ |
ngtkien | 0:fc80425b677a | 561 | |
ngtkien | 0:fc80425b677a | 562 | /* Static functions bodies-----------------------------------------------*/ |
ngtkien | 0:fc80425b677a | 563 | |
ngtkien | 0:fc80425b677a | 564 | |
ngtkien | 0:fc80425b677a | 565 | /** |
ngtkien | 0:fc80425b677a | 566 | * @brief Return the status of I2C was initialized or not. |
ngtkien | 0:fc80425b677a | 567 | * @param None. |
ngtkien | 0:fc80425b677a | 568 | * @retval : I2C initialization status. |
ngtkien | 0:fc80425b677a | 569 | */ |
ngtkien | 0:fc80425b677a | 570 | static uint8_t ft5336_Get_I2C_InitializedStatus(void) |
ngtkien | 0:fc80425b677a | 571 | { |
ngtkien | 0:fc80425b677a | 572 | return(ft5336_handle.i2cInitialized); |
ngtkien | 0:fc80425b677a | 573 | } |
ngtkien | 0:fc80425b677a | 574 | |
ngtkien | 0:fc80425b677a | 575 | /** |
ngtkien | 0:fc80425b677a | 576 | * @brief I2C initialize if needed. |
ngtkien | 0:fc80425b677a | 577 | * @param None. |
ngtkien | 0:fc80425b677a | 578 | * @retval : None. |
ngtkien | 0:fc80425b677a | 579 | */ |
ngtkien | 0:fc80425b677a | 580 | static void ft5336_I2C_InitializeIfRequired(void) |
ngtkien | 0:fc80425b677a | 581 | { |
ngtkien | 0:fc80425b677a | 582 | if(ft5336_Get_I2C_InitializedStatus() == FT5336_I2C_NOT_INITIALIZED) |
ngtkien | 0:fc80425b677a | 583 | { |
ngtkien | 0:fc80425b677a | 584 | /* Initialize TS IO BUS layer (I2C) */ |
ngtkien | 0:fc80425b677a | 585 | TS_IO_Init(); |
ngtkien | 0:fc80425b677a | 586 | |
ngtkien | 0:fc80425b677a | 587 | /* Set state to initialized */ |
ngtkien | 0:fc80425b677a | 588 | ft5336_handle.i2cInitialized = FT5336_I2C_INITIALIZED; |
ngtkien | 0:fc80425b677a | 589 | } |
ngtkien | 0:fc80425b677a | 590 | } |
ngtkien | 0:fc80425b677a | 591 | |
ngtkien | 0:fc80425b677a | 592 | /** |
ngtkien | 0:fc80425b677a | 593 | * @brief Basic static configuration of TouchScreen |
ngtkien | 0:fc80425b677a | 594 | * @param DeviceAddr: FT5336 Device address for communication on I2C Bus. |
ngtkien | 0:fc80425b677a | 595 | * @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK. |
ngtkien | 0:fc80425b677a | 596 | */ |
ngtkien | 0:fc80425b677a | 597 | static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr) |
ngtkien | 0:fc80425b677a | 598 | { |
ngtkien | 0:fc80425b677a | 599 | uint32_t status = FT5336_STATUS_OK; |
ngtkien | 0:fc80425b677a | 600 | |
ngtkien | 0:fc80425b677a | 601 | /* Nothing special to be done for FT5336 */ |
ngtkien | 0:fc80425b677a | 602 | |
ngtkien | 0:fc80425b677a | 603 | return(status); |
ngtkien | 0:fc80425b677a | 604 | } |
ngtkien | 0:fc80425b677a | 605 | |
ngtkien | 0:fc80425b677a | 606 | /** |
ngtkien | 0:fc80425b677a | 607 | * @} |
ngtkien | 0:fc80425b677a | 608 | */ |
ngtkien | 0:fc80425b677a | 609 | |
ngtkien | 0:fc80425b677a | 610 | /** |
ngtkien | 0:fc80425b677a | 611 | * @} |
ngtkien | 0:fc80425b677a | 612 | */ |
ngtkien | 0:fc80425b677a | 613 | |
ngtkien | 0:fc80425b677a | 614 | /** |
ngtkien | 0:fc80425b677a | 615 | * @} |
ngtkien | 0:fc80425b677a | 616 | */ |
ngtkien | 0:fc80425b677a | 617 | |
ngtkien | 0:fc80425b677a | 618 | /** |
ngtkien | 0:fc80425b677a | 619 | * @} |
ngtkien | 0:fc80425b677a | 620 | */ |
ngtkien | 0:fc80425b677a | 621 | |
ngtkien | 0:fc80425b677a | 622 | /** |
ngtkien | 0:fc80425b677a | 623 | * @} |
ngtkien | 0:fc80425b677a | 624 | */ |
ngtkien | 0:fc80425b677a | 625 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |