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:
arostm
Date:
Wed May 17 10:23:19 2017 +0200
Revision:
0:4af3ca173992
Child:
3:42b354f5069c
creation of the DISCO_F413ZH BSP library

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