Select one of the symbols to view example projects that use it.
 
Outline
#include "LCDConf.h"
#include "GUI_Private.h"
#define ROTATION_0
#define ROTATION_CW
#define ROTATION_180
#define ROTATION_CCW
#define CMS_ARGB8888
#define CMS_RGB888
#define CMS_RGB565
#define CMS_ARGB1555
#define CMS_ARGB4444
#define CMS_L8
#define CMS_AL44
#define CMS_AL88
#define XSIZE_PHYS
#define YSIZE_PHYS
#define NUM_BUFFERS
#define NUM_VSCREENS
#define GUI_NUM_LAYERS
#define COLOR_MODE_0
#define ORIENTATION_0
#define XSIZE_0
#define YSIZE_0
#define COLOR_MODE_1
#define ORIENTATION_1
#define XSIZE_1
#define YSIZE_1
#define BK_COLOR
#define ZONES
#define VSYNC
#define VBP
#define VFP
#define VACT
#define HSYNC
#define HBP
#define HFP
#define HACT
TransferInProgress
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define COLOR_CONVERSION_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define DISPLAY_DRIVER_0
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define COLOR_CONVERSION_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define DISPLAY_DRIVER_1
#define XSIZE_0
#define YSIZE_0
#define NUM_BUFFERS
#define NUM_VSCREENS
#define LCD_FRAME_BUFFER
#define __DSI_MASK_TE
#define __DSI_UNMASK_TE
hltdc
hdsi
layer_prop
pPage
pCols
LCD_ActiveRegion
LCD_Refershing
_aMirror
_aAddr
LCD_Addr
_aPendingBuffer
_aBufferIndex
_axSize
_aySize
_aBytesPerPixels
_aBuffer
_pBuffer_DMA2D
_apColorConvAPI
_aOrientation
_Color2IndexBulk_M8888I_DMA2D(LCD_COLOR *, void *, unsigned long, unsigned char)
_Index2ColorBulk_M8888I_DMA2D(void *, LCD_COLOR *, unsigned long, unsigned char)
_Color2IndexBulk_M888_DMA2D(LCD_COLOR *, void *, unsigned long, unsigned char)
_Index2ColorBulk_M888_DMA2D(void *, LCD_COLOR *, unsigned long, unsigned char)
_Color2IndexBulk_M565_DMA2D(LCD_COLOR *, void *, unsigned long, unsigned char)
_Index2ColorBulk_M565_DMA2D(void *, LCD_COLOR *, unsigned long, unsigned char)
_Color2IndexBulk_M1555I_DMA2D(LCD_COLOR *, void *, unsigned long, unsigned char)
_Index2ColorBulk_M1555I_DMA2D(void *, LCD_COLOR *, unsigned long, unsigned char)
_Index2ColorBulk_M4444I_DMA2D(void *, LCD_COLOR *, unsigned long, unsigned char)
_Color2IndexBulk_M4444I_DMA2D(LCD_COLOR *, void *, unsigned long, unsigned char)
_GetPixelformat(int)
_DMA2D_ITConfig(unsigned long, int)
DSI_IO_WriteCmd(uint32_t, uint8_t *)
LCD_LL_Reset()
BSP_LCD_MspInit()
LTDC_Init()
LCD_LL_Init()
LCD_LL_LayerInit(unsigned long, unsigned long)
DMA2D_IRQHandler()
_DMA2D_ExecOperation()
_DMA_Copy(int, void *, void *, int, int, int, int)
_DMA_CopyRGB565(const void *, void *, int, int, int, int)
_DMA_Fill(int, void *, int, int, int, unsigned long)
_DMA_AlphaBlendingBulk(LCD_COLOR *, LCD_COLOR *, LCD_COLOR *, unsigned long)
_DMA_MixColorsBulk(LCD_COLOR *, LCD_COLOR *, LCD_COLOR *, unsigned char, unsigned long)
_DMA_ConvertColor(void *, void *, unsigned long, unsigned long, unsigned long)
_DMA_DrawBitmapL8(void *, void *, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
_DMA_DrawBitmapA4(void *, void *, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
_DMA_DrawAlphaBitmap(void *, const void *, int, int, int, int, int)
_DMA_LoadLUT(LCD_COLOR *, unsigned long)
_DMA_AlphaBlending(LCD_COLOR *, LCD_COLOR *, LCD_COLOR *, unsigned long)
_DMA_Index2ColorBulk(void *, LCD_COLOR *, unsigned long, unsigned char, unsigned long)
_DMA_Color2IndexBulk(LCD_COLOR *, void *, unsigned long, unsigned char, unsigned long)
_LCD_MixColorsBulk(unsigned long *, unsigned long *, unsigned long *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char)
_GetBufferSize(int)
_LCD_CopyBuffer(int, int, int)
_LCD_CopyRect(int, int, int, int, int, int, int)
_LCD_FillRect(int, int, int, int, int, unsigned long)
_LCD_DrawBitmap32bpp(int, int, int, const unsigned short *, int, int, int)
_LCD_DrawBitmap16bpp(int, int, int, const unsigned short *, int, int, int)
_LCD_DrawBitmap8bpp(int, int, int, const unsigned char *, int, int, int)
_LCD_DrawBitmap4bpp(int, int, int, const unsigned char *, int, int, int)
_LCD_DrawMemdev16bpp(void *, const void *, int, int, int, int)
_LCD_DrawMemdevAlpha(void *, const void *, int, int, int, int)
_LCD_DrawBitmapAlpha(int, int, int, const void *, int, int, int)
_LCD_GetpPalConvTable(const LCD_LOGPALETTE *, const GUI_BITMAP *, int)
LCD_SetUpdateRegion(int)
HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *)
HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *)
LCD_ReqTear()
LCD_X_DisplayDriver(unsigned int, unsigned int, void *)
LCD_X_Config()
DSI_IRQHandler()
Files
loading...
SourceVuSTM32 Libraries and SamplesSTemWin_MemoryDeviceSTemWin/Target/LCDConf.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @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 "LCDConf.h" #include "GUI_Private.h" /** @addtogroup LCD CONFIGURATION * @{ *//* ... */ /** @defgroup LCD CONFIGURATION * @brief This file contains the LCD Configuration * @{ *//* ... */ /** @defgroup LCD CONFIGURATION_Private_TypesDefinitions * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup LCD CONFIGURATION_Private_Defines * @{ *//* ... */ /* Define the possible screen orientations */ #define ROTATION_0 0 #define ROTATION_CW 1 #define ROTATION_180 2 #define ROTATION_CCW 3 /* Define the possible color modes */ #define CMS_ARGB8888 1 #define CMS_RGB888 2 #define CMS_RGB565 3 #define CMS_ARGB1555 4 #define CMS_ARGB4444 5 #define CMS_L8 6 #define CMS_AL44 7 #define CMS_AL88 8 /* Define physical screen sizes */ #define XSIZE_PHYS 800 #define YSIZE_PHYS 480 /* Define the number of buffers to use (minimum 1) */ #define NUM_BUFFERS 3 /* Define the number of virtual buffers to use (minimum 1) */ #define NUM_VSCREENS 1 16 defines /* Redefine number of layers to be used, must be equal or less than in GUIConf.h */ #undef GUI_NUM_LAYERS #define GUI_NUM_LAYERS 1 /* Define Layer 0 color mode, orientation and sizes */ #define COLOR_MODE_0 CMS_RGB565 #define ORIENTATION_0 ROTATION_0 #define XSIZE_0 XSIZE_PHYS #define YSIZE_0 YSIZE_PHYS /* Define Layer 1 color mode, orientation and sizes */ #define COLOR_MODE_1 CMS_ARGB4444 #define ORIENTATION_1 ROTATION_0 #define XSIZE_1 XSIZE_PHYS #define YSIZE_1 YSIZE_PHYS /* Define the background color shown where no layer is active */ #define BK_COLOR GUI_DARKBLUE /* Define the screen area: can be 2 or 4 */ #define ZONES 4 #define VSYNC 1 #define VBP 1 #define VFP 1 #define VACT YSIZE_PHYS #define HSYNC 1 #define HBP 1 #define HFP 1 #define HACT XSIZE_PHYS/ZONES 19 defines static volatile char TransferInProgress = 0; void DMA2D_IRQHandler(void); /* Choose Layer 0 color conversion depending of the color mode chosen */ #if (COLOR_MODE_0 == CMS_ARGB8888) #define COLOR_CONVERSION_0 GUICC_M8888I #elif (COLOR_MODE_0 == CMS_RGB888) #define COLOR_CONVERSION_0 GUICC_M888 #elif (COLOR_MODE_0 == CMS_RGB565) #define COLOR_CONVERSION_0 GUICC_M565 #elif (COLOR_MODE_0 == CMS_ARGB1555) #define COLOR_CONVERSION_0 GUICC_M1555I #elif (COLOR_MODE_0 == CMS_ARGB4444) #define COLOR_CONVERSION_0 GUICC_M4444I #elif (COLOR_MODE_0 == CMS_L8) #define COLOR_CONVERSION_0 GUICC_8666 #elif (COLOR_MODE_0 == CMS_AL44) #define COLOR_CONVERSION_0 GUICC_1616I #elif (COLOR_MODE_0 == CMS_AL88) #define COLOR_CONVERSION_0 GUICC_88666I #else #error Illegal color mode 0! #endif /* Choose Choose Layer 0 gui driver depending of the color mode chosen */ #if (COLOR_MODE_0 == CMS_ARGB8888) #if (ORIENTATION_0 == ROTATION_0) #define DISPLAY_DRIVER_0 GUIDRV_LIN_32 #elif (ORIENTATION_0 == ROTATION_CW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSX_32 #elif (ORIENTATION_0 == ROTATION_180) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OXY_32 #elif (ORIENTATION_0 == ROTATION_CCW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSY_32 #endif/* ... */ #elif (COLOR_MODE_0 == CMS_RGB888) #if (ORIENTATION_0 == ROTATION_0) #define DISPLAY_DRIVER_0 GUIDRV_LIN_24 #elif (ORIENTATION_0 == ROTATION_CW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSX_24 #elif (ORIENTATION_0 == ROTATION_180) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OXY_24 #elif (ORIENTATION_0 == ROTATION_CCW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSY_24 #endif/* ... */ #elif (COLOR_MODE_0 == CMS_RGB565) \ || (COLOR_MODE_0 == CMS_ARGB1555) \ || (COLOR_MODE_0 == CMS_ARGB4444) \ || (COLOR_MODE_0 == CMS_AL88) #if (ORIENTATION_0 == ROTATION_0) #define DISPLAY_DRIVER_0 GUIDRV_LIN_16 #elif (ORIENTATION_0 == ROTATION_CW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSX_16 #elif (ORIENTATION_0 == ROTATION_180) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OXY_16 #elif (ORIENTATION_0 == ROTATION_CCW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSY_16 #endif/* ... */ #elif (COLOR_MODE_0 == CMS_L8) \ || (COLOR_MODE_0 == CMS_AL44) #if (ORIENTATION_0 == ROTATION_0) #define DISPLAY_DRIVER_0 GUIDRV_LIN_8 #elif (ORIENTATION_0 == ROTATION_CW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSX_8 #elif (ORIENTATION_0 == ROTATION_180) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OXY_8 #elif (ORIENTATION_0 == ROTATION_CCW) #define DISPLAY_DRIVER_0 GUIDRV_LIN_OSY_8 #endif/* ... */ #endif /* Choose Layer 1 color conversion depending of the color mode//orientation chosen */ #if (GUI_NUM_LAYERS > 1) #if (COLOR_MODE_1 == CMS_ARGB8888) #define COLOR_CONVERSION_1 GUICC_M8888I #elif (COLOR_MODE_1 == CMS_RGB888) #define COLOR_CONVERSION_1 GUICC_M888 #elif (COLOR_MODE_1 == CMS_RGB565) #define COLOR_CONVERSION_1 GUICC_M565 #elif (COLOR_MODE_1 == CMS_ARGB1555) #define COLOR_CONVERSION_1 GUICC_M1555I #elif (COLOR_MODE_1 == CMS_ARGB4444) #define COLOR_CONVERSION_1 GUICC_M4444I #elif (COLOR_MODE_1 == CMS_L8) #define COLOR_CONVERSION_1 GUICC_8666 #elif (COLOR_MODE_1 == CMS_AL44) #define COLOR_CONVERSION_1 GUICC_1616I #elif (COLOR_MODE_1 == CMS_AL88) #define COLOR_CONVERSION_1 GUICC_88666I #else #error Illegal color mode 0! #endif /* Choose Choose Layer 1 gui driver depending of the color mode/orientation chosen */ #if (COLOR_MODE_1 == CMS_ARGB8888) #if (ORIENTATION_1 == ROTATION_0) #define DISPLAY_DRIVER_1 GUIDRV_LIN_32 #elif (ORIENTATION_1 == ROTATION_CW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSX_32 #elif (ORIENTATION_1 == ROTATION_180) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OXY_32 #elif (ORIENTATION_1 == ROTATION_CCW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSY_32 #endif/* ... */ #elif (COLOR_MODE_1 == CMS_RGB888) #if (ORIENTATION_1 == ROTATION_0) #define DISPLAY_DRIVER_1 GUIDRV_LIN_24 #elif (ORIENTATION_1 == ROTATION_CW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSX_24 #elif (ORIENTATION_1 == ROTATION_180) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OXY_24 #elif (ORIENTATION_1 == ROTATION_CCW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSY_24 #endif/* ... */ #elif (COLOR_MODE_1 == CMS_RGB565) \ || (COLOR_MODE_1 == CMS_ARGB1555) \ || (COLOR_MODE_1 == CMS_ARGB4444) \ || (COLOR_MODE_1 == CMS_AL88) #if (ORIENTATION_1 == ROTATION_0) #define DISPLAY_DRIVER_1 GUIDRV_LIN_16 #elif (ORIENTATION_1 == ROTATION_CW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSX_16 #elif (ORIENTATION_1 == ROTATION_180) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OXY_16 #elif (ORIENTATION_1 == ROTATION_CCW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSY_16 #endif/* ... */ #elif (COLOR_MODE_1 == CMS_L8) \ || (COLOR_MODE_1 == CMS_AL44) #if (ORIENTATION_1 == ROTATION_0) #define DISPLAY_DRIVER_1 GUIDRV_LIN_8 #elif (ORIENTATION_1 == ROTATION_CW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSX_8 #elif (ORIENTATION_1 == ROTATION_180) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OXY_8 #elif (ORIENTATION_1 == ROTATION_CCW) #define DISPLAY_DRIVER_1 GUIDRV_LIN_OSY_8 #endif/* ... */ #endif /* ... */ #else /* Use complete display automatically in case of only one layer */ #undef XSIZE_0 #undef YSIZE_0 #define XSIZE_0 XSIZE_PHYS #define YSIZE_0 YSIZE_PHYS /* ... */ #endif /* Check the that configuration used is OK */ #if NUM_BUFFERS > 3 #error More than 3 buffers make no sense and are not supported in this configuration file! #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 NUM_BUFFERS #define NUM_BUFFERS 1 #else #if (NUM_BUFFERS <= 0) #error At least one buffer needs to be defined! #endif/* ... */ #endif #ifndef NUM_VSCREENS #define NUM_VSCREENS 1 #else #if (NUM_VSCREENS <= 0) #error At least one screeen needs to be defined! #endif/* ... */ #endif #if (NUM_VSCREENS > 1) && (NUM_BUFFERS > 1) #error Virtual screens together with multiple buffers are not allowed! #endif /* Define the offset of the frame to be used */ #define LCD_FRAME_BUFFER ((U32)0xC0000000) /* DSI tearing effect GPIO */ #define __DSI_MASK_TE() (GPIOJ->AFR[0] &= (0xFFFFF0FFU)) #define __DSI_UNMASK_TE() (GPIOJ->AFR[0] |= ((uint32_t)(GPIO_AF13_DSI) << 8)) /** * @} *//* ... */ /* Redirect bulk conversion to DMA2D routines */ #define DEFINE_DMA2D_COLORCONVERSION(PFIX, PIXELFORMAT) \ static void _Color2IndexBulk_##PFIX##_DMA2D(LCD_COLOR * pColor, void * pIndex, U32 NumItems, U8 SizeOfIndex) { \ _DMA_Color2IndexBulk(pColor, pIndex, NumItems, SizeOfIndex, PIXELFORMAT); \ }_DMA2D (LCD_COLOR * pColor, void * pIndex, U32 NumItems, U8 SizeOfIndex) { ... } \ static void _Index2ColorBulk_##PFIX##_DMA2D(void * pIndex, LCD_COLOR * pColor, U32 NumItems, U8 SizeOfIndex) { \ _DMA_Index2ColorBulk(pIndex, pColor, NumItems, SizeOfIndex, PIXELFORMAT); \ }_DMA2D (void * pIndex, LCD_COLOR * pColor, U32 NumItems, U8 SizeOfIndex) { ... } ... /** * @} *//* ... */ /** @defgroup LCD CONFIGURATION_Private_Variables * @{ *//* ... */ LTDC_HandleTypeDef hltdc; DSI_HandleTypeDef hdsi; static LCD_LayerPropTypedef layer_prop[GUI_NUM_LAYERS]; /* Screen needed definitions */ uint8_t pPage[] = {0x00, 0x00, 0x01, 0xDF}; /* 0 -> 479 */ /* ZONES of the screen */ uint8_t pCols[ZONES][4] = { #if (ZONES == 4 ) {0x00, 0x00, 0x00, 0xC7}, /* 0 -> 199 */ {0x00, 0xC8, 0x01, 0x8F}, /* 200 -> 399 */ {0x01, 0x90, 0x02, 0x57}, /* 400 -> 599 */ {0x02, 0x58, 0x03, 0x1F}, /* 600 -> 799 *//* ... */ #elif (ZONES == 2 ) {0x00, 0x00, 0x01, 0x8F}, /* 0 -> 399 */ {0x01, 0x90, 0x03, 0x1F} /* ... */ #elif (ZONES == 1 ) {0x00, 0x00, 0x01, 0x3F}, /* 0 -> 799 */ #endif ...}; volatile int32_t LCD_ActiveRegion = 1; volatile int32_t LCD_Refershing = 0; /* Array for speeding up nibble conversion for A4 bitmaps */ static const U8 _aMirror[] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF, ...}; /* Frame buffer tables to be used */ static const U32 _aAddr[] = { LCD_FRAME_BUFFER, LCD_FRAME_BUFFER + XSIZE_PHYS * YSIZE_PHYS * sizeof(U32) * NUM_VSCREENS * NUM_BUFFERS }; U32 LCD_Addr[] = { LCD_FRAME_BUFFER, LCD_FRAME_BUFFER + XSIZE_PHYS * YSIZE_PHYS * sizeof(U32) * NUM_VSCREENS * NUM_BUFFERS }; static int _aPendingBuffer[2] = { -1, -1 }; static int _aBufferIndex[GUI_NUM_LAYERS]; static int _axSize[GUI_NUM_LAYERS]; static int _aySize[GUI_NUM_LAYERS]; static int _aBytesPerPixels[GUI_NUM_LAYERS]; static U32 _aBuffer[XSIZE_PHYS * sizeof(U32) * 3]; static U32 * _pBuffer_DMA2D = &_aBuffer[XSIZE_PHYS * sizeof(U32) * 0]; /* Array of color conversions for each layer */ static const LCD_API_COLOR_CONV * _apColorConvAPI[] = { COLOR_CONVERSION_0, #if GUI_NUM_LAYERS > 1 COLOR_CONVERSION_1, #endif ...}; /* Array of orientations for each layer */ static const int _aOrientation[] = { ORIENTATION_0, #if GUI_NUM_LAYERS > 1 ORIENTATION_1, #endif ...}; /** * @} *//* ... */ /** @defgroup LCD CONFIGURATION_Private_FunctionPrototypes * @{ *//* ... */ static void _DMA_Index2ColorBulk(void * pIndex, LCD_COLOR * pColor, U32 NumItems, U8 SizeOfIndex, U32 PixelFormat); static void _DMA_Color2IndexBulk(LCD_COLOR * pColor, void * pIndex, U32 NumItems, U8 SizeOfIndex, U32 PixelFormat); /* Color conversion routines using DMA2D */ DEFINE_DMA2D_COLORCONVERSION(M8888I, LTDC_PIXEL_FORMAT_ARGB8888) /* Internal pixel format of emWin is 32 bit, because of that ARGB8888 */ DEFINE_DMA2D_COLORCONVERSION(M888, LTDC_PIXEL_FORMAT_ARGB8888) DEFINE_DMA2D_COLORCONVERSION(M565, LTDC_PIXEL_FORMAT_RGB565) DEFINE_DMA2D_COLORCONVERSION(M1555I, LTDC_PIXEL_FORMAT_ARGB1555) DEFINE_DMA2D_COLORCONVERSION(M4444I, LTDC_PIXEL_FORMAT_ARGB4444) void LCD_SetUpdateRegion(int idx); void LCD_ReqTear(void); void DSI_IRQHandler(void); /** * @brief Get the used pixel format * @param LayerIndex: Layer index used * @retval LTDC pixel format *//* ... */ static U32 _GetPixelformat(int LayerIndex) { const LCD_API_COLOR_CONV * pColorConvAPI; if (LayerIndex >= GUI_COUNTOF(_apColorConvAPI)) { return 0; }if (LayerIndex >= GUI_COUNTOF(_apColorConvAPI)) { ... } pColorConvAPI = _apColorConvAPI[LayerIndex]; if (pColorConvAPI == GUICC_M8888I) { return LTDC_PIXEL_FORMAT_ARGB8888; }if (pColorConvAPI == GUICC_M8888I) { ... } else if (pColorConvAPI == GUICC_M888) { return LTDC_PIXEL_FORMAT_RGB888; }else if (pColorConvAPI == GUICC_M888) { ... } else if (pColorConvAPI == GUICC_M565) { return LTDC_PIXEL_FORMAT_RGB565; }else if (pColorConvAPI == GUICC_M565) { ... } else if (pColorConvAPI == GUICC_M1555I) { return LTDC_PIXEL_FORMAT_ARGB1555; }else if (pColorConvAPI == GUICC_M1555I) { ... } else if (pColorConvAPI == GUICC_M4444I) { return LTDC_PIXEL_FORMAT_ARGB4444; }else if (pColorConvAPI == GUICC_M4444I) { ... } else if (pColorConvAPI == GUICC_8666 ) { return LTDC_PIXEL_FORMAT_L8; }else if (pColorConvAPI == GUICC_8666) { ... } else if (pColorConvAPI == GUICC_1616I ) { return LTDC_PIXEL_FORMAT_AL44; }else if (pColorConvAPI == GUICC_1616I) { ... } else if (pColorConvAPI == GUICC_88666I) { return LTDC_PIXEL_FORMAT_AL88; }else if (pColorConvAPI == GUICC_88666I) { ... } /* We'll hang in case of bad configuration */ while (1); }{ ... } /** * @brief Enable/Disable the DMA2D interrupt * @param DMA2D_IT: DM2D interrupt to enable * @param NewState: ENABLE/DISABLE * @retval LTDC pixel format *//* ... */ static void _DMA2D_ITConfig(U32 DMA2D_IT, int NewState) { if (NewState != DISABLE) { DMA2D->CR |= DMA2D_IT; }if (NewState != DISABLE) { ... } else { DMA2D->CR &= (U32)~DMA2D_IT; }else { ... } }{ ... } /** * @brief DCS or Generic short/long write command * @param NbParams: Number of parameters. It indicates the write command mode: * If inferior to 2, a long write command is performed else short. * @param pParams: Pointer to parameter values table. * @retval None *//* ... */ void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams) { if(NbrParams <= 1) { HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); }if (NbrParams <= 1) { ... } else { HAL_DSI_LongWrite(&hdsi, 0, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams); }else { ... } }{ ... } /** * @brief BSP LCD Reset * Hw reset the LCD DSI activating its XRES signal (active low for some time) * and desactivating it later. * This signal is only cabled on eval Rev B and beyond. *//* ... */ static void LCD_LL_Reset(void) { GPIO_InitTypeDef gpio_init_structure; __HAL_RCC_GPIOK_CLK_ENABLE(); /* Configure the GPIO on PK7 */ gpio_init_structure.Pin = GPIO_PIN_7; gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; gpio_init_structure.Pull = GPIO_PULLUP; gpio_init_structure.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOK, &gpio_init_structure); /* Activate XRES active low */ HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_RESET); HAL_Delay(20); /* wait 20 ms */ /* Deactivate XRES */ HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_SET); HAL_Delay(10); /* wait 10 ms */ }{ ... } /** * @brief Initialize the BSP LCD Msp. * Application can surcharge if needed this function implementation *//* ... */ void BSP_LCD_MspInit(void) { /** @brief Enable the LTDC clock */ __HAL_RCC_LTDC_CLK_ENABLE(); /** @brief Toggle Sw reset of LTDC IP */ __HAL_RCC_LTDC_FORCE_RESET(); __HAL_RCC_LTDC_RELEASE_RESET(); /** @brief Enable the DMA2D clock */ __HAL_RCC_DMA2D_CLK_ENABLE(); /** @brief Toggle Sw reset of DMA2D IP */ __HAL_RCC_DMA2D_FORCE_RESET(); __HAL_RCC_DMA2D_RELEASE_RESET(); /** @brief Enable DSI Host and wrapper clocks */ __HAL_RCC_DSI_CLK_ENABLE(); /** @brief Soft Reset the DSI Host and wrapper */ __HAL_RCC_DSI_FORCE_RESET(); __HAL_RCC_DSI_RELEASE_RESET(); /** @brief NVIC configuration for DSI interrupt that is now enabled */ HAL_NVIC_SetPriority(LTDC_IRQn, 0xF, 0); HAL_NVIC_EnableIRQ(LTDC_IRQn); /** @brief NVIC configuration for DSI interrupt that is now enabled */ HAL_NVIC_SetPriority(DSI_IRQn, 0xF, 0); HAL_NVIC_EnableIRQ(DSI_IRQn); _DMA2D_ITConfig(DMA2D_CR_TCIE, ENABLE); HAL_NVIC_SetPriority(DMA2D_IRQn, 0xF, 0x0); HAL_NVIC_EnableIRQ(DMA2D_IRQn); }{ ... } /** * @brief Initialize the LTDC * @param None * @retval None *//* ... */ static void LTDC_Init(void) { /* DeInit */ hltdc.Instance = LTDC; HAL_LTDC_DeInit(&hltdc); /* LTDC Config */ /* Timing and polarity */ hltdc.Init.HorizontalSync = HSYNC; hltdc.Init.VerticalSync = VSYNC; hltdc.Init.AccumulatedHBP = HSYNC+HBP; hltdc.Init.AccumulatedVBP = VSYNC+VBP; hltdc.Init.AccumulatedActiveH = VSYNC+VBP+VACT; hltdc.Init.AccumulatedActiveW = HSYNC+HBP+HACT; hltdc.Init.TotalHeigh = VSYNC+VBP+VACT+VFP; hltdc.Init.TotalWidth = HSYNC+HBP+HACT+HFP; /* background value */ hltdc.Init.Backcolor.Blue = 0; hltdc.Init.Backcolor.Green = 0; hltdc.Init.Backcolor.Red = 0; /* Polarity */ hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL; hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc.Instance = LTDC; HAL_LTDC_Init(&hltdc); }{ ... } /** * @brief Initialize the LCD Controller. * @param None * @retval None *//* ... */ static void LCD_LL_Init(void) { RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; GPIO_InitTypeDef GPIO_Init_Structure; static DSI_PHY_TimerTypeDef PhyTimings; static DSI_CmdCfgTypeDef CmdCfg; static DSI_LPCmdTypeDef LPCmd; static DSI_PLLInitTypeDef PLLInit; /* Toggle Hardware Reset of the DSI LCD using * its XRES signal (active low) *//* ... */ LCD_LL_Reset(); /* Call first MSP Initialize only in case of first initialization * This will set IP blocks LTDC, DSI and DMA2D * - out of reset * - clocked * - NVIC IRQ related to IP blocks enabled *//* ... */ BSP_LCD_MspInit(); /* LCD clock configuration */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */ /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */ hdsi.Instance = DSI; HAL_DSI_DeInit(&(hdsi)); PLLInit.PLLNDIV = 100; PLLInit.PLLIDF = DSI_PLL_IN_DIV5; PLLInit.PLLODF = DSI_PLL_OUT_DIV1; hdsi.Init.NumberOfLanes = DSI_TWO_DATA_LANES; hdsi.Init.TXEscapeCkdiv = 0x4; HAL_DSI_Init(&(hdsi), &(PLLInit)); /* Configure the DSI for Command mode */ CmdCfg.VirtualChannelID = 0; CmdCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; CmdCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; CmdCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; CmdCfg.ColorCoding = DSI_RGB565; CmdCfg.CommandSize = HACT; CmdCfg.TearingEffectSource = DSI_TE_EXTERNAL; CmdCfg.TearingEffectPolarity = DSI_TE_RISING_EDGE; CmdCfg.VSyncPol = DSI_VSYNC_FALLING; CmdCfg.AutomaticRefresh = DSI_AR_DISABLE; CmdCfg.TEAcknowledgeRequest = DSI_TE_ACKNOWLEDGE_ENABLE; HAL_DSI_ConfigAdaptedCommandMode(&hdsi, &CmdCfg); LPCmd.LPGenShortWriteNoP = DSI_LP_GSW0P_ENABLE; LPCmd.LPGenShortWriteOneP = DSI_LP_GSW1P_ENABLE; LPCmd.LPGenShortWriteTwoP = DSI_LP_GSW2P_ENABLE; LPCmd.LPGenShortReadNoP = DSI_LP_GSR0P_ENABLE; LPCmd.LPGenShortReadOneP = DSI_LP_GSR1P_ENABLE; LPCmd.LPGenShortReadTwoP = DSI_LP_GSR2P_ENABLE; LPCmd.LPGenLongWrite = DSI_LP_GLW_ENABLE; LPCmd.LPDcsShortWriteNoP = DSI_LP_DSW0P_ENABLE; LPCmd.LPDcsShortWriteOneP = DSI_LP_DSW1P_ENABLE; LPCmd.LPDcsShortReadNoP = DSI_LP_DSR0P_ENABLE; LPCmd.LPDcsLongWrite = DSI_LP_DLW_ENABLE; HAL_DSI_ConfigCommand(&hdsi, &LPCmd); /* Configure DSI PHY HS2LP and LP2HS timings */ PhyTimings.ClockLaneHS2LPTime = 35; PhyTimings.ClockLaneLP2HSTime = 35; PhyTimings.DataLaneHS2LPTime = 35; PhyTimings.DataLaneLP2HSTime = 35; PhyTimings.DataLaneMaxReadTime = 0; PhyTimings.StopWaitTime = 10; HAL_DSI_ConfigPhyTimer(&hdsi, &PhyTimings); /* Initialize LTDC */ LTDC_Init(); /* Start DSI */ HAL_DSI_Start(&(hdsi)); /* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver) * depending on configuration set in 'hdsivideo_handle'. *//* ... */ /* Send Display off DCS Command to display */ HAL_DSI_ShortWrite(&(hdsi), 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPOFF, 0x00); OTM8009A_Init(OTM8009A_FORMAT_RBG565, LCD_ORIENTATION_LANDSCAPE); LPCmd.LPGenShortWriteNoP = DSI_LP_GSW0P_DISABLE; LPCmd.LPGenShortWriteOneP = DSI_LP_GSW1P_DISABLE; LPCmd.LPGenShortWriteTwoP = DSI_LP_GSW2P_DISABLE; LPCmd.LPGenShortReadNoP = DSI_LP_GSR0P_DISABLE; LPCmd.LPGenShortReadOneP = DSI_LP_GSR1P_DISABLE; LPCmd.LPGenShortReadTwoP = DSI_LP_GSR2P_DISABLE; LPCmd.LPGenLongWrite = DSI_LP_GLW_DISABLE; LPCmd.LPDcsShortWriteNoP = DSI_LP_DSW0P_DISABLE; LPCmd.LPDcsShortWriteOneP = DSI_LP_DSW1P_DISABLE; LPCmd.LPDcsShortReadNoP = DSI_LP_DSR0P_DISABLE; LPCmd.LPDcsLongWrite = DSI_LP_DLW_DISABLE; HAL_DSI_ConfigCommand(&hdsi, &LPCmd); HAL_DSI_ConfigFlowControl(&hdsi, DSI_FLOW_CONTROL_BTA); /* Enable GPIOJ clock */ __HAL_RCC_GPIOJ_CLK_ENABLE(); /* Configure DSI_TE pin from MB1166 : Tearing effect on separated GPIO from KoD LCD */ /* that is mapped on GPIOJ2 as alternate DSI function (DSI_TE) */ /* This pin is used only when the LCD and DSI link is configured in command mode */ /* Not used in DSI Video mode. */ GPIO_Init_Structure.Pin = GPIO_PIN_2; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; GPIO_Init_Structure.Alternate = GPIO_AF13_DSI; HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); }{ ... } /** * @brief Initialise the LCD Controller * @param LayerIndex : layer Index. * @retval None *//* ... */ static void LCD_LL_LayerInit(U32 LayerIndex, U32 address) { static uint32_t LUT[256]; uint32_t i; if (LayerIndex < GUI_NUM_LAYERS) { LTDC_LayerCfgTypeDef Layercfg; /* Layer Init */ Layercfg.WindowX0 = 0; Layercfg.WindowX1 = HACT; Layercfg.WindowY0 = 0; Layercfg.WindowY1 = YSIZE_PHYS; Layercfg.PixelFormat = _GetPixelformat(LayerIndex); Layercfg.FBStartAdress = address; Layercfg.Alpha = 255; Layercfg.Alpha0 = 0; Layercfg.Backcolor.Blue = 0; Layercfg.Backcolor.Green = 0; Layercfg.Backcolor.Red = 0; Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; Layercfg.ImageWidth = HACT; Layercfg.ImageHeight = YSIZE_PHYS; HAL_LTDC_ConfigLayer(&hltdc, &Layercfg, LayerIndex); /* Enable LUT on demand */ if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8) { /* Enable usage of LUT for all modes with <= 8bpp*/ HAL_LTDC_EnableCLUT(&hltdc, LayerIndex); }if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8) { ... } else { /* Optional CLUT initialization for AL88 mode (16bpp)*/ if (layer_prop[LayerIndex].pColorConvAPI == GUICC_88666I) { HAL_LTDC_EnableCLUT(&hltdc, LayerIndex); for (i = 0; i < 256; i++) { LUT[i] = LCD_API_ColorConv_8666.pfIndex2Color(i); }for (i = 0; i < 256; i++) { ... } HAL_LTDC_ConfigCLUT(&hltdc, LUT, 256, LayerIndex); }if (layer_prop[LayerIndex].pColorConvAPI == GUICC_88666I) { ... } }else { ... } }if (LayerIndex < GUI_NUM_LAYERS) { ... } }{ ... } /** * @brief DMA2D interrupt handler * @param None * @retval None *//* ... */ void DMA2D_IRQHandler(void) { /* Clear the Transfer complete interrupt */ DMA2D->IFCR = (U32)DMA2D_IFSR_CTCIF; DMA2D->IFCR = (U32)DMA2D_IFCR_CCTCIF; /* Release the DMA2D for the next transfer */ TransferInProgress = 0; }{ ... } /** * @brief DMA2D wait for interrupt * @param None * @retval None *//* ... */ static void _DMA2D_ExecOperation(void) { /* If no concurrent operation, do not wait */ if ( TransferInProgress == 0 ) return; /* Wait until the transfer is done */ while(TransferInProgress) { }while (TransferInProgress) { ... } }{ ... } /** * @brief DMA2D Copy buffers * @param LayerIndex: Layer index * @param pSrc : Source buffer pointer * @param pDst : Destination buffer pointer * @param xSize : Horizontal size * @param ySize : Vertical size * @param OffLineSrc: Source Line offset * @param OffLineDst: Destination Line offset * @retval None *//* ... */ static void _DMA_Copy(int LayerIndex, void * pSrc, void * pDst, int xSize, int ySize, int OffLineSrc, int OffLineDst) { U32 PixelFormat; /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Get the layer pixel format used */ PixelFormat = _GetPixelformat(LayerIndex); /* Setup DMA2D Configuration */ DMA2D->CR = 0x00000000UL | (1 << 9); DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = OffLineSrc; DMA2D->OOR = OffLineDst; DMA2D->FGPFCCR = PixelFormat; DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief DMA2D Copy RGB 565 buffer * @param pSrc : Source buffer pointer * @param pDst : Destination buffer pointer * @param xSize : Horizontal size * @param ySize : Vertical size * @param OffLineSrc: Source Line offset * @param OffLineDst: Destination Line offset * @retval None *//* ... */ static void _DMA_CopyRGB565(const void * pSrc, void * pDst, int xSize, int ySize, int OffLineSrc, int OffLineDst) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00000000UL | (1 << 9); DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = OffLineSrc; DMA2D->OOR = OffLineDst; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_RGB565; DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief DMA2D Fill buffer * @param LayerIndex: Layer index * @param pDst : Destination buffer pointer * @param xSize : Horizontal size * @param ySize : Vertical size * @param OffLineSrc: Source Line offset * @param OffLineDst: Destination Line offset * @param ColorIndex: Color to be used for the Fill operation * @retval None *//* ... */ static void _DMA_Fill(int LayerIndex, void * pDst, int xSize, int ySize, int OffLine, U32 ColorIndex) { U32 PixelFormat; /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Get the layer pixel format used */ PixelFormat = _GetPixelformat(LayerIndex); /* Setup DMA2D Configuration */ DMA2D->CR = 0x00030000UL | (1 << 9); DMA2D->OCOLR = ColorIndex; DMA2D->OMAR = (U32)pDst; DMA2D->OOR = OffLine; DMA2D->OPFCCR = PixelFormat; DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief DMA2D Alpha blending bulk * @param pColorFG : Foregroung color * @param pColorBG : Background color * @param pColorDst: Destination color * @param NumItems : Number of lines * @retval None *//* ... */ static void _DMA_AlphaBlendingBulk(LCD_COLOR * pColorFG, LCD_COLOR * pColorBG, LCD_COLOR * pColorDst, U32 NumItems) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00020000UL | (1 << 9); DMA2D->FGMAR = (U32)pColorFG; DMA2D->BGMAR = (U32)pColorBG; DMA2D->OMAR = (U32)pColorDst; DMA2D->FGOR = 0; DMA2D->BGOR = 0; DMA2D->OOR = 0; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->BGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->OPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->NLR = (U32)(NumItems << 16) | 1; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief Mixing bulk colors * @param pColorFG : Foregroung color * @param pColorBG : Background color * @param pColorDst: Destination color * @param Intens : Color intensity * @param NumItems : Number of lines * @retval None *//* ... */ static void _DMA_MixColorsBulk(LCD_COLOR * pColorFG, LCD_COLOR * pColorBG, LCD_COLOR * pColorDst, U8 Intens, U32 NumItems) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00020000UL | (1 << 9); DMA2D->FGMAR = (U32)pColorFG; DMA2D->BGMAR = (U32)pColorBG; DMA2D->OMAR = (U32)pColorDst; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888 | (1UL << 16) | ((U32)Intens << 24); DMA2D->BGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888 | (0UL << 16) | ((U32)(255 - Intens) << 24); DMA2D->OPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->NLR = (U32)(NumItems << 16) | 1; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief Color conversion * @param pSrc : Source buffer * @param pDst : Destination buffer * @param PixelFormatSrc: Source pixel format * @param PixelFormatDst: Destination pixel format * @param NumItems : Number of lines * @retval None *//* ... */ static void _DMA_ConvertColor(void * pSrc, void * pDst, U32 PixelFormatSrc, U32 PixelFormatDst, U32 NumItems) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00010000UL | (1 << 9); DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = 0; DMA2D->OOR = 0; DMA2D->FGPFCCR = PixelFormatSrc; DMA2D->OPFCCR = PixelFormatDst; DMA2D->NLR = (U32)(NumItems << 16) | 1; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief Draw L8 picture * @param pSrc : Source buffer * @param pDst : Destination buffer * @param OffSrc : Source Offset * @param OffDst : Destination Offset * @param PixelFormatDst: Destination pixel format * @param xSize : Picture horizontal size * @param ySize : Picture vertical size * @retval None *//* ... */ static void _DMA_DrawBitmapL8(void * pSrc, void * pDst, U32 OffSrc, U32 OffDst, U32 PixelFormatDst, U32 xSize, U32 ySize) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00010000UL | (1 << 9); DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = OffSrc; DMA2D->OOR = OffDst; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_L8; DMA2D->OPFCCR = PixelFormatDst; DMA2D->NLR = (U32)(xSize << 16) | ySize; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief Draw A4 picture * @param pSrc : Source buffer * @param pDst : Destination buffer * @param OffSrc : Source Offset * @param OffDst : Destination Offset * @param PixelFormatDst: Destination pixel format * @param xSize : Picture horizontal size * @param ySize : Picture vertical size * @retval int *//* ... */ static int _DMA_DrawBitmapA4(void * pSrc, void * pDst, U32 OffSrc, U32 OffDst, U32 PixelFormatDst, U32 xSize, U32 ySize) { U8 * pRD; U8 * pWR; U32 NumBytes, Color, Index; /* Check size of conversion buffer */ NumBytes = ((xSize + 1) & ~1) * ySize; if ((NumBytes > sizeof(_aBuffer)) || (NumBytes == 0)) { return 1; }if ((NumBytes > sizeof(_aBuffer)) || (NumBytes == 0)) { ... } /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Conversion (swapping nibbles) */ pWR = (U8 *)_aBuffer; pRD = (U8 *)pSrc; do { *pWR++ = _aMirror[*pRD++]; ...} while (--NumBytes); /* Get current drawing color (ARGB) */ Index = LCD_GetColorIndex(); Color = LCD_Index2Color(Index); /* Setup DMA2D Configuration */ DMA2D->CR = 0x00020000UL; DMA2D->FGCOLR = Color; DMA2D->FGMAR = (U32)_aBuffer; DMA2D->FGOR = 0; DMA2D->FGPFCCR = 0xA; DMA2D->NLR = (U32)((xSize + OffSrc) << 16) | ySize; DMA2D->BGMAR = (U32)pDst; DMA2D->BGOR = OffDst - OffSrc; DMA2D->BGPFCCR = PixelFormatDst; DMA2D->OMAR = DMA2D->BGMAR; DMA2D->OOR = DMA2D->BGOR; DMA2D->OPFCCR = DMA2D->BGPFCCR; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); return 0; }{ ... } /** * @brief Draw alpha bitmap * @param pDst : Destination buffer * @param pSrc : Source buffer * @param xSize : Picture horizontal size * @param ySize : Picture vertical size * @param OffLineSrc : Source line offset * @param OffLineDst : Destination line offset * @param PixelFormat: Pixel format * @retval None *//* ... */ static void _DMA_DrawAlphaBitmap(void * pDst, const void * pSrc, int xSize, int ySize, int OffLineSrc, int OffLineDst, int PixelFormat) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->CR = 0x00020000UL | (1 << 9); DMA2D->FGMAR = (U32)pSrc; DMA2D->BGMAR = (U32)pDst; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = OffLineSrc; DMA2D->BGOR = OffLineDst; DMA2D->OOR = OffLineDst; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->BGPFCCR = PixelFormat; DMA2D->OPFCCR = PixelFormat; DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; /* Start the transfer, and enable the transfer complete IT */ DMA2D->CR |= (1|DMA2D_IT_TC); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief Load LUT * @param pColor : CLUT address * @param NumItems: Number of items to load * @retval None *//* ... */ static void _DMA_LoadLUT(LCD_COLOR * pColor, U32 NumItems) { /* Wait if there is a transfer in progress */ _DMA2D_ExecOperation(); /* Take the TransferInProgress flag */ TransferInProgress = 1; /* Setup DMA2D Configuration */ DMA2D->FGCMAR = (U32)pColor; DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888 | ((NumItems - 1) & 0xFF) << 8; DMA2D->CR |= DMA2D_IT_CTC; /* Start loading */ DMA2D->FGPFCCR |= (1 << 5); /* Wait for the end of the transfer */ _DMA2D_ExecOperation(); }{ ... } /** * @brief DMA2D Alpha blending * @param pColorFG : Foreground color * @param pColorBG : Background color * @param pColorDst: Destination color * @param NumItems : Number of items * @retval None *//* ... */ static void _DMA_AlphaBlending(LCD_COLOR * pColorFG, LCD_COLOR * pColorBG, LCD_COLOR * pColorDst, U32 NumItems) { _DMA_AlphaBlendingBulk(pColorFG, pColorBG, pColorDst, NumItems); }{ ... } /** * @brief Converts the given index values to 32 bit colors. * @param pIndex : Index value * @param pColor : Color relative to the index * @param NumItems : Number of items * @param SizeOfIndex: Size of index color * @param PixelFormat: Pixel format * @retval None *//* ... */ static void _DMA_Index2ColorBulk(void * pIndex, LCD_COLOR * pColor, U32 NumItems, U8 SizeOfIndex, U32 PixelFormat) { _DMA_ConvertColor(pIndex, pColor, PixelFormat, LTDC_PIXEL_FORMAT_ARGB8888, NumItems); }{ ... } /** * @brief Converts a 32 bit colors to an index value. * @param pColor : Color relative to the index * @param pIndex : Index value * @param NumItems : Number of items * @param SizeOfIndex: Size of index color * @param PixelFormat: Pixel format * @retval None *//* ... */ static void _DMA_Color2IndexBulk(LCD_COLOR * pColor, void * pIndex, U32 NumItems, U8 SizeOfIndex, U32 PixelFormat) { _DMA_ConvertColor(pColor, pIndex, LTDC_PIXEL_FORMAT_ARGB8888, PixelFormat, NumItems); }{ ... } /** * @brief LCD Mix color bulk. * @param pFG : Foreground buffer * @param pBG : Background buffer * @param pDst : Destination buffer * @param OffFG : Foreground offset * @param OffBG : Background offset * @param OffDest: Destination offset * @param xSize : Horizontal size * @param ySize : Vertical size * @param Intens : Color Intensity * @retval None *//* ... */ static void _LCD_MixColorsBulk(U32 * pFG, U32 * pBG, U32 * pDst, unsigned OffFG, unsigned OffBG, unsigned OffDest, unsigned xSize, unsigned ySize, U8 Intens) { int y; GUI_USE_PARA(OffFG); GUI_USE_PARA(OffDest); /* Do the same operation for all the lines */ for (y = 0; y < ySize; y++) { /* Use DMA2D for mixing up */ _DMA_MixColorsBulk(pFG, pBG, pDst, Intens, xSize); pFG += xSize + OffFG; pBG += xSize + OffBG; pDst += xSize + OffDest; }for (y = 0; y < ySize; y++) { ... } }{ ... } /** * @brief Get buffer size. * @param LayerIndex: Layer index * @retval U32 : Buffer size *//* ... */ static U32 _GetBufferSize(int LayerIndex) { U32 BufferSize; BufferSize = _axSize[LayerIndex] * _aySize[LayerIndex] * _aBytesPerPixels[LayerIndex]; return BufferSize; }{ ... } /** * @brief LCD Copy buffer * @param LayerIndex: Layer index * @param IndexSrc : Source index * @param IndexDst : Destination index * @retval None *//* ... */ static void _LCD_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst) { U32 BufferSize, AddrSrc, AddrDst; BufferSize = _GetBufferSize(LayerIndex); AddrSrc = _aAddr[LayerIndex] + BufferSize * IndexSrc; AddrDst = _aAddr[LayerIndex] + BufferSize * IndexDst; _DMA_Copy(LayerIndex, (void *)AddrSrc, (void *)AddrDst, _axSize[LayerIndex], _aySize[LayerIndex], 0, 0); /* After this function has been called all drawing operations are routed to Buffer[IndexDst] */ _aBufferIndex[LayerIndex] = IndexDst; }{ ... } /** * @brief LCD Copy rectangle * @param LayerIndex: Layer index * @param x0 : Horizontal rect origin * @param y0 : Vertical rect origin * @param x1 : Horizontal rect end * @param y1 : Vertical rect end * @param xSize : Rectangle width * @param ySize : Rectangle height * @retval None *//* ... */ static void _LCD_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize) { U32 BufferSize, AddrSrc, AddrDst; int OffLine; BufferSize = _GetBufferSize(LayerIndex); AddrSrc = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y0 * _axSize[LayerIndex] + x0) * _aBytesPerPixels[LayerIndex]; AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y1 * _axSize[LayerIndex] + x1) * _aBytesPerPixels[LayerIndex]; OffLine = _axSize[LayerIndex] - xSize; _DMA_Copy(LayerIndex, (void *)AddrSrc, (void *)AddrDst, xSize, ySize, OffLine, OffLine); }{ ... } /** * @brief LCD fill rectangle * @param LayerIndex: Layer index * @param x0 : Horizontal rect origin * @param y0 : Vertical rect origin * @param x1 : Horizontal rect end * @param y1 : Vertical rect end * @param PixelIndex: Color to be used for the Fill operation * @retval None *//* ... */ static void _LCD_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex) { U32 BufferSize, AddrDst; int xSize, ySize; /* Depending on the draw mode, do it differently */ if (GUI_GetDrawMode() == GUI_DM_XOR) { /* Use SW Fill rectangle */ LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, NULL); LCD_FillRect(x0, y0, x1, y1); /* Then set custom callback function for fillrect operation */ LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, (void(*)(void))_LCD_FillRect); }if (GUI_GetDrawMode() == GUI_DM_XOR) { ... } else { xSize = x1 - x0 + 1; ySize = y1 - y0 + 1; BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y0 * _axSize[LayerIndex] + x0) * _aBytesPerPixels[LayerIndex]; _DMA_Fill(LayerIndex, (void *)AddrDst, xSize, ySize, _axSize[LayerIndex] - xSize, PixelIndex); }else { ... } }{ ... } /** * @brief Draw 32 bits per pixel bitmap * @param LayerIndex : Layer index * @param x : start horizontal position on the screen * @param y : start vertical position on the screen * @param p : Source buffer * @param xSize : Horizontal bitmap size * @param ySize : Vertical bitmap size * @param BytesPerLine: Number of bytes per Line * @retval None *//* ... */ static void _LCD_DrawBitmap32bpp(int LayerIndex, int x, int y, U16 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y * _axSize[LayerIndex] + x) * _aBytesPerPixels[LayerIndex]; OffLineSrc = (BytesPerLine / 4) - xSize; OffLineDst = _axSize[LayerIndex] - xSize; _DMA_Copy(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst); }{ ... } /** * @brief Draw 16 bits per pixel bitmap * @param LayerIndex : Layer index * @param x : start horizontal position on the screen * @param y : start vertical position on the screen * @param p : Source buffer * @param xSize : Horizontal bitmap size * @param ySize : Vertical bitmap size * @param BytesPerLine: Number of bytes per Line * @retval None *//* ... */ static void _LCD_DrawBitmap16bpp(int LayerIndex, int x, int y, U16 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y * _axSize[LayerIndex] + x) * _aBytesPerPixels[LayerIndex]; OffLineSrc = (BytesPerLine / 2) - xSize; OffLineDst = _axSize[LayerIndex] - xSize; _DMA_Copy(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst); }{ ... } /** * @brief Draw 8 bits per pixel bitmap * @param LayerIndex : Layer index * @param x : start horizontal position on the screen * @param y : start vertical position on the screen * @param p : Source buffer * @param xSize : Horizontal bitmap size * @param ySize : Vertical bitmap size * @param BytesPerLine: Number of bytes per Line * @retval None *//* ... */ static void _LCD_DrawBitmap8bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; U32 PixelFormat; PixelFormat = _GetPixelformat(LayerIndex); BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y * _axSize[LayerIndex] + x) * _aBytesPerPixels[LayerIndex]; OffLineSrc = BytesPerLine - xSize; OffLineDst = _axSize[LayerIndex] - xSize; _DMA_DrawBitmapL8((void *)p, (void *)AddrDst, OffLineSrc, OffLineDst, PixelFormat, xSize, ySize); }{ ... } /** * @brief Draw 4 bits per pixel bitmap * @param LayerIndex : Layer index * @param x : start horizontal position on the screen * @param y : start vertical position on the screen * @param p : Source buffer * @param xSize : Horizontal bitmap size * @param ySize : Vertical bitmap size * @param BytesPerLine: Number of bytes per Line * @retval int *//* ... */ static int _LCD_DrawBitmap4bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; U32 PixelFormat; if (x < 0) { return 1; }if (x < 0) { ... } if ((x + xSize) >= _axSize[LayerIndex]) { return 1; }if ((x + xSize) >= _axSize[LayerIndex]) { ... } if (y < 0) { return 1; }if (y < 0) { ... } if ((y + ySize) >= _aySize[LayerIndex]) { return 1; }if ((y + ySize) >= _aySize[LayerIndex]) { ... } PixelFormat = _GetPixelformat(LayerIndex); /* Check if destination has direct color mode */ if (PixelFormat > LTDC_PIXEL_FORMAT_ARGB4444) { return 1; }if (PixelFormat > LTDC_PIXEL_FORMAT_ARGB4444) { ... } BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y * _axSize[LayerIndex] + x) * _aBytesPerPixels[LayerIndex]; OffLineSrc = (BytesPerLine * 2) - xSize; OffLineDst = _axSize[LayerIndex] - xSize; return _DMA_DrawBitmapA4((void *)p, (void *)AddrDst, OffLineSrc, OffLineDst, PixelFormat, xSize, ySize);; }{ ... } /** * @brief Draw 16 bits per pixel memory device * @param pDst : Destination buffer * @param pSrc : Source buffer * @param xSize : Horizontal memory device size * @param ySize : Vertical memory device size * @param BytesPerLineDst: Destination number of bytes per Line * @param BytesPerLineSrc: Source number of bytes per Line * @retval None *//* ... */ static void _LCD_DrawMemdev16bpp(void * pDst, const void * pSrc, int xSize, int ySize, int BytesPerLineDst, int BytesPerLineSrc) { int OffLineSrc, OffLineDst; OffLineSrc = (BytesPerLineSrc / 2) - xSize; OffLineDst = (BytesPerLineDst / 2) - xSize; _DMA_CopyRGB565(pSrc, pDst, xSize, ySize, OffLineSrc, OffLineDst); }{ ... } /** * @brief Draw alpha memory device * @param pDst : Destination buffer * @param pSrc : Source buffer * @param xSize : Horizontal memory device size * @param ySize : Vertical memory device size * @param BytesPerLineDst: Destination number of bytes per Line * @param BytesPerLineSrc: Source number of bytes per Line * @retval None *//* ... */ static void _LCD_DrawMemdevAlpha(void * pDst, const void * pSrc, int xSize, int ySize, int BytesPerLineDst, int BytesPerLineSrc) { int OffLineSrc, OffLineDst; OffLineSrc = (BytesPerLineSrc / 4) - xSize; OffLineDst = (BytesPerLineDst / 4) - xSize; _DMA_DrawAlphaBitmap(pDst, pSrc, xSize, ySize, OffLineSrc, OffLineDst, LTDC_PIXEL_FORMAT_ARGB8888); }{ ... } /** * @brief Draw alpha Bitmap * @param LayerIndex : Layer index * @param x : Horizontal position on the screen * @param y : vertical position on the screen * @param xSize : Horizontal bitmap size * @param ySize : Vertical bitmap size * @param BytesPerLine: Bytes per Line * @retval None *//* ... */ static void _LCD_DrawBitmapAlpha(int LayerIndex, int x, int y, const void * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; U32 PixelFormat; PixelFormat = _GetPixelformat(LayerIndex); BufferSize = _GetBufferSize(LayerIndex); AddrDst = _aAddr[LayerIndex] + BufferSize * _aBufferIndex[LayerIndex] + (y * _axSize[LayerIndex] + x) * _aBytesPerPixels[LayerIndex]; OffLineSrc = (BytesPerLine / 4) - xSize; OffLineDst = _axSize[LayerIndex] - xSize; _DMA_DrawAlphaBitmap((void *)AddrDst, p, xSize, ySize, OffLineSrc, OffLineDst, PixelFormat); }{ ... } /** * @brief Translates the given colors into index values for the display controller * @param pLogPal : Palette * @param pBitmap : Bitmap * @param LayerIndex: Layer index * @retval LCD_PIXELINDEX *//* ... */ static LCD_PIXELINDEX * _LCD_GetpPalConvTable(const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, const GUI_BITMAP GUI_UNI_PTR * pBitmap, int LayerIndex) { void (* pFunc)(void); int DoDefault = 0; /* Check if we have a non transparent device independent bitmap */ if (pBitmap->BitsPerPixel == 8) { pFunc = LCD_GetDevFunc(LayerIndex, LCD_DEVFUNC_DRAWBMP_8BPP); if (pFunc) { if (pBitmap->pPal) { if (pBitmap->pPal->HasTrans) { DoDefault = 1; }if (pBitmap->pPal->HasTrans) { ... } }if (pBitmap->pPal) { ... } else { DoDefault = 1; }else { ... } }if (pFunc) { ... } else { DoDefault = 1; }else { ... } }if (pBitmap->BitsPerPixel == 8) { ... } else { DoDefault = 1; }else { ... } /* Default palette management for other cases */ if (DoDefault) { /* Return a pointer to the index values to be used by the controller */ return LCD_GetpPalConvTable(pLogPal); }if (DoDefault) { ... } /* Load LUT using DMA2D */ _DMA_LoadLUT((U32 *)pLogPal->pPalEntries, pLogPal->NumEntries); /* Return something not NULL */ return _pBuffer_DMA2D; }{ ... } /** * @brief Set LCD updated region. * @param idx: active region index. * @retval None *//* ... */ void LCD_SetUpdateRegion(int idx) { HAL_DSI_LongWrite(&hdsi, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_CASET, pCols[idx]); }{ ... } /** * @brief Tearing Effect DSI callback. * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains * the configuration information for the DSI. * @retval None *//* ... */ void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *hdsi) { uint32_t index = 0; __DSI_MASK_TE(); for(index = 0; index < GUI_NUM_LAYERS; index++) { if(_aPendingBuffer[index] >= 0) { GUI_MULTIBUF_ConfirmEx(index, _aPendingBuffer[index]); _aPendingBuffer[index] = -1; }if (_aPendingBuffer[index] >= 0) { ... } }for (index = 0; index < GUI_NUM_LAYERS; index++) { ... } LCD_ActiveRegion = 1; HAL_DSI_Refresh(hdsi); }{ ... } /** * @brief End of Refresh DSI callback. * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains * the configuration information for the DSI. * @retval None *//* ... */ void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi) { uint32_t index = 0; static uint32_t TestAdd = 0; if(LCD_ActiveRegion < ZONES ) { /* Disable DSI Wrapper */ __HAL_DSI_WRAPPER_DISABLE(hdsi); for(index = 0; index < GUI_NUM_LAYERS; index ++) { TestAdd = LCD_Addr[index]; /* Update LTDC configuration */ LTDC_LAYER(&hltdc, index)->CFBAR = TestAdd + LCD_ActiveRegion * HACT * 2; }for (index = 0; index < GUI_NUM_LAYERS; index ++) { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc); __HAL_DSI_WRAPPER_ENABLE(hdsi); LCD_SetUpdateRegion(LCD_ActiveRegion++); /* Refresh the right part of the display */ HAL_DSI_Refresh(hdsi); }if (LCD_ActiveRegion < ZONES) { ... } else { __HAL_DSI_WRAPPER_DISABLE(hdsi); for(index = 0; index < GUI_NUM_LAYERS; index ++) { LTDC_LAYER(&hltdc, index)->CFBAR = TestAdd; }for (index = 0; index < GUI_NUM_LAYERS; index ++) { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc); __HAL_DSI_WRAPPER_ENABLE(hdsi); LCD_SetUpdateRegion(0); LCD_Refershing = 0; }else { ... } }{ ... } /** * @brief Request TE at scanline. * @param None * @retval None *//* ... */ void LCD_ReqTear(void) { static uint8_t ScanLineParams[2]; #if (ZONES == 4 ) uint16_t scanline = 283; #elif (ZONES == 2 ) uint16_t scanline = 533; #endif ScanLineParams[0] = scanline >> 8; ScanLineParams[1] = scanline & 0x00FF; HAL_DSI_LongWrite(&hdsi, 0, DSI_DCS_LONG_PKT_WRITE, 2, 0x44, ScanLineParams); /* set_tear_on */ HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_TEEON, 0x00); }{ ... } /** * @brief Function is called by the display driver for several purposes * @param LayerIndex: Index of layer to be configured * @param Cmd : Commands * @param pData : Pointer to a LCD_X_DATA structure * @retval int *//* ... */ int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) { int r = 0; U32 addr; switch (Cmd) { case LCD_X_INITCONTROLLER: { /* Called during the initialization process in order to set up the display controller and put it into operation */ break; ...}case LCD_X_INITCONTROLLER: case LCD_X_SETORG: { /* Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p */ LCD_X_SETORG_INFO * p; p = (LCD_X_SETORG_INFO *)pData; addr = _aAddr[LayerIndex] + p->yPos * _axSize[LayerIndex] * _aBytesPerPixels[LayerIndex]; HAL_LTDC_SetAddress(&hltdc, addr, LayerIndex); break; ...}case LCD_X_SETORG: case LCD_X_SHOWBUFFER: { /* Required if multiple buffers are used. The 'Index' element of p contains the buffer index. */ LCD_X_SHOWBUFFER_INFO * p; p = (LCD_X_SHOWBUFFER_INFO *)pData; /* UnMask the tearing effect */ __DSI_UNMASK_TE(); LCD_Refershing = 1; /* Wait for the LCD_Refreshing */ while(LCD_Refershing); /* Update the index of the buffer to use */ LCD_Addr[LayerIndex] = _aAddr[LayerIndex] + _axSize[LayerIndex] * _aySize[LayerIndex] * _aBytesPerPixels[LayerIndex] * p->Index; _aPendingBuffer[LayerIndex] = p->Index; __HAL_DSI_WRAPPER_DISABLE(&hdsi); LTDC_LAYER(&hltdc, LayerIndex)->CFBAR = LCD_Addr[LayerIndex]; __HAL_LTDC_RELOAD_CONFIG(&hltdc); __HAL_DSI_WRAPPER_ENABLE(&hdsi); break; ...}case LCD_X_SHOWBUFFER: case LCD_X_SETLUTENTRY: { /* Required for setting a lookup table entry which is passed in the 'Pos' and 'Color' element of p */ LCD_X_SETLUTENTRY_INFO * p; p = (LCD_X_SETLUTENTRY_INFO *)pData; HAL_LTDC_ConfigCLUT(&hltdc, (uint32_t*)p->Color, p->Pos, LayerIndex); break; ...}case LCD_X_SETLUTENTRY: case LCD_X_ON: { /* Required if the display controller should support switching on and off */ __HAL_LTDC_ENABLE(&hltdc); break; ...}case LCD_X_ON: case LCD_X_OFF: { /* Required if the display controller should support switching on and off */ __HAL_LTDC_DISABLE(&hltdc); break; ...}case LCD_X_OFF: case LCD_X_SETVIS: { /* Required for setting the layer visibility which is passed in the 'OnOff' element of pData */ LCD_X_SETVIS_INFO * p; p = (LCD_X_SETVIS_INFO *)pData; if(p->OnOff == ENABLE ) { __HAL_DSI_WRAPPER_DISABLE(&hdsi); __HAL_LTDC_LAYER_ENABLE(&hltdc, LayerIndex); __HAL_DSI_WRAPPER_ENABLE(&hdsi); }if (p->OnOff == ENABLE) { ... } else { __HAL_DSI_WRAPPER_DISABLE(&hdsi); __HAL_LTDC_LAYER_DISABLE(&hltdc, LayerIndex); __HAL_DSI_WRAPPER_ENABLE(&hdsi); }else { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc); HAL_DSI_Refresh(&hdsi); break; ...}case LCD_X_SETVIS: case LCD_X_SETPOS: { /* Required for setting the layer position which is passed in the 'xPos' and 'yPos' element of pData */ LCD_X_SETPOS_INFO * p; p = (LCD_X_SETPOS_INFO *)pData; HAL_LTDC_SetWindowPosition(&hltdc, p->xPos, p->yPos, LayerIndex); break; ...}case LCD_X_SETPOS: case LCD_X_SETSIZE: { /* Required for setting the layer position which is passed in the 'xPos' and 'yPos' element of pData */ LCD_X_SETSIZE_INFO * p; int xPos, yPos; GUI_GetLayerPosEx(LayerIndex, &xPos, &yPos); p = (LCD_X_SETSIZE_INFO *)pData; if (LCD_GetSwapXYEx(LayerIndex)) { _axSize[LayerIndex] = p->ySize; _aySize[LayerIndex] = p->xSize; }if (LCD_GetSwapXYEx(LayerIndex)) { ... } else { _axSize[LayerIndex] = p->xSize; _aySize[LayerIndex] = p->ySize; }else { ... } HAL_LTDC_SetWindowPosition(&hltdc, xPos, yPos, LayerIndex); break; ...}case LCD_X_SETSIZE: case LCD_X_SETALPHA: { /* Required for setting the alpha value which is passed in the 'Alpha' element of pData */ LCD_X_SETALPHA_INFO * p; p = (LCD_X_SETALPHA_INFO *)pData; HAL_LTDC_SetAlpha(&hltdc, p->Alpha, LayerIndex); break; ...}case LCD_X_SETALPHA: case LCD_X_SETCHROMAMODE: { /* Required for setting the chroma mode which is passed in the 'ChromaMode' element of pData */ LCD_X_SETCHROMAMODE_INFO * p; p = (LCD_X_SETCHROMAMODE_INFO *)pData; if(p->ChromaMode != 0) { HAL_LTDC_EnableColorKeying(&hltdc, LayerIndex); }if (p->ChromaMode != 0) { ... } else { HAL_LTDC_DisableColorKeying(&hltdc, LayerIndex); }else { ... } break; ...}case LCD_X_SETCHROMAMODE: case LCD_X_SETCHROMA: { /* Required for setting the chroma value which is passed in the 'ChromaMin' and 'ChromaMax' element of pData */ LCD_X_SETCHROMA_INFO * p; U32 Color; p = (LCD_X_SETCHROMA_INFO *)pData; Color = ((p->ChromaMin & 0xFF0000) >> 16) | (p->ChromaMin & 0x00FF00) | ((p->ChromaMin & 0x0000FF) << 16); HAL_LTDC_ConfigColorKeying(&hltdc, Color, LayerIndex); break; ...}case LCD_X_SETCHROMA: default: r = -1; break;default }switch (Cmd) { ... } return r; }{ ... } /** * @brief Called during the initialization process in order to set up the * display driver configuration * @param None * @retval None *//* ... */ void LCD_X_Config(void) { int i; U32 PixelFormat; /* At first initialize use of multiple buffers on demand */ #if (NUM_BUFFERS > 1) for (i = 0; i < GUI_NUM_LAYERS; i++) { GUI_MULTIBUF_ConfigEx(i, NUM_BUFFERS); }for (i = 0; i < GUI_NUM_LAYERS; i++) { ... } /* ... */#endif /* Set display driver and color conversion for 1st layer */ GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_0, COLOR_CONVERSION_0, 0, 0); /* Set size of 1st layer */ if (LCD_GetSwapXYEx(0)) { LCD_SetSizeEx (0, YSIZE_0, XSIZE_0); LCD_SetVSizeEx(0, YSIZE_0 * NUM_VSCREENS, XSIZE_0); }if (LCD_GetSwapXYEx(0)) { ... } else { LCD_SetSizeEx (0, XSIZE_0, YSIZE_0); LCD_SetVSizeEx(0, XSIZE_0, YSIZE_0 * NUM_VSCREENS); }else { ... } #if (GUI_NUM_LAYERS > 1) /* Set display driver and color conversion for 2nd layer */ GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_1, COLOR_CONVERSION_1, 0, 1); /* Set size of 2nd layer */ if (LCD_GetSwapXYEx(1)) { LCD_SetSizeEx (1, YSIZE_0, XSIZE_1); LCD_SetVSizeEx(1, YSIZE_1 * NUM_VSCREENS, XSIZE_1); }if (LCD_GetSwapXYEx(1)) { ... } else { LCD_SetSizeEx (1, XSIZE_1, YSIZE_1); LCD_SetVSizeEx(1, XSIZE_1, YSIZE_1 * NUM_VSCREENS); }else { ... } /* ... */#endif /* Setting up VRam address and get the pixel size */ for (i = 0; i < GUI_NUM_LAYERS; i++) { /* Setting up VRam address */ LCD_SetVRAMAddrEx(i, (void *)(_aAddr[i])); /* Get the pixel size */ _aBytesPerPixels[i] = LCD_GetBitsPerPixelEx(i) >> 3; }for (i = 0; i < GUI_NUM_LAYERS; i++) { ... } /* Setting up custom functions */ for (i = 0; i < GUI_NUM_LAYERS; i++) { PixelFormat = _GetPixelformat(i); /* Set custom function for copying complete buffers (used by multiple buffering) using DMA2D */ LCD_SetDevFunc(i, LCD_DEVFUNC_COPYBUFFER, (void(*)(void))_LCD_CopyBuffer); if (PixelFormat <= LTDC_PIXEL_FORMAT_ARGB4444) { /* Set custom function for filling operations using DMA2D */ LCD_SetDevFunc(i, LCD_DEVFUNC_FILLRECT, (void(*)(void))_LCD_FillRect); }if (PixelFormat <= LTDC_PIXEL_FORMAT_ARGB4444) { ... } if (_aOrientation[i] == ROTATION_0) { /* Set custom function for copy recxtangle areas (used by GUI_CopyRect()) using DMA2D */ LCD_SetDevFunc(i, LCD_DEVFUNC_COPYRECT, (void(*)(void))_LCD_CopyRect); /* Set functions for direct color mode layers. Won't work with indexed color modes because of missing LUT for DMA2D destination */ if (PixelFormat <= LTDC_PIXEL_FORMAT_ARGB4444) { /* Set up custom drawing routine for index based bitmaps using DMA2D */ LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_8BPP, (void(*)(void))_LCD_DrawBitmap8bpp); }if (PixelFormat <= LTDC_PIXEL_FORMAT_ARGB4444) { ... } /* Set up drawing routine for 16bpp bitmap using DMA2D */ if (PixelFormat == LTDC_PIXEL_FORMAT_RGB565) { /* Set up drawing routine for 16bpp bitmap using DMA2D. Makes only sense with RGB565 */ LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_16BPP, (void(*)(void))_LCD_DrawBitmap16bpp); }if (PixelFormat == LTDC_PIXEL_FORMAT_RGB565) { ... } /* Set up drawing routine for 32bpp bitmap using DMA2D */ if (PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) { /* Set up drawing routine for 32bpp bitmap using DMA2D. Makes only sense with ARGB8888 */ LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_32BPP, (void(*)(void))_LCD_DrawBitmap32bpp); }if (PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) { ... } }if (_aOrientation[i] == ROTATION_0) { ... } }for (i = 0; i < GUI_NUM_LAYERS; i++) { ... } /* Set up custom color conversion using DMA2D, works only for direct color modes because of missing LUT for DMA2D destination */ /* Set up custom bulk color conversion using DMA2D for ARGB1555 */ GUICC_M1555I_SetCustColorConv(_Color2IndexBulk_M1555I_DMA2D, _Index2ColorBulk_M1555I_DMA2D); /* Set up custom bulk color conversion using DMA2D for RGB565 */ GUICC_M565_SetCustColorConv (_Color2IndexBulk_M565_DMA2D, _Index2ColorBulk_M565_DMA2D); /* Set up custom bulk color conversion using DMA2D for ARGB4444 */ GUICC_M4444I_SetCustColorConv(_Color2IndexBulk_M4444I_DMA2D, _Index2ColorBulk_M4444I_DMA2D); /* Set up custom bulk color conversion using DMA2D for RGB888 */ GUICC_M888_SetCustColorConv (_Color2IndexBulk_M888_DMA2D, _Index2ColorBulk_M888_DMA2D); /* Set up custom bulk color conversion using DMA2D for ARGB8888 */ GUICC_M8888I_SetCustColorConv(_Color2IndexBulk_M8888I_DMA2D, _Index2ColorBulk_M8888I_DMA2D); /* Set up custom alpha blending function using DMA2D */ GUI_SetFuncAlphaBlending(_DMA_AlphaBlending); /* Set up custom function for translating a bitmap palette into index values. * Required to load a bitmap palette into DMA2D CLUT in case of a 8bpp indexed bitmap *//* ... */ GUI_SetFuncGetpPalConvTable(_LCD_GetpPalConvTable); /* Set up custom function for mixing up arrays of colors using DMA2D */ GUI_SetFuncMixColorsBulk(_LCD_MixColorsBulk); /* Set up custom function for drawing AA4 characters */ GUI_AA_SetpfDrawCharAA4(_LCD_DrawBitmap4bpp); #if GUI_SUPPORT_MEMDEV /* Set up custom function for drawing 16bpp memory devices */ GUI_MEMDEV_SetDrawMemdev16bppFunc(_LCD_DrawMemdev16bpp); /* Set up custom function for Alpha drawing operations */ GUI_SetFuncDrawAlpha(_LCD_DrawMemdevAlpha, _LCD_DrawBitmapAlpha);/* ... */ #endif /* Complete the initialisation */ LCD_LL_Init (); __HAL_DSI_WRAPPER_DISABLE(&hdsi); LCD_LL_LayerInit(0, _aAddr[0]); HAL_LTDC_SetPitch(&hltdc, XSIZE_PHYS, 0); #if (GUI_NUM_LAYERS > 1) LCD_LL_LayerInit(1, _aAddr[1]); HAL_LTDC_SetPitch(&hltdc, XSIZE_PHYS, 1);/* ... */ #endif __HAL_DSI_WRAPPER_ENABLE(&hdsi); HAL_DSI_LongWrite(&hdsi, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_CASET, pCols[0]); HAL_DSI_LongWrite(&hdsi, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_PASET, pPage); HAL_Delay(20); LCD_ReqTear(); /* Send Display off DCS Command to display */ HAL_DSI_ShortWrite(&(hdsi), 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPON, 0x00); }{ ... } /** * @brief This function handles DSI global interrupt request. * @param None * @retval None *//* ... */ void DSI_IRQHandler(void) { HAL_DSI_IRQHandler(&hdsi); }{ ... }
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.