1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
27
30
31
35
36
39
42
43
46
49
50
51
54
57
58
59
62
65
66
67
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
89
90
93
94
95
100
101
102
103
104
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
190
191
192
193
194
195
196
197
198
199
200
201
207
208
209
214
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
266
267
268
269
270
271
272
273
274
279
280
281
282
283
284
285
286
287
288
289
299
300
301
304
305
308
309
/* ... */
#include "main.h"
#include "k_mem.h"
#include "k_bsp.h"
#include "k_log.h"
#include "k_rtc.h"
#include "k_calibration.h"
#include "k_storage.h"
7 includes
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
static void SystemClock_Config(void);
static void GUIThread(void const * argument);
static void TimerCallback(void const *n);
extern K_ModuleItem_Typedef system_info;
extern K_ModuleItem_Typedef video_player;
extern K_ModuleItem_Typedef game_board;
extern K_ModuleItem_Typedef image_browser;
extern K_ModuleItem_Typedef cpu_bench;
extern K_ModuleItem_Typedef file_browser;
extern K_ModuleItem_Typedef usb_device;
extern K_ModuleItem_Typedef audio_player;
extern K_ModuleItem_Typedef camera_capture;
uint32_t GUI_FreeMem = 0;
/* ... */
/* ... */
/* ... */
int main(void)
{
osTimerId lcd_timer;
/* ... */
HAL_Init();
SystemClock_Config();
k_BspInit();
k_LogInit();
k_CalendarBkupInit();
osThreadDef(GUI_Thread, GUIThread, osPriorityAboveNormal, 0, 1024);
osThreadCreate (osThread(GUI_Thread), NULL);
k_MemInit();
k_ModuleInit();
k_ModuleAdd(&video_player);
k_ModuleOpenLink(&video_player, "emf");
k_ModuleOpenLink(&video_player, "EMF");
k_ModuleAdd(&image_browser);
k_ModuleOpenLink(&image_browser, "jpg");
k_ModuleOpenLink(&image_browser, "JPG");
k_ModuleOpenLink(&image_browser, "bmp");
k_ModuleOpenLink(&image_browser, "BMP");
k_ModuleAdd(&audio_player);
k_ModuleOpenLink(&audio_player, "wav");
k_ModuleOpenLink(&audio_player, "WAV");
k_ModuleAdd(&camera_capture);
k_ModuleAdd(&system_info);
k_ModuleAdd(&file_browser);
k_ModuleAdd(&cpu_bench);
k_ModuleAdd(&game_board);
k_ModuleAdd(&usb_device);
osTimerDef(TS_Timer, TimerCallback);
lcd_timer = osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);
osTimerStart(lcd_timer, 40);
GUI_X_InitOS();
osKernelStart();
for( ;; );
}{ ... }
/* ... */
static void GUIThread(void const * argument)
{
k_StorageInit();
GUI_Init();
WM_SetCreateFlags(WM_CF_MEMDEV);
k_SetGuiProfile();
if(k_CalibrationIsDone() == 0)
{
k_CalibrationInit();
}if (k_CalibrationIsDone() == 0) { ... }
k_StartUp();
k_BspAudioInit();
k_InitMenu();
while(1) {
GUI_Exec();
osDelay(20);
GUI_FreeMem = GUI_ALLOC_GetNumFreeBytes();
}while (1) { ... }
}{ ... }
/* ... */
static void TimerCallback(void const *n)
{
k_TouchUpdate();
}{ ... }
/* ... */
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
__HAL_RCC_PWR_CLK_ENABLE();
/* ... */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig (&RCC_OscInitStruct);
/* ... */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
if (HAL_GetREVID() >= 0x1001)
{
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
}if (HAL_GetREVID() >= 0x1001) { ... }
}{ ... }
#ifdef USE_FULL_ASSERT
/* ... */
void assert_failed(uint8_t* file, uint32_t line)
{
/* ... */
while (1)
{
}while (1) { ... }
}assert_failed (uint8_t* file, uint32_t line) { ... }
/* ... */#endif
/* ... */
/* ... */
/* ... */