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