1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
31
34
35
36
37
38
39
40
45
46
47
48
49
50
51
52
53
54
55
56
57
63
64
65
66
67
68
69
70
71
72
73
78
79
97
98
99
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
142
143
/* ... */
#include "k_bsp.h"
/* ... */
/* ... */
Includes
TS_StateTypeDef TS_State = {0};
External variables
/* ... */
void k_BspInit(void)
{
BSP_QSPI_Init();
BSP_QSPI_MemoryMappedMode();
BSP_TS_InitEx(240, 240, TS_ORIENTATION_PORTRAIT);
__HAL_RCC_CRC_CLK_ENABLE();
}{ ... }
/* ... */
void k_TouchUpdate(void)
{
static GUI_PID_STATE TS_State = {0, 0, 0, 0};
__IO TS_StateTypeDef ts;
BSP_TS_GetState((TS_StateTypeDef *)&ts);
ts.touchX[0] = TouchScreen_Get_Calibrated_X(ts.touchX[0]);
ts.touchY[0] = TouchScreen_Get_Calibrated_Y(ts.touchY[0]);
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())) { ... }
if((TS_State.Pressed != ts.touchDetected )||
(TS_State.x != ts.touchX[0]) ||
(TS_State.y != ts.touchY[0]))
{
TS_State.Pressed = ts.touchDetected;
if(ts.touchDetected)
{
TS_State.x = ts.touchX[0];
TS_State.y = ts.touchY[0];
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 )|| (TS_State.x != ts.touchX[0]) || (TS_State.y != ts.touchY[0])) { ... }
}{ ... }
/* ... */
void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params)
{
GPIO_InitTypeDef gpio_init_structure;
__HAL_RCC_SDIO_CLK_ENABLE();
__DMAx_TxRx_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
gpio_init_structure.Alternate = GPIO_AF12_SDIO;
gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
gpio_init_structure.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
HAL_NVIC_SetPriority(SDIO_IRQn, 0x0E, 0x00);
HAL_NVIC_EnableIRQ(SDIO_IRQn);
}{ ... }
/* ... */
/* ... */