Select one of the symbols to view example projects that use it.
 
Outline
#include "LCDConf.h"
#include "GUI_Private.h"
#define LCD_SWAP_XY
#define LCD_MIRROR_Y
#define XSIZE_PHYS
#define YSIZE_PHYS
#define ZONES
#define VSYNC
#define VBP
#define VFP
#define VACT
#define HSYNC
#define HBP
#define HFP
#define HACT
#define NUM_BUFFERS
#define NUM_VSCREENS
#define BK_COLOR
#define GUI_NUM_LAYERS
#define COLOR_CONVERSION_0
#define DISPLAY_DRIVER_0
#define COLOR_CONVERSION_1
#define DISPLAY_DRIVER_1
#define NUM_VSCREENS
#define LCD_LAYER0_FRAME_BUFFER
#define LCD_LAYER1_FRAME_BUFFER
#define __DSI_MASK_TE
#define __DSI_UNMASK_TE
hltdc_disco
hdsi_disco
pPage
pCols
layer_prop
LCD_ActiveRegion
LCD_Refershing
apColorConvAPI
LCD_Addr
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)
GetPixelformat(unsigned long)
DMA2D_CopyBuffer(unsigned long, void *, void *, unsigned long, unsigned long, unsigned long, unsigned long)
DMA2D_CopyBufferWithAlpha(unsigned long, void *, void *, unsigned long, unsigned long, unsigned long, unsigned long)
DMA2D_FillBuffer(unsigned long, void *, unsigned long, unsigned long, unsigned long, unsigned long)
GetBufferSize(unsigned long)
LCD_LL_CopyBuffer(int, int, int)
LCD_LL_CopyRect(int, int, int, int, int, int, int)
LCD_LL_FillRect(int, int, int, int, int, unsigned long)
DMA2D_DrawBitmapL8(void *, void *, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
LCD_LL_DrawBitmap16bpp(int, int, int, const unsigned short *, int, int, int)
LCD_LL_DrawBitmap32bpp(int, int, int, const unsigned char *, int, int, int)
LCD_LL_DrawBitmap8bpp(int, int, int, const unsigned char *, int, int, int)
LCD_SetUpdateRegion(int)
HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *)
HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *)
LCD_ReqTear()
LCD_X_Config()
LCD_X_DisplayDriver(unsigned int, unsigned int, void *)
DSI_IRQHandler()
Files
loading...
CodeScopeSTM32 Libraries and SamplesSTemWinGui/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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/********************************************************************* * Portions COPYRIGHT(c) 2016 STMicroelectronics * * Portions SEGGER Microcontroller GmbH & Co. KG * * Solutions for real time microcontroller applications * ********************************************************************** * * * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG * * * * Internet: www.segger.com Support: support@segger.com * * * ********************************************************************** ** emWin V5.24 - Graphical user interface for embedded applications ** All Intellectual Property rights in the Software belongs to SEGGER. emWin is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with the following terms: The software has been licensed to STMicroelectronics International N.V. a Dutch company with a Swiss branch and its headquarters in Plan- les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_ troller products commercialized by Licensee only, sublicensed and dis_ tributed under the terms and conditions of the End User License Agree_ ment supplied by STMicroelectronics International N.V. Full source code is available at: www.segger.com We appreciate your understanding and fairness. ---------------------------------------------------------------------- File : LCDConf.c Purpose : Display controller configuration (single layer) ---------------------------END-OF-HEADER------------------------------ *//* ... */ /** ****************************************************************************** * @file LCDConf_stm32469i_discovery.c * @author MCD Application Team * @brief Driver for STM32469I-Discovery board LCD ****************************************************************************** * @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 * @{ *//* ... */ #undef LCD_SWAP_XY #undef LCD_MIRROR_Y #define LCD_SWAP_XY 1 #define LCD_MIRROR_Y 1 #define XSIZE_PHYS 800 #define YSIZE_PHYS 480 #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 /* !!!! SCREEN DIVIDED INTO 4 AREAS !!!! */ #define NUM_BUFFERS 3 /* Number of multiple buffers to be used */ #define NUM_VSCREENS 1 /* Number of virtual screens to be used */ #define BK_COLOR GUI_DARKBLUE 16 defines #undef GUI_NUM_LAYERS #define GUI_NUM_LAYERS 2 #define COLOR_CONVERSION_0 GUICC_M565 #define DISPLAY_DRIVER_0 GUIDRV_LIN_16 #if (GUI_NUM_LAYERS > 1) #define COLOR_CONVERSION_1 GUICC_M1555I #define DISPLAY_DRIVER_1 GUIDRV_LIN_16 /* ... */ #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_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 and multiple buffers are not allowed! #endif #define LCD_LAYER0_FRAME_BUFFER ((uint32_t)0xC0000000) #define LCD_LAYER1_FRAME_BUFFER ((uint32_t)0xC0400000) /** * @} *//* ... */ #define __DSI_MASK_TE() (GPIOJ->AFR[0] &= (0xFFFFF0FFU)) /* Mask DSI TearingEffect Pin*/ #define __DSI_UNMASK_TE() (GPIOJ->AFR[0] |= ((uint32_t)(GPIO_AF13_DSI) << 8)) /* UnMask DSI TearingEffect Pin*/ /** * @} *//* ... */ /** @defgroup LCD CONFIGURATION_Private_Variables * @{ *//* ... */ LTDC_HandleTypeDef hltdc_disco; DSI_HandleTypeDef hdsi_disco; uint8_t pPage[] = {0x00, 0x00, 0x01, 0xDF}; /* 0 -> 479 */ 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, 0x03, 0x1F}, /* 0 -> 799 */ #endif ...}; static LCD_LayerPropTypedef layer_prop[GUI_NUM_LAYERS]; volatile int32_t LCD_ActiveRegion = 1; volatile int32_t LCD_Refershing = 0; static const LCD_API_COLOR_CONV * apColorConvAPI[] = { COLOR_CONVERSION_0, #if GUI_NUM_LAYERS > 1 COLOR_CONVERSION_1, #endif ...}; #if GUI_NUM_LAYERS < 2 U32 LCD_Addr[GUI_NUM_LAYERS] = {LCD_LAYER0_FRAME_BUFFER}; #else U32 LCD_Addr[GUI_NUM_LAYERS] = {LCD_LAYER0_FRAME_BUFFER, LCD_LAYER1_FRAME_BUFFER}; #endif /** * @} *//* ... */ /** @defgroup LCD CONFIGURATION_Private_FunctionPrototypes * @{ *//* ... */ static U32 GetPixelformat(U32 LayerIndex); static U32 GetBufferSize(U32 LayerIndex); static void DMA2D_CopyBufferWithAlpha(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst); static void DMA2D_CopyBuffer (U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst); static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex); static void LCD_LL_Init(void); static void LCD_LL_Reset(void); static void LTDC_Init(void); void BSP_LCD_MspInit(void); static void LCD_LL_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst); static void LCD_LL_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize); static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex); static void LCD_LL_DrawBitmap8bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine); void LCD_LL_DrawBitmap16bpp(int LayerIndex, int x, int y, U16 const * p, int xSize, int ySize, int BytesPerLine); static void LCD_LL_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine); void LCD_SetUpdateRegion(int idx); void LCD_ReqTear(void); void DSI_IRQHandler(void); /** * @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 HAL status *//* ... */ void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams) { if(NbrParams <= 1) { HAL_DSI_ShortWrite(&hdsi_disco, 0, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); }if (NbrParams <= 1) { ... } else { HAL_DSI_LongWrite(&hdsi_disco, 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 disco Rev B and beyond. *//* ... */ static void LCD_LL_Reset(void) { #if !defined(USE_STM32469I_DISCO_REVA) GPIO_InitTypeDef gpio_init_structure; __HAL_RCC_GPIOH_CLK_ENABLE(); /* Configure the GPIO on PH7 */ gpio_init_structure.Pin = GPIO_PIN_7; gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; /* GPIO_NOPULL is needed for new TechShine LCD(NT35510) used in STM32F469I_DISCO_REVC */ #if defined(USE_STM32469I_DISCO_REVC) gpio_init_structure.Pull = GPIO_NOPULL; #else gpio_init_structure.Pull = GPIO_PULLUP; #endif /* USE_STM32469I_DISCO_REVC */ gpio_init_structure.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOH, &gpio_init_structure); /* Activate XRES active low */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); HAL_Delay(20); /* wait 20 ms */ /* Deactivate XRES */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET); HAL_Delay(10); /* wait 10 ms *//* ... */ #endif /* (USE_STM32469I_DISCO_REVA) */ }{ ... } /** * @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(DSI_IRQn, 0xF, 0); HAL_NVIC_EnableIRQ(DSI_IRQn); }{ ... } /** * @brief Initialize the LTDC * @param None * @retval None *//* ... */ static void LTDC_Init(void) { /* DeInit */ hltdc_disco.Instance = LTDC; HAL_LTDC_DeInit(&hltdc_disco); /* LTDC Config */ /* Timing and polarity */ hltdc_disco.Init.HorizontalSync = HSYNC; hltdc_disco.Init.VerticalSync = VSYNC; hltdc_disco.Init.AccumulatedHBP = HSYNC+HBP; hltdc_disco.Init.AccumulatedVBP = VSYNC+VBP; hltdc_disco.Init.AccumulatedActiveH = VSYNC+VBP+VACT; hltdc_disco.Init.AccumulatedActiveW = HSYNC+HBP+HACT; hltdc_disco.Init.TotalHeigh = VSYNC+VBP+VACT+VFP; hltdc_disco.Init.TotalWidth = HSYNC+HBP+HACT+HFP; /* background value */ hltdc_disco.Init.Backcolor.Blue = 0; hltdc_disco.Init.Backcolor.Green = 0; hltdc_disco.Init.Backcolor.Red = 0; /* Polarity */ hltdc_disco.Init.HSPolarity = LTDC_HSPOLARITY_AL; hltdc_disco.Init.VSPolarity = LTDC_VSPOLARITY_AL; hltdc_disco.Init.DEPolarity = LTDC_DEPOLARITY_AL; hltdc_disco.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc_disco.Instance = LTDC; HAL_LTDC_Init(&hltdc_disco); }{ ... } /** * @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 / 5 = 76.8 MHz */ /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 76.8 MHz / 2 = 38.4 MHz */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; PeriphClkInitStruct.PLLSAI.PLLSAIR = 5; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */ hdsi_disco.Instance = DSI; HAL_DSI_DeInit(&(hdsi_disco)); PLLInit.PLLNDIV = 125; PLLInit.PLLIDF = DSI_PLL_IN_DIV2; PLLInit.PLLODF = DSI_PLL_OUT_DIV1; hdsi_disco.Init.NumberOfLanes = DSI_TWO_DATA_LANES; hdsi_disco.Init.TXEscapeCkdiv = 0x4; HAL_DSI_Init(&(hdsi_disco), &(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_disco, &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_disco, &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_disco, &PhyTimings); /* Initialize LTDC */ LTDC_Init(); /* Start DSI */ HAL_DSI_Start(&(hdsi_disco)); #if defined(USE_STM32469I_DISCO_REVC) /* Initialize the NT35510 LCD Display IC Driver (TechShine LCD IC Driver) * depending on configuration set in 'hdsivideo_handle'. *//* ... */ /* Send Display off DCS Command to display */ HAL_DSI_ShortWrite(&(hdsi_disco), 0, DSI_DCS_SHORT_PKT_WRITE_P1, NT35510_CMD_DISPOFF, 0x00); NT35510_Init(NT35510_FORMAT_RBG565, NT35510_ORIENTATION_LANDSCAPE);/* ... */ #else /* 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_disco), 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPOFF, 0x00); OTM8009A_Init(OTM8009A_FORMAT_RBG565, LCD_ORIENTATION_LANDSCAPE);/* ... */ #endif 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_disco, &LPCmd); HAL_DSI_ConfigFlowControl(&hdsi_disco, 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); DMA2D_FillBuffer(0, (U32 *)LCD_LAYER0_FRAME_BUFFER, XSIZE_PHYS,YSIZE_PHYS, 0, 0x00); /* Refresh the display */ HAL_DSI_Refresh(&hdsi_disco); }{ ... } /** * @brief Initialize the LCD layers. * @param LayerIndex : layer Index. * @retval None *//* ... */ static void LCD_LL_LayerInit(U32 LayerIndex, U32 address) { 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_disco, &Layercfg, LayerIndex); }{ ... } /** * @brief Return Pixel format for a given layer * @param LayerIndex : Layer Index * @retval Status ( 0 : 0k , 1: error) *//* ... */ static U32 GetPixelformat(U32 LayerIndex) { if (LayerIndex == 0) { return LTDC_PIXEL_FORMAT_RGB565; }if (LayerIndex == 0) { ... } else { return LTDC_PIXEL_FORMAT_ARGB1555; }else { ... } }{ ... } /** * @brief Return Pixel format for a given layer * @param LayerIndex : Layer Index * @retval Status ( 0 : 0k , 1: error) *//* ... */ static void DMA2D_CopyBuffer(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst) { U32 PixelFormat; PixelFormat = GetPixelformat(LayerIndex); DMA2D->CR = 0x00000000UL | (1 << 9); /* Set up pointers */ DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->FGOR = OffLineSrc; DMA2D->OOR = OffLineDst; /* Set up pixel format */ DMA2D->FGPFCCR = PixelFormat; /* Set up size */ DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; DMA2D->CR |= DMA2D_CR_START; /* Wait until transfer is done */ while (DMA2D->CR & DMA2D_CR_START) { }while (DMA2D->CR & DMA2D_CR_START) { ... } }{ ... } /********************************************************************* * * CopyBuffer *//* ... */ static void DMA2D_CopyBufferWithAlpha(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst) { uint32_t PixelFormat; PixelFormat = GetPixelformat(LayerIndex); DMA2D->CR = 0x00000000UL | (1 << 9) | (0x2 << 16); /* Set up pointers */ DMA2D->FGMAR = (U32)pSrc; DMA2D->OMAR = (U32)pDst; DMA2D->BGMAR = (U32)pDst; DMA2D->FGOR = OffLineSrc; DMA2D->OOR = OffLineDst; DMA2D->BGOR = OffLineDst; /* Set up pixel format */ DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_ARGB8888; DMA2D->BGPFCCR = PixelFormat; DMA2D->OPFCCR = PixelFormat; /* Set up size */ DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; DMA2D->CR |= DMA2D_CR_START; /* Wait until transfer is done */ while (DMA2D->CR & DMA2D_CR_START) { }while (DMA2D->CR & DMA2D_CR_START) { ... } }{ ... } /** * @brief Fill Buffer * @param LayerIndex : Layer Index * @param pDst: pointer to destination * @param xSize: X size * @param ySize: Y size * @param OffLine: offset after each line * @param ColorIndex: color to be used. * @retval None. *//* ... */ static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex) { U32 PixelFormat; PixelFormat = GetPixelformat(LayerIndex); /* Set up mode */ DMA2D->CR = 0x00030000UL | (1 << 9); DMA2D->OCOLR = ColorIndex; /* Set up pointers */ DMA2D->OMAR = (U32)pDst; /* Set up offsets */ DMA2D->OOR = OffLine; /* Set up pixel format */ DMA2D->OPFCCR = PixelFormat; /* Set up size */ DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; DMA2D->CR |= DMA2D_CR_START; /* Wait until transfer is done */ while (DMA2D->CR & DMA2D_CR_START) { }while (DMA2D->CR & DMA2D_CR_START) { ... } }{ ... } /** * @brief Get buffer size * @param LayerIndex : Layer Index * @retval None. *//* ... */ static U32 GetBufferSize(U32 LayerIndex) { return (layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].ySize * layer_prop[LayerIndex].BytesPerPixel); }{ ... } /** * @brief Customized copy buffer * @param LayerIndex : Layer Index * @param IndexSrc: index source * @param IndexDst: index destination * @retval None. *//* ... */ static void LCD_LL_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst) { U32 BufferSize, AddrSrc, AddrDst; BufferSize = GetBufferSize(LayerIndex); AddrSrc = layer_prop[LayerIndex].address + BufferSize * IndexSrc; AddrDst = layer_prop[LayerIndex].address + BufferSize * IndexDst; DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, layer_prop[LayerIndex].xSize, layer_prop[LayerIndex].ySize, 0, 0); layer_prop[LayerIndex].buffer_index = IndexDst; }{ ... } /** * @brief Copy rectangle * @param LayerIndex : Layer Index * @param x0: X0 position * @param y0: Y0 position * @param x1: X1 position * @param y1: Y1 position * @param xSize: X size. * @param ySize: Y size. * @retval None. *//* ... */ static void LCD_LL_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize) { U32 BufferSize, AddrSrc, AddrDst; BufferSize = GetBufferSize(LayerIndex); AddrSrc = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].pending_buffer + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel; AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].pending_buffer + (y1 * layer_prop[LayerIndex].xSize + x1) * layer_prop[LayerIndex].BytesPerPixel; DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, 0); }{ ... } /** * @brief Fill rectangle * @param LayerIndex : Layer Index * @param x0: X0 position * @param y0: Y0 position * @param x1: X1 position * @param y1: Y1 position * @param PixelIndex: Pixel index. * @retval None. *//* ... */ static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex) { U32 BufferSize, AddrDst; int xSize, ySize; if (GUI_GetDrawMode() == GUI_DM_XOR) { LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, NULL); LCD_FillRect(x0, y0, x1, y1); LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, (void(*)(void))LCD_LL_FillRect); }if (GUI_GetDrawMode() == GUI_DM_XOR) { ... } else { xSize = x1 - x0 + 1; ySize = y1 - y0 + 1; BufferSize = GetBufferSize(LayerIndex); AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel; DMA2D_FillBuffer(LayerIndex, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, PixelIndex); }else { ... } }{ ... } /** * @brief Draw indirect color bitmap * @param pSrc: pointer to the source * @param pDst: pointer to the destination * @param OffSrc: offset source * @param OffDst: offset destination * @param PixelFormatDst: pixel format for destination * @param xSize: X size * @param ySize: Y size * @retval None *//* ... */ static void DMA2D_DrawBitmapL8(void * pSrc, void * pDst, U32 OffSrc, U32 OffDst, U32 PixelFormatDst, U32 xSize, U32 ySize) { /* Set up mode */ DMA2D->CR = 0x00010000UL | (1 << 9); /* Control Register (Memory to memory with pixel format conversion and TCIE) */ /* Set up pointers */ DMA2D->FGMAR = (U32)pSrc; /* Foreground Memory Address Register (Source address) */ DMA2D->OMAR = (U32)pDst; /* Output Memory Address Register (Destination address) */ /* Set up offsets */ DMA2D->FGOR = OffSrc; /* Foreground Offset Register (Source line offset) */ DMA2D->OOR = OffDst; /* Output Offset Register (Destination line offset) */ /* Set up pixel format */ DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_L8; /* Foreground PFC Control Register (Defines the input pixel format) */ DMA2D->OPFCCR = PixelFormatDst; /* Output PFC Control Register (Defines the output pixel format) */ /* Set up size */ DMA2D->NLR = (U32)(xSize << 16) | ySize; /* Number of Line Register (Size configuration of area to be transferred) */ /* Execute operation */ DMA2D->CR |= DMA2D_CR_START; /* Start operation */ /* Wait until transfer is done */ while (DMA2D->CR & DMA2D_CR_START) { }while (DMA2D->CR & DMA2D_CR_START) { ... } }{ ... } /** * @brief Draw 16bpp bitmap file * @param LayerIndex: Layer Index * @param x: X position * @param y: Y position * @param p: pointer to destination address * @param xSize: X size * @param ySize: Y size * @param BytesPerLine * @retval None *//* ... */ void LCD_LL_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 = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y * layer_prop[LayerIndex].xSize + x) * layer_prop[LayerIndex].BytesPerPixel; OffLineSrc = (BytesPerLine / 2) - xSize; OffLineDst = layer_prop[LayerIndex].xSize - xSize; DMA2D_CopyBuffer(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst); }{ ... } static void LCD_LL_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; BufferSize = GetBufferSize(LayerIndex); AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y * layer_prop[LayerIndex].xSize + x) * layer_prop[LayerIndex].BytesPerPixel; OffLineSrc = (BytesPerLine / 4) - xSize; OffLineDst = layer_prop[LayerIndex].xSize - xSize; DMA2D_CopyBufferWithAlpha(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst); }{ ... } /** * @brief Draw 8bpp bitmap file * @param LayerIndex: Layer Index * @param x: X position * @param y: Y position * @param p: pointer to destination address * @param xSize: X size * @param ySize: Y size * @param BytesPerLine * @retval None *//* ... */ static void LCD_LL_DrawBitmap8bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine) { U32 BufferSize, AddrDst; int OffLineSrc, OffLineDst; U32 PixelFormat; BufferSize = GetBufferSize(LayerIndex); AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y * layer_prop[LayerIndex].xSize + x) * layer_prop[LayerIndex].BytesPerPixel; OffLineSrc = BytesPerLine - xSize; OffLineDst = layer_prop[LayerIndex].xSize - xSize; PixelFormat = GetPixelformat(LayerIndex); DMA2D_DrawBitmapL8((void *)p, (void *)AddrDst, OffLineSrc, OffLineDst, PixelFormat, xSize, ySize); }{ ... } /** * @brief Set LCD updated region. * @param idx: active region index. * @retval None *//* ... */ void LCD_SetUpdateRegion(int idx) { HAL_DSI_LongWrite(&hdsi_disco, 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; if(!LCD_Refershing) { for(index = 0; index < GUI_NUM_LAYERS; index ++) { if(layer_prop[index].pending_buffer >= 0) { GUI_MULTIBUF_ConfirmEx(index, layer_prop[index].pending_buffer); layer_prop[index].pending_buffer = -1; }if (layer_prop[index].pending_buffer >= 0) { ... } }for (index = 0; index < GUI_NUM_LAYERS; index ++) { ... } LCD_Refershing = 1; LCD_ActiveRegion = 1; HAL_DSI_Refresh(hdsi); }if (!LCD_Refershing) { ... } }{ ... } /** * @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; if(LCD_ActiveRegion < ZONES ) { LCD_Refershing = 1; /* Disable DSI Wrapper */ __HAL_DSI_WRAPPER_DISABLE(hdsi); for(index = 0; index < GUI_NUM_LAYERS; index ++) { /* Update LTDC configuration */ LTDC_LAYER(&hltdc_disco, index)->CFBAR = LCD_Addr[index] + LCD_ActiveRegion * HACT * 2; }for (index = 0; index < GUI_NUM_LAYERS; index ++) { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc_disco); __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 { LCD_Refershing = 0; __HAL_DSI_WRAPPER_DISABLE(&hdsi_disco); for(index = 0; index < GUI_NUM_LAYERS; index ++) { LTDC_LAYER(&hltdc_disco, index)->CFBAR = LCD_Addr[index]; }for (index = 0; index < GUI_NUM_LAYERS; index ++) { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc_disco); __HAL_DSI_WRAPPER_ENABLE(&hdsi_disco); LCD_SetUpdateRegion(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 = 200; #endif ScanLineParams[0] = scanline >> 8; ScanLineParams[1] = scanline & 0x00FF; HAL_DSI_LongWrite(&hdsi_disco, 0, DSI_DCS_LONG_PKT_WRITE, 2, 0x44, ScanLineParams); /* set_tear_on */ HAL_DSI_ShortWrite(&hdsi_disco, 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_TEEON, 0x00); }{ ... } /** * @brief Called during the initialization process in order to set up the * display driver configuration * @param None * @retval None *//* ... */ void LCD_X_Config(void) { U32 i; /* 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_PHYS, XSIZE_PHYS); LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS); }if (LCD_GetSwapXYEx(0)) { ... } else { LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS); LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * 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_PHYS, XSIZE_PHYS); LCD_SetVSizeEx(1, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS); }if (LCD_GetSwapXYEx(1)) { ... } else { LCD_SetSizeEx (1, XSIZE_PHYS, YSIZE_PHYS); LCD_SetVSizeEx(1, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS); }else { ... } /* ... */#endif /*Initialize GUI Layer structure */ layer_prop[0].address = LCD_LAYER0_FRAME_BUFFER; #if (GUI_NUM_LAYERS > 1) layer_prop[1].address = LCD_LAYER1_FRAME_BUFFER; #endif /* Setting up VRam address and custom functions for CopyBuffer-, CopyRect- and FillRect operations */ for (i = 0; i < GUI_NUM_LAYERS; i++) { layer_prop[i].pColorConvAPI = (LCD_API_COLOR_CONV *)apColorConvAPI[i]; layer_prop[i].pending_buffer = -1; /* Remember color depth for further operations */ layer_prop[i].BytesPerPixel = LCD_GetBitsPerPixelEx(i) >> 3; /* Set custom functions for several operations */ LCD_SetDevFunc(i, LCD_DEVFUNC_COPYBUFFER, (void(*)(void))LCD_LL_CopyBuffer); LCD_SetDevFunc(i, LCD_DEVFUNC_COPYRECT, (void(*)(void))LCD_LL_CopyRect); /* Filling via DMA2D does only work with 16bpp or more */ LCD_SetDevFunc(i, LCD_DEVFUNC_FILLRECT, (void(*)(void))LCD_LL_FillRect); LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_8BPP, (void(*)(void))LCD_LL_DrawBitmap8bpp); LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_16BPP, (void(*)(void))LCD_LL_DrawBitmap16bpp); LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_32BPP, (void(*)(void))LCD_LL_DrawBitmap32bpp); /* Set VRAM address */ LCD_SetVRAMAddrEx(i, (void *)(layer_prop[i].address)); }for (i = 0; i < GUI_NUM_LAYERS; i++) { ... } LCD_LL_Init (); LCD_LL_LayerInit(0, LCD_LAYER0_FRAME_BUFFER); #if (GUI_NUM_LAYERS > 1) LCD_LL_LayerInit(1, LCD_LAYER1_FRAME_BUFFER); #endif HAL_DSI_LongWrite(&hdsi_disco, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_CASET, pCols[0]); HAL_DSI_LongWrite(&hdsi_disco, 0, DSI_DCS_LONG_PKT_WRITE, 4, OTM8009A_CMD_PASET, pPage); /* Update pitch : the draw is done on the whole physical X Size */ HAL_LTDC_SetPitch(&hltdc_disco, XSIZE_PHYS, 0); #if (GUI_NUM_LAYERS > 1) HAL_LTDC_SetPitch(&hltdc_disco, XSIZE_PHYS, 1); #endif HAL_Delay(20); LCD_ReqTear(); /* Send Display off DCS Command to display */ HAL_DSI_ShortWrite(&(hdsi_disco), 0, DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPON, 0x00); }{ ... } /** * @brief This function is called by the display driver for several purposes. * To support the according task the routine needs to be adapted to * the display controller. Please note that the commands marked with * 'optional' are not cogently required and should only be adapted if * the display controller supports these features * @param LayerIndex: Index of layer to be configured * @param Cmd :Please refer to the details in the switch statement below * @param pData :Pointer to a LCD_X_DATA structure * @retval Status (-1 : Error, 0 : Ok) *//* ... */ int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) { int r = 0; U32 addr; int xPos, yPos; U32 Color; LCD_X_SHOWBUFFER_INFO * p; switch (Cmd) { case LCD_X_SETORG: addr = layer_prop[LayerIndex].address + ((LCD_X_SETORG_INFO *)pData)->yPos * layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].BytesPerPixel; HAL_LTDC_SetAddress(&hltdc_disco, addr, LayerIndex); break; case LCD_X_SETORG: case LCD_X_SHOWBUFFER: p = (LCD_X_SHOWBUFFER_INFO *)pData; LCD_Addr[LayerIndex] = layer_prop[LayerIndex].address + \ layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].ySize * layer_prop[LayerIndex].BytesPerPixel * p->Index; layer_prop[LayerIndex].pending_buffer = p->Index; break; case LCD_X_SHOWBUFFER: case LCD_X_ON: __HAL_LTDC_ENABLE(&hltdc_disco); break; case LCD_X_ON: case LCD_X_OFF: __HAL_LTDC_DISABLE(&hltdc_disco); break; case LCD_X_OFF: case LCD_X_SETVIS: if(((LCD_X_SETVIS_INFO *)pData)->OnOff == ENABLE ) { __HAL_DSI_WRAPPER_DISABLE(&hdsi_disco); __HAL_LTDC_LAYER_ENABLE(&hltdc_disco, LayerIndex); __HAL_DSI_WRAPPER_ENABLE(&hdsi_disco); }if (((LCD_X_SETVIS_INFO *)pData)->OnOff == ENABLE) { ... } else { __HAL_DSI_WRAPPER_DISABLE(&hdsi_disco); __HAL_LTDC_LAYER_DISABLE(&hltdc_disco, LayerIndex); __HAL_DSI_WRAPPER_ENABLE(&hdsi_disco); }else { ... } __HAL_LTDC_RELOAD_CONFIG(&hltdc_disco); HAL_DSI_Refresh(&hdsi_disco); break; case LCD_X_SETVIS: case LCD_X_SETPOS: HAL_LTDC_SetWindowPosition(&hltdc_disco, ((LCD_X_SETPOS_INFO *)pData)->xPos, ((LCD_X_SETPOS_INFO *)pData)->yPos, LayerIndex); break; case LCD_X_SETPOS: case LCD_X_SETSIZE: GUI_GetLayerPosEx(LayerIndex, &xPos, &yPos); layer_prop[LayerIndex].xSize = ((LCD_X_SETSIZE_INFO *)pData)->xSize; layer_prop[LayerIndex].ySize = ((LCD_X_SETSIZE_INFO *)pData)->ySize; HAL_LTDC_SetWindowPosition(&hltdc_disco, xPos, yPos, LayerIndex); break; case LCD_X_SETSIZE: case LCD_X_SETALPHA: HAL_LTDC_SetAlpha(&hltdc_disco, ((LCD_X_SETALPHA_INFO *)pData)->Alpha, LayerIndex); break; case LCD_X_SETALPHA: case LCD_X_SETCHROMAMODE: if(((LCD_X_SETCHROMAMODE_INFO *)pData)->ChromaMode != 0) { HAL_LTDC_EnableColorKeying(&hltdc_disco, LayerIndex); }if (((LCD_X_SETCHROMAMODE_INFO *)pData)->ChromaMode != 0) { ... } else { HAL_LTDC_DisableColorKeying(&hltdc_disco, LayerIndex); }else { ... } break; case LCD_X_SETCHROMAMODE: case LCD_X_SETCHROMA: Color = ((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0xFF0000) >> 16) |\ (((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x00FF00) |\ ((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x0000FF) << 16); HAL_LTDC_ConfigColorKeying(&hltdc_disco, Color, LayerIndex); break; case LCD_X_SETCHROMA: default: r = -1;default }switch (Cmd) { ... } return r; }{ ... } /** * @brief This function handles DSI Handler. * @param None * @retval None *//* ... */ void DSI_IRQHandler(void) { HAL_DSI_IRQHandler(&hdsi_disco); }{ ... }