1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
26
27
31
32
35
38
39
42
43
44
45
46
47
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
78
79
80
81
86
87
88
89
90
96
97
98
99
100
107
111
112
119
123
124
131
138
139
146
153
154
160
161
166
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
241
242
243
244
249
254
255
260
265
266
271
/* ... */
#include "GUI.h"
#include "GUIDRV_FlexColor.h"
#include "main.h"
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
#define XSIZE_PHYS 240
#define YSIZE_PHYS 240
/* ... */
#ifndef VXSIZE_PHYS
#define VXSIZE_PHYS XSIZE_PHYS
#endif
#ifndef VYSIZE_PHYS
#define VYSIZE_PHYS YSIZE_PHYS
#endif
#ifndef XSIZE_PHYS
#error Physical X size of display is not defined!
#endif
#ifndef YSIZE_PHYS
#error Physical Y size of display is not defined!
#endif
#ifndef GUICC_M565
#error Color conversion not defined!
#endif
#ifndef GUIDRV_FLEXCOLOR
#error No display driver defined!
#endif
/* ... */
typedef struct
{
__IO uint16_t REG;
__IO uint16_t RAM;
...}LCD_CONTROLLER_TypeDef;
#define FMC_BANK3_BASE ((uint32_t)(0x60000000 | 0x08000000))
#define FMC_BANK3 ((LCD_CONTROLLER_TypeDef *) FMC_BANK3_BASE)
/* ... */
static void STM_FSMC_BANK3_WriteData(uint16_t Data);
static void STM_FSMC_BANK3_WriteReg(uint8_t Reg);
static uint16_t STM_FSMC_BANK3_ReadData(void);
/* ... */
static void LcdWriteReg(U16 Data)
{
STM_FSMC_BANK3_WriteReg(Data);
}{ ... }
/* ... */
static void LcdWriteData(U16 Data)
{
STM_FSMC_BANK3_WriteData (Data);
}{ ... }
/* ... */
static void LcdWriteDataMultiple(U16 * pData, int NumItems)
{
while (NumItems--)
{
STM_FSMC_BANK3_WriteData(*pData++);
}while (NumItems--) { ... }
}{ ... }
/* ... */
static void LcdReadDataMultiple(U16 * pData, int NumItems)
{
while (NumItems--)
{
*pData++ = STM_FSMC_BANK3_ReadData();
}while (NumItems--) { ... }
}{ ... }
/* ... */
/* ... */
void LCD_LL_Init(void)
{
BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE_ROT180);
}{ ... }
/* ... */
void LCD_X_Config(void)
{
GUI_DEVICE * pDevice;
CONFIG_FLEXCOLOR Config = {0};
GUI_PORT_API PortAPI = {0};
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_M565, 0, 0);
LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
Config.Orientation = GUI_MIRROR_X | GUI_MIRROR_Y;
GUIDRV_FlexColor_Config(pDevice, &Config);
PortAPI.pfWrite16_A0 = LcdWriteReg;
PortAPI.pfWrite16_A1 = LcdWriteData;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);
}{ ... }
/* ... */
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
int r;
(void) LayerIndex;
(void) pData;
switch (Cmd) {
case LCD_X_INITCONTROLLER: {
LCD_LL_Init();
return 0;
...}case LCD_X_INITCONTROLLER:
default:
r = -1;default
}switch (Cmd) { ... }
return r;
}{ ... }
/* ... */
static void STM_FSMC_BANK3_WriteData(uint16_t Data)
{
FMC_BANK3->RAM = Data;
}{ ... }
/* ... */
static void STM_FSMC_BANK3_WriteReg(uint8_t Reg)
{
FMC_BANK3->REG = Reg;
}{ ... }
/* ... */
static uint16_t STM_FSMC_BANK3_ReadData(void)
{
return FMC_BANK3->RAM;
}{ ... }