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