Patched for Audio example - Add status check when DFSDM's filter and channel de-init.

Dependents:   DISCO_F413ZH-AUDIO-demo

The base repository is https://os.mbed.com/teams/ST/code/BSP_DISCO_F413ZH/. I've just added workaround patch for Audio-in demo on DISCO_F413ZH board(Microphone U16, U17)

Committer:
Daniel_Lee
Date:
Fri Jan 31 07:17:05 2020 +0000
Revision:
4:c051317d4051
Parent:
3:42b354f5069c
Patched for Audio example;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arostm 0:4af3ca173992 1 /**
arostm 0:4af3ca173992 2 ******************************************************************************
arostm 0:4af3ca173992 3 * @file stm32f413h_discovery_ts.c
arostm 0:4af3ca173992 4 * @author MCD Application Team
arostm 0:4af3ca173992 5 * @brief This file provides a set of functions needed to manage the Touch
arostm 0:4af3ca173992 6 * Screen on STM32F413h-DISCOVERY evaluation board.
arostm 0:4af3ca173992 7 ******************************************************************************
arostm 0:4af3ca173992 8 * @attention
arostm 0:4af3ca173992 9 *
arostm 0:4af3ca173992 10 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
arostm 0:4af3ca173992 11 *
arostm 0:4af3ca173992 12 * Redistribution and use in source and binary forms, with or without modification,
arostm 0:4af3ca173992 13 * are permitted provided that the following conditions are met:
arostm 0:4af3ca173992 14 * 1. Redistributions of source code must retain the above copyright notice,
arostm 0:4af3ca173992 15 * this list of conditions and the following disclaimer.
arostm 0:4af3ca173992 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
arostm 0:4af3ca173992 17 * this list of conditions and the following disclaimer in the documentation
arostm 0:4af3ca173992 18 * and/or other materials provided with the distribution.
arostm 0:4af3ca173992 19 * 3. Neither the name of STMicroelectronics nor the names of its contributors
arostm 0:4af3ca173992 20 * may be used to endorse or promote products derived from this software
arostm 0:4af3ca173992 21 * without specific prior written permission.
arostm 0:4af3ca173992 22 *
arostm 0:4af3ca173992 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
arostm 0:4af3ca173992 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
arostm 0:4af3ca173992 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
arostm 0:4af3ca173992 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
arostm 0:4af3ca173992 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
arostm 0:4af3ca173992 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
arostm 0:4af3ca173992 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
arostm 0:4af3ca173992 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
arostm 0:4af3ca173992 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
arostm 0:4af3ca173992 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
arostm 0:4af3ca173992 33 *
arostm 0:4af3ca173992 34 ******************************************************************************
arostm 0:4af3ca173992 35 */
arostm 0:4af3ca173992 36
arostm 0:4af3ca173992 37 /* File Info : -----------------------------------------------------------------
arostm 0:4af3ca173992 38 User NOTES
arostm 0:4af3ca173992 39 1. How To use this driver:
arostm 0:4af3ca173992 40 --------------------------
arostm 0:4af3ca173992 41 - This driver is used to drive the touch screen module of the STM32F413H-DISCOVERY
arostm 0:4af3ca173992 42 evaluation board on the FRIDA LCD mounted on MB1209 daughter board.
arostm 0:4af3ca173992 43 The touch screen driver IC is a FT6x36 type which share the same register naming
arostm 0:4af3ca173992 44 with FT6206 type.
arostm 0:4af3ca173992 45
arostm 0:4af3ca173992 46 2. Driver description:
arostm 0:4af3ca173992 47 ---------------------
arostm 0:4af3ca173992 48 + Initialization steps:
arostm 0:4af3ca173992 49 o Initialize the TS module using the BSP_TS_Init() function. This
arostm 0:4af3ca173992 50 function includes the MSP layer hardware resources initialization and the
arostm 0:4af3ca173992 51 communication layer configuration to start the TS use. The LCD size properties
arostm 0:4af3ca173992 52 (x and y) are passed as parameters.
arostm 0:4af3ca173992 53 o If TS interrupt mode is desired, you must configure the TS interrupt mode
arostm 0:4af3ca173992 54 by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated
arostm 0:4af3ca173992 55 as an external interrupt whenever a touch is detected.
arostm 0:4af3ca173992 56
arostm 0:4af3ca173992 57 + Touch screen use
arostm 0:4af3ca173992 58 o The touch screen state is captured whenever the function BSP_TS_GetState() is
arostm 0:4af3ca173992 59 used. This function returns information about the last LCD touch occurred
arostm 0:4af3ca173992 60 in the TS_StateTypeDef structure.
arostm 0:4af3ca173992 61 ------------------------------------------------------------------------------*/
arostm 0:4af3ca173992 62
arostm 0:4af3ca173992 63 /* Includes ------------------------------------------------------------------*/
arostm 0:4af3ca173992 64 #include "stm32f413h_discovery.h"
arostm 0:4af3ca173992 65 #include "stm32f413h_discovery_ts.h"
arostm 0:4af3ca173992 66
arostm 0:4af3ca173992 67 /** @addtogroup BSP
arostm 0:4af3ca173992 68 * @{
arostm 0:4af3ca173992 69 */
arostm 0:4af3ca173992 70
arostm 0:4af3ca173992 71 /** @addtogroup STM32F413H_DISCOVERY
arostm 0:4af3ca173992 72 * @{
arostm 0:4af3ca173992 73 */
arostm 0:4af3ca173992 74
arostm 0:4af3ca173992 75 /** @defgroup STM32F413H_DISCOVERY_TS STM32F413H_DISCOVERY TS
arostm 0:4af3ca173992 76 * @{
arostm 0:4af3ca173992 77 */
arostm 0:4af3ca173992 78
arostm 0:4af3ca173992 79 /** @defgroup STM32F413H_DISCOVERY_TS_Private_Variables STM32F413H DISCOVERY TS Private Variables
arostm 0:4af3ca173992 80 * @{
arostm 0:4af3ca173992 81 */
arostm 0:4af3ca173992 82 static TS_DrvTypeDef *tsDriver;
arostm 0:4af3ca173992 83 static uint8_t I2C_Address = 0;
arostm 0:4af3ca173992 84 static uint8_t tsOrientation = TS_SWAP_NONE;
arostm 0:4af3ca173992 85
arostm 0:4af3ca173992 86 /* Table for touchscreen event information display on LCD : table indexed on enum @ref TS_TouchEventTypeDef information */
arostm 0:4af3ca173992 87 char * ts_event_string_tab[TOUCH_EVENT_NB_MAX] = { "None",
arostm 0:4af3ca173992 88 "Press down",
arostm 0:4af3ca173992 89 "Lift up",
arostm 0:4af3ca173992 90 "Contact"
arostm 0:4af3ca173992 91 };
arostm 0:4af3ca173992 92
arostm 0:4af3ca173992 93 /* Table for touchscreen gesture Id information display on LCD : table indexed on enum @ref TS_GestureIdTypeDef information */
arostm 0:4af3ca173992 94 char * ts_gesture_id_string_tab[GEST_ID_NB_MAX] = { "None",
arostm 0:4af3ca173992 95 "Move Up",
arostm 0:4af3ca173992 96 "Move Right",
arostm 0:4af3ca173992 97 "Move Down",
arostm 0:4af3ca173992 98 "Move Left",
arostm 0:4af3ca173992 99 "Zoom In",
arostm 0:4af3ca173992 100 "Zoom Out"
arostm 0:4af3ca173992 101 };
arostm 0:4af3ca173992 102 /**
arostm 0:4af3ca173992 103 * @}
arostm 0:4af3ca173992 104 */
arostm 0:4af3ca173992 105
arostm 0:4af3ca173992 106 /** @defgroup STM32F413H_DISCOVERY_TS_Private_Functions STM32F413H DISCOVERY TS Private Functions
arostm 0:4af3ca173992 107 * @{
arostm 0:4af3ca173992 108 */
arostm 0:4af3ca173992 109 /**
arostm 0:4af3ca173992 110 * @brief Initializes and configures the touch screen functionalities and
arostm 0:4af3ca173992 111 * configures all necessary hardware resources (GPIOs, I2C, clocks..).
arostm 0:4af3ca173992 112 * @param ts_SizeX : Maximum X size of the TS area on LCD
arostm 0:4af3ca173992 113 * @param ts_SizeY : Maximum Y size of the TS area on LCD
arostm 0:4af3ca173992 114 * @retval TS_OK if all initializations are OK. Other value if error.
arostm 0:4af3ca173992 115 */
arostm 0:4af3ca173992 116 uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY)
arostm 0:4af3ca173992 117 {
arostm 0:4af3ca173992 118 return (BSP_TS_InitEx(ts_SizeX, ts_SizeY, TS_ORIENTATION_LANDSCAPE));
arostm 0:4af3ca173992 119 }
arostm 0:4af3ca173992 120
arostm 0:4af3ca173992 121 /**
arostm 0:4af3ca173992 122 * @brief Initializes and configures the touch screen functionalities and
arostm 0:4af3ca173992 123 * configures all necessary hardware resources (GPIOs, I2C, clocks..)
arostm 0:4af3ca173992 124 * with a given orientation
arostm 0:4af3ca173992 125 * @param ts_SizeX : Maximum X size of the TS area on LCD
arostm 0:4af3ca173992 126 * @param ts_SizeY : Maximum Y size of the TS area on LCD
arostm 0:4af3ca173992 127 * @param orientation : TS_ORIENTATION_LANDSCAPE or TS_ORIENTATION_PORTRAIT
arostm 0:4af3ca173992 128 * @retval TS_OK if all initializations are OK. Other value if error.
arostm 0:4af3ca173992 129 */
arostm 0:4af3ca173992 130 uint8_t BSP_TS_InitEx(uint16_t ts_SizeX, uint16_t ts_SizeY, uint8_t orientation)
arostm 0:4af3ca173992 131 {
arostm 0:4af3ca173992 132 uint8_t ts_status = TS_OK;
arostm 0:4af3ca173992 133
arostm 0:4af3ca173992 134 /* Note : I2C_Address is un-initialized here, but is not used at all in init function */
arostm 0:4af3ca173992 135 /* but the prototype of Init() is like that in template and should be respected */
arostm 0:4af3ca173992 136
arostm 0:4af3ca173992 137 /* Initialize the communication channel to sensor (I2C) if necessary */
arostm 0:4af3ca173992 138 /* that is initialization is done only once after a power up */
arostm 0:4af3ca173992 139 ft6x06_ts_drv.Init(I2C_Address);
arostm 0:4af3ca173992 140
arostm 0:4af3ca173992 141 /* Scan FT6x36 TouchScreen IC controller ID register by I2C Read */
arostm 0:4af3ca173992 142 /* Verify this is a FT6x36, otherwise this is an error case */
arostm 0:4af3ca173992 143
arostm 0:4af3ca173992 144 if(ft6x06_ts_drv.ReadID(TS_I2C_ADDRESS) == FT6x36_ID_VALUE)
arostm 0:4af3ca173992 145 {
arostm 0:4af3ca173992 146 /* Found FT6x36 : Initialize the TS driver structure */
arostm 0:4af3ca173992 147 tsDriver = &ft6x06_ts_drv;
arostm 0:4af3ca173992 148
arostm 0:4af3ca173992 149 I2C_Address = TS_I2C_ADDRESS;
arostm 0:4af3ca173992 150
arostm 0:4af3ca173992 151 /* Get LCD chosen orientation */
arostm 0:4af3ca173992 152 if(orientation == TS_ORIENTATION_PORTRAIT)
arostm 0:4af3ca173992 153 {
arostm 0:4af3ca173992 154 tsOrientation = TS_SWAP_Y;
arostm 0:4af3ca173992 155 }
arostm 0:4af3ca173992 156 else if(orientation == TS_ORIENTATION_LANDSCAPE_ROT180)
arostm 0:4af3ca173992 157 {
arostm 0:4af3ca173992 158 tsOrientation = TS_SWAP_XY;
arostm 0:4af3ca173992 159 }
arostm 0:4af3ca173992 160 else
arostm 0:4af3ca173992 161 {
arostm 0:4af3ca173992 162 tsOrientation = TS_SWAP_XY | TS_SWAP_Y;
arostm 0:4af3ca173992 163 }
arostm 0:4af3ca173992 164
arostm 0:4af3ca173992 165
arostm 0:4af3ca173992 166 if(ts_status == TS_OK)
arostm 0:4af3ca173992 167 {
arostm 0:4af3ca173992 168 /* Software reset the TouchScreen */
arostm 0:4af3ca173992 169 tsDriver->Reset(I2C_Address);
arostm 0:4af3ca173992 170
arostm 0:4af3ca173992 171 /* Calibrate, Configure and Start the TouchScreen driver */
arostm 0:4af3ca173992 172 tsDriver->Start(I2C_Address);
arostm 0:4af3ca173992 173
arostm 0:4af3ca173992 174 } /* of if(ts_status == TS_OK) */
arostm 0:4af3ca173992 175 }
arostm 0:4af3ca173992 176 else
arostm 0:4af3ca173992 177 {
arostm 0:4af3ca173992 178 ts_status = TS_DEVICE_NOT_FOUND;
arostm 0:4af3ca173992 179 }
arostm 0:4af3ca173992 180
arostm 0:4af3ca173992 181 return (ts_status);
arostm 0:4af3ca173992 182 }
arostm 0:4af3ca173992 183
arostm 0:4af3ca173992 184 /**
arostm 0:4af3ca173992 185 * @brief Configures and enables the touch screen interrupts.
arostm 0:4af3ca173992 186 * @retval TS_OK if all initializations are OK. Other value if error.
arostm 0:4af3ca173992 187 */
arostm 0:4af3ca173992 188 uint8_t BSP_TS_ITConfig(void)
arostm 0:4af3ca173992 189 {
arostm 0:4af3ca173992 190 uint8_t ts_status = TS_OK;
arostm 0:4af3ca173992 191
arostm 0:4af3ca173992 192 /* Msp Init of GPIO used for TS_INT pin coming from TouchScreen driver IC FT6x36 */
arostm 0:4af3ca173992 193 /* When touchscreen is operated in interrupt mode */
arostm 0:4af3ca173992 194 BSP_TS_INT_MspInit();
arostm 0:4af3ca173992 195
arostm 0:4af3ca173992 196 /* Enable and set the TS_INT EXTI Interrupt to an intermediate priority */
arostm 0:4af3ca173992 197 HAL_NVIC_SetPriority((IRQn_Type)(TS_INT_EXTI_IRQn), 0x0F, 0x00);
arostm 0:4af3ca173992 198 HAL_NVIC_EnableIRQ((IRQn_Type)(TS_INT_EXTI_IRQn));
arostm 0:4af3ca173992 199
arostm 0:4af3ca173992 200 /* Enable the TS in interrupt mode */
arostm 0:4af3ca173992 201 /* In that case the INT output of FT6206 when new touch is available */
arostm 0:4af3ca173992 202 /* is active on low level and directed on EXTI */
arostm 0:4af3ca173992 203 tsDriver->EnableIT(I2C_Address);
arostm 0:4af3ca173992 204
arostm 0:4af3ca173992 205 return (ts_status);
arostm 0:4af3ca173992 206 }
arostm 0:4af3ca173992 207
arostm 0:4af3ca173992 208 /**
arostm 0:4af3ca173992 209 * @brief Returns status and positions of the touch screen.
arostm 0:4af3ca173992 210 * @param TS_State: Pointer to touch screen current state structure
arostm 0:4af3ca173992 211 * @retval TS_OK if all initializations are OK. Other value if error.
arostm 0:4af3ca173992 212 */
arostm 0:4af3ca173992 213 uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State)
arostm 0:4af3ca173992 214 {
arostm 0:4af3ca173992 215 static uint32_t _x[TS_MAX_NB_TOUCH] = {0, 0};
arostm 0:4af3ca173992 216 static uint32_t _y[TS_MAX_NB_TOUCH] = {0, 0};
arostm 0:4af3ca173992 217 uint8_t ts_status = TS_OK;
arostm 0:4af3ca173992 218 uint16_t tmp;
arostm 0:4af3ca173992 219 uint16_t Raw_x[TS_MAX_NB_TOUCH];
arostm 0:4af3ca173992 220 uint16_t Raw_y[TS_MAX_NB_TOUCH];
arostm 0:4af3ca173992 221 uint16_t xDiff;
arostm 0:4af3ca173992 222 uint16_t yDiff;
arostm 0:4af3ca173992 223 uint32_t index;
arostm 0:4af3ca173992 224 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
arostm 0:4af3ca173992 225 uint32_t weight = 0;
arostm 0:4af3ca173992 226 uint32_t area = 0;
arostm 0:4af3ca173992 227 uint32_t event = 0;
arostm 0:4af3ca173992 228 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
arostm 0:4af3ca173992 229
arostm 0:4af3ca173992 230 /* Check and update the number of touches active detected */
arostm 0:4af3ca173992 231 TS_State->touchDetected = tsDriver->DetectTouch(I2C_Address);
arostm 0:4af3ca173992 232 if(TS_State->touchDetected)
arostm 0:4af3ca173992 233 {
arostm 0:4af3ca173992 234 for(index=0; index < TS_State->touchDetected; index++)
arostm 0:4af3ca173992 235 {
arostm 0:4af3ca173992 236 /* Get each touch coordinates */
arostm 0:4af3ca173992 237 tsDriver->GetXY(I2C_Address, &(Raw_x[index]), &(Raw_y[index]));
arostm 0:4af3ca173992 238
arostm 0:4af3ca173992 239 if(tsOrientation & TS_SWAP_XY)
arostm 0:4af3ca173992 240 {
arostm 0:4af3ca173992 241 tmp = Raw_x[index];
arostm 0:4af3ca173992 242 Raw_x[index] = Raw_y[index];
arostm 0:4af3ca173992 243 Raw_y[index] = tmp;
arostm 0:4af3ca173992 244 }
arostm 0:4af3ca173992 245
arostm 0:4af3ca173992 246 if(tsOrientation & TS_SWAP_X)
arostm 0:4af3ca173992 247 {
arostm 0:4af3ca173992 248 Raw_x[index] = FT_6206_MAX_WIDTH_HEIGHT - 1 - Raw_x[index];
arostm 0:4af3ca173992 249 }
arostm 0:4af3ca173992 250
arostm 0:4af3ca173992 251 if(tsOrientation & TS_SWAP_Y)
arostm 0:4af3ca173992 252 {
arostm 0:4af3ca173992 253 Raw_y[index] = FT_6206_MAX_WIDTH_HEIGHT - 1 - Raw_y[index];
arostm 0:4af3ca173992 254 }
arostm 0:4af3ca173992 255
arostm 0:4af3ca173992 256 xDiff = Raw_x[index] > _x[index]? (Raw_x[index] - _x[index]): (_x[index] - Raw_x[index]);
arostm 0:4af3ca173992 257 yDiff = Raw_y[index] > _y[index]? (Raw_y[index] - _y[index]): (_y[index] - Raw_y[index]);
arostm 0:4af3ca173992 258
arostm 0:4af3ca173992 259 if ((xDiff + yDiff) > 5)
arostm 0:4af3ca173992 260 {
arostm 0:4af3ca173992 261 _x[index] = Raw_x[index];
arostm 0:4af3ca173992 262 _y[index] = Raw_y[index];
arostm 0:4af3ca173992 263 }
arostm 0:4af3ca173992 264
arostm 0:4af3ca173992 265
arostm 0:4af3ca173992 266 TS_State->touchX[index] = _x[index];
arostm 0:4af3ca173992 267 TS_State->touchY[index] = _y[index];
arostm 0:4af3ca173992 268
arostm 0:4af3ca173992 269 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
arostm 0:4af3ca173992 270
arostm 0:4af3ca173992 271 /* Get touch info related to the current touch */
arostm 0:4af3ca173992 272 ft6x06_TS_GetTouchInfo(I2C_Address, index, &weight, &area, &event);
arostm 0:4af3ca173992 273
arostm 0:4af3ca173992 274 /* Update TS_State structure */
arostm 0:4af3ca173992 275 TS_State->touchWeight[index] = weight;
arostm 0:4af3ca173992 276 TS_State->touchArea[index] = area;
arostm 0:4af3ca173992 277
arostm 0:4af3ca173992 278 /* Remap touch event */
arostm 0:4af3ca173992 279 switch(event)
arostm 0:4af3ca173992 280 {
arostm 0:4af3ca173992 281 case FT6206_TOUCH_EVT_FLAG_PRESS_DOWN :
arostm 0:4af3ca173992 282 TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN;
arostm 0:4af3ca173992 283 break;
arostm 0:4af3ca173992 284 case FT6206_TOUCH_EVT_FLAG_LIFT_UP :
arostm 0:4af3ca173992 285 TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP;
arostm 0:4af3ca173992 286 break;
arostm 0:4af3ca173992 287 case FT6206_TOUCH_EVT_FLAG_CONTACT :
arostm 0:4af3ca173992 288 TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT;
arostm 0:4af3ca173992 289 break;
arostm 0:4af3ca173992 290 case FT6206_TOUCH_EVT_FLAG_NO_EVENT :
arostm 0:4af3ca173992 291 TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
arostm 0:4af3ca173992 292 break;
arostm 0:4af3ca173992 293 default :
arostm 0:4af3ca173992 294 ts_status = TS_ERROR;
arostm 0:4af3ca173992 295 break;
arostm 0:4af3ca173992 296 } /* of switch(event) */
arostm 0:4af3ca173992 297
arostm 0:4af3ca173992 298 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
arostm 0:4af3ca173992 299
arostm 0:4af3ca173992 300 } /* of for(index=0; index < TS_State->touchDetected; index++) */
arostm 0:4af3ca173992 301
arostm 0:4af3ca173992 302 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
arostm 0:4af3ca173992 303 /* Get gesture Id */
arostm 0:4af3ca173992 304 ts_status = BSP_TS_Get_GestureId(TS_State);
arostm 0:4af3ca173992 305 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
arostm 0:4af3ca173992 306
arostm 0:4af3ca173992 307 } /* end of if(TS_State->touchDetected != 0) */
arostm 0:4af3ca173992 308
arostm 0:4af3ca173992 309 return (ts_status);
arostm 0:4af3ca173992 310 }
arostm 0:4af3ca173992 311
arostm 0:4af3ca173992 312 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
arostm 0:4af3ca173992 313 /**
arostm 0:4af3ca173992 314 * @brief Update gesture Id following a touch detected.
arostm 0:4af3ca173992 315 * @param TS_State: Pointer to touch screen current state structure
arostm 0:4af3ca173992 316 * @retval TS_OK if all initializations are OK. Other value if error.
arostm 0:4af3ca173992 317 */
arostm 0:4af3ca173992 318 uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State)
arostm 0:4af3ca173992 319 {
arostm 0:4af3ca173992 320 uint32_t gestureId = 0;
arostm 0:4af3ca173992 321 uint8_t ts_status = TS_OK;
arostm 0:4af3ca173992 322
arostm 0:4af3ca173992 323 /* Get gesture Id */
arostm 0:4af3ca173992 324 ft6x06_TS_GetGestureID(I2C_Address, &gestureId);
arostm 0:4af3ca173992 325
arostm 0:4af3ca173992 326 /* Remap gesture Id to a TS_GestureIdTypeDef value */
arostm 0:4af3ca173992 327 switch(gestureId)
arostm 0:4af3ca173992 328 {
arostm 0:4af3ca173992 329 case FT6206_GEST_ID_NO_GESTURE :
arostm 0:4af3ca173992 330 TS_State->gestureId = GEST_ID_NO_GESTURE;
arostm 0:4af3ca173992 331 break;
arostm 0:4af3ca173992 332 case FT6206_GEST_ID_MOVE_UP :
arostm 0:4af3ca173992 333 TS_State->gestureId = GEST_ID_MOVE_UP;
arostm 0:4af3ca173992 334 break;
arostm 0:4af3ca173992 335 case FT6206_GEST_ID_MOVE_RIGHT :
arostm 0:4af3ca173992 336 TS_State->gestureId = GEST_ID_MOVE_RIGHT;
arostm 0:4af3ca173992 337 break;
arostm 0:4af3ca173992 338 case FT6206_GEST_ID_MOVE_DOWN :
arostm 0:4af3ca173992 339 TS_State->gestureId = GEST_ID_MOVE_DOWN;
arostm 0:4af3ca173992 340 break;
arostm 0:4af3ca173992 341 case FT6206_GEST_ID_MOVE_LEFT :
arostm 0:4af3ca173992 342 TS_State->gestureId = GEST_ID_MOVE_LEFT;
arostm 0:4af3ca173992 343 break;
arostm 0:4af3ca173992 344 case FT6206_GEST_ID_ZOOM_IN :
arostm 0:4af3ca173992 345 TS_State->gestureId = GEST_ID_ZOOM_IN;
arostm 0:4af3ca173992 346 break;
arostm 0:4af3ca173992 347 case FT6206_GEST_ID_ZOOM_OUT :
arostm 0:4af3ca173992 348 TS_State->gestureId = GEST_ID_ZOOM_OUT;
arostm 0:4af3ca173992 349 break;
arostm 0:4af3ca173992 350 default :
arostm 0:4af3ca173992 351 ts_status = TS_ERROR;
arostm 0:4af3ca173992 352 break;
arostm 0:4af3ca173992 353 } /* of switch(gestureId) */
arostm 0:4af3ca173992 354
arostm 0:4af3ca173992 355 return(ts_status);
arostm 0:4af3ca173992 356 }
arostm 0:4af3ca173992 357
arostm 0:4af3ca173992 358 /**
arostm 0:4af3ca173992 359 * @brief Function used to reset all touch data before a new acquisition
arostm 0:4af3ca173992 360 * of touch information.
arostm 0:4af3ca173992 361 * @param TS_State: Pointer to touch screen current state structure
arostm 0:4af3ca173992 362 * @retval TS_OK if OK, TE_ERROR if problem found.
arostm 0:4af3ca173992 363 */
arostm 0:4af3ca173992 364 uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State)
arostm 0:4af3ca173992 365 {
arostm 0:4af3ca173992 366 uint8_t ts_status = TS_ERROR;
arostm 0:4af3ca173992 367 uint32_t index;
arostm 0:4af3ca173992 368
arostm 0:4af3ca173992 369 if (TS_State != (TS_StateTypeDef *)NULL)
arostm 0:4af3ca173992 370 {
arostm 0:4af3ca173992 371 TS_State->gestureId = GEST_ID_NO_GESTURE;
arostm 0:4af3ca173992 372 TS_State->touchDetected = 0;
arostm 0:4af3ca173992 373
arostm 0:4af3ca173992 374 for(index = 0; index < TS_MAX_NB_TOUCH; index++)
arostm 0:4af3ca173992 375 {
arostm 0:4af3ca173992 376 TS_State->touchX[index] = 0;
arostm 0:4af3ca173992 377 TS_State->touchY[index] = 0;
arostm 0:4af3ca173992 378 TS_State->touchArea[index] = 0;
arostm 0:4af3ca173992 379 TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
arostm 0:4af3ca173992 380 TS_State->touchWeight[index] = 0;
arostm 0:4af3ca173992 381 }
arostm 0:4af3ca173992 382
arostm 0:4af3ca173992 383 ts_status = TS_OK;
arostm 0:4af3ca173992 384
arostm 0:4af3ca173992 385 } /* of if (TS_State != (TS_StateTypeDef *)NULL) */
arostm 0:4af3ca173992 386
arostm 0:4af3ca173992 387 return (ts_status);
arostm 0:4af3ca173992 388 }
arostm 0:4af3ca173992 389 #endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
arostm 0:4af3ca173992 390
arostm 0:4af3ca173992 391 /**
arostm 0:4af3ca173992 392 * @brief Initializes the TS_INT pin MSP.
arostm 0:4af3ca173992 393 */
arostm 0:4af3ca173992 394 __weak void BSP_TS_INT_MspInit(void)
arostm 0:4af3ca173992 395 {
arostm 0:4af3ca173992 396 GPIO_InitTypeDef gpio_init_structure;
arostm 0:4af3ca173992 397
arostm 0:4af3ca173992 398 TS_INT_GPIO_CLK_ENABLE();
arostm 0:4af3ca173992 399
arostm 0:4af3ca173992 400 /* Configure Interrupt mode for TS_INT pin falling edge : when a new touch is available */
arostm 0:4af3ca173992 401 /* TS_INT pin is active on low level on new touch available */
arostm 0:4af3ca173992 402 gpio_init_structure.Pin = TS_INT_PIN;
arostm 0:4af3ca173992 403 gpio_init_structure.Pull = GPIO_NOPULL;
arostm 0:4af3ca173992 404 gpio_init_structure.Speed = GPIO_SPEED_FAST;
arostm 0:4af3ca173992 405 gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
arostm 0:4af3ca173992 406 HAL_GPIO_Init(TS_INT_GPIO_PORT, &gpio_init_structure);
arostm 0:4af3ca173992 407 }
arostm 0:4af3ca173992 408
arostm 0:4af3ca173992 409 /**
arostm 0:4af3ca173992 410 * @}
arostm 0:4af3ca173992 411 */
arostm 0:4af3ca173992 412
arostm 0:4af3ca173992 413 /**
arostm 0:4af3ca173992 414 * @}
arostm 0:4af3ca173992 415 */
arostm 0:4af3ca173992 416
arostm 0:4af3ca173992 417 /**
arostm 0:4af3ca173992 418 * @}
arostm 0:4af3ca173992 419 */
arostm 0:4af3ca173992 420
arostm 0:4af3ca173992 421 /**
arostm 0:4af3ca173992 422 * @}
arostm 0:4af3ca173992 423 */
arostm 0:4af3ca173992 424
arostm 0:4af3ca173992 425 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/