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