1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
30
34
35
36
37
38
39
40
45
46
47
48
49
50
51
52
53
54
55
56
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
79
80
81
82
83
84
85
86
87
92
93
94
95
96
97
98
99
100
101
102
122
128
129
130
131
132
133
134
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
166
167
/* ... */
#include "k_bsp.h"
/* ... */
/* ... */
Includes
extern uint8_t SelLayer;
extern uint8_t I2C_Address;
TS_StateTypeDef TS_State = {0};External variables
/* ... */
void k_BspInit(void)
{
BSP_QSPI_Init();
BSP_QSPI_EnableMemoryMappedMode();
BSP_SDRAM_Init();
#if defined(USE_STM32469I_DISCO_REVC)
k_Bsp_LCD_Reset();/* ... */
#endif
HAL_Delay(100);
BSP_TS_Init(800, 480);
__HAL_RCC_CRC_CLK_ENABLE();
__HAL_RCC_BKPSRAM_CLK_ENABLE();
}{ ... }
/* ... */
void k_TouchUpdate(void)
{
static GUI_PID_STATE TS_State = {0, 0, 0, 0};
__IO TS_StateTypeDef ts;
uint16_t xDiff, yDiff;
BSP_TS_GetState((TS_StateTypeDef *)&ts);
if((ts.touchX[0] >= LCD_GetXSize()) ||(ts.touchY[0] >= LCD_GetYSize()) )
{
ts.touchX[0] = 0;
ts.touchY[0] = 0;
}if ((ts.touchX[0] >= LCD_GetXSize()) ||(ts.touchY[0] >= LCD_GetYSize())) { ... }
xDiff = (TS_State.x > ts.touchX[0]) ? (TS_State.x - ts.touchX[0]) : (ts.touchX[0] - TS_State.x);
yDiff = (TS_State.y > ts.touchY[0]) ? (TS_State.y - ts.touchY[0]) : (ts.touchY[0] - TS_State.y);
if((TS_State.Pressed != ts.touchDetected ) ||
(xDiff > 20 )||
(yDiff > 20))
{
TS_State.Pressed = ts.touchDetected;
TS_State.Layer = SelLayer;
if(ts.touchDetected)
{
TS_State.x = ts.touchX[0];
if(I2C_Address == TS_I2C_ADDRESS)
{
if(ts.touchY[0] < 240)
{
TS_State.y = ts.touchY[0];
}if (ts.touchY[0] < 240) { ... }
else
{
TS_State.y = (ts.touchY[0] * 480) / 450;
}else { ... }
}if (I2C_Address == TS_I2C_ADDRESS) { ... }
else
{
TS_State.y = ts.touchY[0];
}else { ... }
GUI_TOUCH_StoreStateEx(&TS_State);
}if (ts.touchDetected) { ... }
else
{
GUI_TOUCH_StoreStateEx(&TS_State);
TS_State.x = 0;
TS_State.y = 0;
}else { ... }
}if ((TS_State.Pressed != ts.touchDetected ) || (xDiff > 20 )|| (yDiff > 20)) { ... }
}{ ... }
#if defined(USE_STM32469I_DISCO_REVC)
/* ... */
void k_Bsp_LCD_Reset(void)
{
GPIO_InitTypeDef gpio_init_structure;
__HAL_RCC_GPIOH_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_7;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init( GPIOH, &gpio_init_structure );
HAL_GPIO_WritePin( GPIOH, GPIO_PIN_7, GPIO_PIN_RESET );
HAL_Delay(20);
HAL_GPIO_WritePin( GPIOH, GPIO_PIN_7, GPIO_PIN_SET );
}{ ... }
#endif/* ... */
/* ... */
/* ... */