Select one of the symbols to view example projects that use it.
 
Outline
#include "stm32f429i_discovery_ts.h"
#include "stm32f429i_discovery_io.h"
TsDrv
TsXBoundary
TsYBoundary
BSP_TS_Init(uint16_t, uint16_t)
BSP_TS_ITConfig()
BSP_TS_ITGetStatus()
BSP_TS_GetState(TS_StateTypeDef *)
BSP_TS_ITClear()
Files
loading...
CodeScopeSTM32 Libraries and SamplesSTM32F429I-Discoverystm32f429i_discovery_ts.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file stm32f429i_discovery_ts.c * @author MCD Application Team * @brief This file provides a set of functions needed to manage Touch * screen available with STMPE811 IO Expander device mounted on * STM32F429I-Discovery Kit. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "stm32f429i_discovery_ts.h" #include "stm32f429i_discovery_io.h" /** @addtogroup BSP * @{ *//* ... */ /** @addtogroup STM32F429I_DISCOVERY * @{ *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS STM32F429I DISCOVERY TS * @{ *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Types_Definitions STM32F429I DISCOVERY TS Private Types Definitions * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Defines STM32F429I DISCOVERY TS Private Defines * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Macros STM32F429I DISCOVERY TS Private Macros * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Variables STM32F429I DISCOVERY TS Private Variables * @{ *//* ... */ static TS_DrvTypeDef *TsDrv; static uint16_t TsXBoundary, TsYBoundary; /** * @} *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Function_Prototypes STM32F429I DISCOVERY TS Private Function Prototypes * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup STM32F429I_DISCOVERY_TS_Private_Functions STM32F429I DISCOVERY TS Private Functions * @{ *//* ... */ /** * @brief Initializes and configures the touch screen functionalities and * configures all necessary hardware resources (GPIOs, clocks..). * @param XSize: The maximum X size of the TS area on LCD * @param YSize: The maximum Y size of the TS area on LCD * @retval TS_OK: if all initializations are OK. Other value if error. *//* ... */ uint8_t BSP_TS_Init(uint16_t XSize, uint16_t YSize) { uint8_t ret = TS_ERROR; /* Initialize x and y positions boundaries */ TsXBoundary = XSize; TsYBoundary = YSize; /* Read ID and verify if the IO expander is ready */ if (stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) { /* Initialize the TS driver structure */ TsDrv = &stmpe811_ts_drv; ret = TS_OK; }if (stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID) { ... } if (ret == TS_OK) { /* Initialize the LL TS Driver */ TsDrv->Init(TS_I2C_ADDRESS); TsDrv->Start(TS_I2C_ADDRESS); }if (ret == TS_OK) { ... } return ret; }{ ... } /** * @brief Configures and enables the touch screen interrupts. * @retval TS_OK: if ITconfig is OK. Other value if error. *//* ... */ uint8_t BSP_TS_ITConfig(void) { /* Enable the TS ITs */ TsDrv->EnableIT(TS_I2C_ADDRESS); return TS_OK; }{ ... } /** * @brief Gets the TS IT status. * @retval Interrupt status. *//* ... */ uint8_t BSP_TS_ITGetStatus(void) { /* Return the TS IT status */ return (TsDrv->GetITStatus(TS_I2C_ADDRESS)); }{ ... } /** * @brief Returns status and positions of the touch screen. * @param TsState: Pointer to touch screen current state structure *//* ... */ void BSP_TS_GetState(TS_StateTypeDef *TsState) { static uint32_t _x = 0, _y = 0; uint16_t xDiff, yDiff, x, y, xr, yr; TsState->TouchDetected = TsDrv->DetectTouch(TS_I2C_ADDRESS); if (TsState->TouchDetected) { TsDrv->GetXY(TS_I2C_ADDRESS, &x, &y); #if defined (USE_STM32F429I_DISCOVERY_REVD) if (y > 3700) { y = 3700; }if (y > 3700) { ... } else if (y < 180) { y = 180; }else if (y < 180) { ... } /* Y value first correction */ y = 3700 - y;/* ... */ #else /* Y value first correction */ y -= 360; /* ... */ #endif /* Y value second correction */ yr = y / 11; /* Return y position value */ if (yr <= 0) { yr = 0; }if (yr <= 0) { ... } else if (yr > TsYBoundary) { yr = TsYBoundary - 1; }else if (yr > TsYBoundary) { ... } else {}else { ... } y = yr; /* X value first correction */ if (x <= 3000) { x = 3870 - x; }if (x <= 3000) { ... } else { x = 3800 - x; }else { ... } /* X value second correction */ xr = x / 15; /* Return X position value */ if (xr <= 0) { xr = 0; }if (xr <= 0) { ... } else if (xr > TsXBoundary) { xr = TsXBoundary - 1; }else if (xr > TsXBoundary) { ... } else {}else { ... } x = xr; xDiff = x > _x ? (x - _x): (_x - x); yDiff = y > _y ? (y - _y) : (_y - y); if (xDiff + yDiff > 5) { _x = x; _y = y; }if (xDiff + yDiff > 5) { ... } /* Update the X position */ TsState->X = _x; /* Update the Y position */ TsState->Y = _y; }if (TsState->TouchDetected) { ... } }{ ... } /** * @brief Clears all touch screen interrupts. *//* ... */ void BSP_TS_ITClear(void) { /* Clear TS IT pending bits */ TsDrv->ClearIT(TS_I2C_ADDRESS); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */