-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstm32h747i_discovery_lcd.c
2265 lines (2023 loc) · 65.3 KB
/
stm32h747i_discovery_lcd.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
/**
******************************************************************************
* @file stm32h747i_discovery_lcd.c
* @author MCD Application Team
* @brief This file includes the driver for Liquid Crystal Display (LCD) module
* mounted on STM32H747I_DISCO board.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* How To use this driver:
--------------------------
- This driver is used to drive directly a LCD TFT using the DSI interface.
The following IPs are implied : DSI Host IP block working in conjunction to the
LTDC controller.
- This driver is linked by construction to LCD KoD mounted on MB1166 daughter board.
- This driver is also used to drive monitors using HDMI interface.
Driver description:
---------------------
+ Initialization steps:
o Initialize the LCD in default mode using the BSP_LCD_Init() function with the
following settings:
- DSI is configured in video mode
- Pixelformat : LCD_PIXEL_FORMAT_RBG888
- Orientation : LCD_ORIENTATION_LANDSCAPE.
- Width : LCD_DEFAULT_WIDTH (800)
- Height : LCD_DEFAULT_HEIGHT(480)
The default LTDC layer configured is layer 0.
BSP_LCD_Init() includes DSI, LTDC, LTDC Layer and clock configurations by calling:
- MX_LTDC_ClockConfig()
- MX_LTDC_Init()
- MX_DSIHOST_DSI_Init()
- MX_LTDC_ConfigLayer()
o Initialize the LCD with required parameters using the BSP_LCD_InitEx() function.
To initialize DSI in command mode, user have to override MX_DSIHOST_DSI_Init(), weak function,
content at application level.
o Initialize the display with HDMI using BSP_LCD_InitHDMI(). Two display formats
are supported: HDMI_FORMAT_720_480 or HDMI_FORMAT_720_576
o Select the LCD layer to be activated using the BSP_LCD_SetActiveLayer() function.
o Enable the LCD display using the BSP_LCD_DisplayOn() function.
o Disable the LCD display using the BSP_LCD_DisplayOff() function.
o Set the display brightness using the BSP_LCD_SetBrightness() function.
o Get the display brightness using the BSP_LCD_GetBrightness() function.
o Write a pixel to the LCD memory using the BSP_LCD_WritePixel() function.
o Read a pixel from the LCD memory using the BSP_LCD_ReadPixel() function.
o Draw an horizontal line using the BSP_LCD_DrawHLine() function.
o Draw a vertical line using the BSP_LCD_DrawVLine() function.
o Draw a bitmap image using the BSP_LCD_DrawBitmap() function.
+ Options
o Configure the LTDC reload mode by calling BSP_LCD_Reload(). By default, the
reload mode is set to BSP_LCD_RELOAD_IMMEDIATE then LTDC is reloaded immediately.
To control the reload mode:
- Call BSP_LCD_Reload() with ReloadType parameter set to BSP_LCD_RELOAD_NONE
- Configure LTDC (color keying, transparency ..)
- Call BSP_LCD_Reload() with ReloadType parameter set to BSP_LCD_RELOAD_IMMEDIATE
for immediate reload or BSP_LCD_RELOAD_VERTICAL_BLANKING for LTDC reload
in the next vertical blanking
o Configure LTDC layers using BSP_LCD_ConfigLayer()
o Control layer visibility using BSP_LCD_SetLayerVisible()
o Configure and enable the color keying functionality using the
BSP_LCD_SetColorKeying() function.
o Disable the color keying functionality using the BSP_LCD_ResetColorKeying() function.
o Modify on the fly the transparency and/or the frame buffer address
using the following functions:
- BSP_LCD_SetTransparency()
- BSP_LCD_SetLayerAddress()
+ Display on LCD
o To draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
on LCD and display text, utility basic_gui.c/.h must be called. Once the LCD is initialized,
user should call GUI_SetFuncDriver() API to link board LCD drivers to BASIC GUI LCD drivers.
The basic gui services, defined in basic_gui utility, are ready for use.
Note:
--------
Regarding the "Instance" parameter, needed for all functions, it is used to select
an LCD instance. On the STM32H747I_DISCO board, there's one instance. Then, this
parameter should be 0.
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32h747i_discovery_lcd.h"
#include "stm32h747i_discovery_bus.h"
#include "stm32h747i_discovery_sdram.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H747I_DISCO
* @{
*/
/** @defgroup STM32H747I_DISCO_LCD LCD
* @{
*/
/** @defgroup STM32H747I_DISCO_LCD_Private_Variables Private Variables
* @{
*/
static LCD_Drv_t *Lcd_Drv = NULL;
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_LCD_Private_TypesDefinitions Private TypesDefinitions
* @{
*/
const LCD_UTILS_Drv_t LCD_Driver =
{
BSP_LCD_DrawBitmap,
BSP_LCD_FillRGBRect,
BSP_LCD_DrawHLine,
BSP_LCD_DrawVLine,
BSP_LCD_FillRect,
BSP_LCD_ReadPixel,
BSP_LCD_WritePixel,
BSP_LCD_GetXSize,
BSP_LCD_GetYSize,
BSP_LCD_SetActiveLayer,
BSP_LCD_GetPixelFormat
};
typedef struct
{
uint32_t HACT;
uint32_t VACT;
uint32_t HSYNC;
uint32_t HBP;
uint32_t HFP;
uint32_t VSYNC;
uint32_t VBP;
uint32_t VFP;
/* Configure the D-PHY Timings */
uint32_t ClockLaneHS2LPTime;
uint32_t ClockLaneLP2HSTime;
uint32_t DataLaneHS2LPTime;
uint32_t DataLaneLP2HSTime;
uint32_t DataLaneMaxReadTime;
uint32_t StopWaitTime;
} LCD_HDMI_Timing_t;
typedef enum
{
LCD_CTRL_NT35510,
LCD_CTRL_OTM8009A
} LCD_Driver_t;
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_LCD_Exported_Variables Exported Variables
* @{
*/
void *Lcd_CompObj = NULL;
DSI_HandleTypeDef hlcd_dsi;
DMA2D_HandleTypeDef hlcd_dma2d;
LTDC_HandleTypeDef hlcd_ltdc;
BSP_LCD_Ctx_t Lcd_Ctx[LCD_INSTANCES_NBR];
LCD_Driver_t Lcd_Driver_Type = LCD_CTRL_NT35510;
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_LCD_Private_FunctionPrototypes Private FunctionPrototypes
* @{
*/
static void DSI_MspInit(DSI_HandleTypeDef *hdsi);
static void DSI_MspDeInit(DSI_HandleTypeDef *hdsi);
static int32_t DSI_IO_Write(uint16_t ChannelNbr, uint16_t Reg, uint8_t *pData, uint16_t Size);
static int32_t DSI_IO_Read(uint16_t ChannelNbr, uint16_t Reg, uint8_t *pData, uint16_t Size);
static int32_t NT35510_Probe(uint32_t ColorCoding, uint32_t Orientation);
static int32_t OTM8009A_Probe(uint32_t ColorCoding, uint32_t Orientation);
#if (USE_LCD_CTRL_ADV7533 > 0)
static int32_t ADV7533_Probe(void);
static void LCD_Get_HDMI_VideoModeTiming(uint32_t Format, LCD_HDMI_Timing_t *Timing);
static void LTDC_HDMI_Init(LCD_HDMI_Timing_t *Timing);
#endif /* USE_LCD_CTRL_ADV7533 */
static void LTDC_MspInit(LTDC_HandleTypeDef *hltdc);
static void LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc);
static void DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d);
static void DMA2D_MspDeInit(DMA2D_HandleTypeDef *hdma2d);
static void LL_FillBuffer(uint32_t Instance, uint32_t *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t Color);
static void LL_ConvertLineToRGB(uint32_t Instance, uint32_t *pSrc, uint32_t *pDst, uint32_t xSize, uint32_t ColorMode);
static void LCD_InitSequence(void);
static void LCD_DeInitSequence(void);
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_LCD_Private_Macros Private Macros
* @{
*/
#define CONVERTRGB5652ARGB8888(Color)((((((((Color) >> (11U)) & 0x1FU) * 527U) + 23U) >> (6U)) << (16U)) |\
(((((((Color) >> (5U)) & 0x3FU) * 259U) + 33U) >> (6U)) << (8U)) |\
(((((Color) & 0x1FU) * 527U) + 23U) >> (6U)) | (0xFF000000U))
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_LCD_Exported_Functions LCD Exported Functions
* @{
*/
/**
* @brief Initializes the LCD in default mode.
* @param Instance LCD Instance
* @param Orientation LCD_ORIENTATION_LANDSCAPE
* @retval BSP status
*/
int32_t BSP_LCD_Init(uint32_t Instance, uint32_t Orientation)
{
return BSP_LCD_InitEx(Instance, Orientation, LCD_PIXEL_FORMAT_RGB888, LCD_DEFAULT_WIDTH, LCD_DEFAULT_HEIGHT);
}
/**
* @brief Initializes the LCD.
* @param Instance LCD Instance
* @param Orientation LCD_ORIENTATION_LANDSCAPE
* @param PixelFormat LCD_PIXEL_FORMAT_RBG565 or LCD_PIXEL_FORMAT_RBG888
* @param Width Display width
* @param Height Display height
* @retval BSP status
*/
int32_t BSP_LCD_InitEx(uint32_t Instance, uint32_t Orientation, uint32_t PixelFormat, uint32_t Width, uint32_t Height)
{
int32_t ret = BSP_ERROR_NONE;
uint32_t ctrl_pixel_format, ltdc_pixel_format, dsi_pixel_format;
MX_LTDC_LayerConfig_t config;
if((Orientation > LCD_ORIENTATION_LANDSCAPE) || (Instance >= LCD_INSTANCES_NBR) || \
((PixelFormat != LCD_PIXEL_FORMAT_RGB565) && (PixelFormat != LTDC_PIXEL_FORMAT_RGB888)))
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
if(PixelFormat == LCD_PIXEL_FORMAT_RGB565)
{
ltdc_pixel_format = LTDC_PIXEL_FORMAT_RGB565;
dsi_pixel_format = DSI_RGB565;
Lcd_Ctx[Instance].BppFactor = 2U;
}
else /* LCD_PIXEL_FORMAT_RGB888 */
{
ltdc_pixel_format = LTDC_PIXEL_FORMAT_ARGB8888;
dsi_pixel_format = DSI_RGB888;
Lcd_Ctx[Instance].BppFactor = 4U;
}
/* Store pixel format, xsize and ysize information */
Lcd_Ctx[Instance].PixelFormat = PixelFormat;
Lcd_Ctx[Instance].XSize = Width;
Lcd_Ctx[Instance].YSize = Height;
/* Toggle Hardware Reset of the LCD using its XRES signal (active low) */
BSP_LCD_Reset(Instance);
/* Initialize LCD special pins GPIOs */
LCD_InitSequence();
/* Initializes peripherals instance value */
hlcd_ltdc.Instance = LTDC;
hlcd_dma2d.Instance = DMA2D;
hlcd_dsi.Instance = DSI;
/* MSP initialization */
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
/* Register the LTDC MSP Callbacks */
if(Lcd_Ctx[Instance].IsMspCallbacksValid == 0U)
{
if(BSP_LCD_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#else
LTDC_MspInit(&hlcd_ltdc);
#endif
DMA2D_MspInit(&hlcd_dma2d);
#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
/* Register the DSI MSP Callbacks */
if(Lcd_Ctx[Instance].IsMspCallbacksValid == 0U)
{
if(BSP_LCD_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#else
DSI_MspInit(&hlcd_dsi);
#endif
if(MX_DSIHOST_DSI_Init(&hlcd_dsi, Width, Height, dsi_pixel_format) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(MX_LTDC_ClockConfig(&hlcd_ltdc) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
if(MX_LTDC_Init(&hlcd_ltdc, Width, Height) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
if(ret == BSP_ERROR_NONE)
{
/* Before configuring LTDC layer, ensure SDRAM is initialized */
#if !defined(DATA_IN_ExtSDRAM)
/* Initialize the SDRAM */
if(BSP_SDRAM_Init(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
#endif /* DATA_IN_ExtSDRAM */
/* Configure default LTDC Layer 0. This configuration can be override by calling
BSP_LCD_ConfigLayer() at application level */
config.X0 = 0;
config.X1 = Width;
config.Y0 = 0;
config.Y1 = Height;
config.PixelFormat = ltdc_pixel_format;
config.Address = LCD_LAYER_0_ADDRESS;
if(MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, &config) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
/* Enable the DSI host and wrapper after the LTDC initialization
To avoid any synchronization issue, the DSI shall be started after enabling the LTDC */
(void)HAL_DSI_Start(&hlcd_dsi);
/* Enable the DSI BTW for read operations */
(void)HAL_DSI_ConfigFlowControl(&hlcd_dsi, DSI_FLOW_CONTROL_BTA);
/* Initialize the NT35510 LCD Display IC Driver (KoD LCD IC Driver)
depending on configuration of DSI */
if(PixelFormat == LCD_PIXEL_FORMAT_RGB565)
{
ctrl_pixel_format = NT35510_FORMAT_RBG565;
}
else /* LCD_PIXEL_FORMAT_RGB888 */
{
ctrl_pixel_format = NT35510_FORMAT_RGB888;
}
if(NT35510_Probe(ctrl_pixel_format, Orientation) != BSP_ERROR_NONE)
{
Lcd_Driver_Type = LCD_CTRL_OTM8009A;
if(ret == BSP_ERROR_NONE)
{
/* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver)
depending on configuration of DSI */
if(PixelFormat == LCD_PIXEL_FORMAT_RGB565)
{
ctrl_pixel_format = OTM8009A_FORMAT_RBG565;
}
else /* LCD_PIXEL_FORMAT_RGB888 */
{
ctrl_pixel_format = OTM8009A_FORMAT_RGB888;
}
if(OTM8009A_Probe(ctrl_pixel_format, Orientation) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_UNKNOWN_COMPONENT;
}
else
{
ret = BSP_ERROR_NONE;
}
}
}
else
{
ret = BSP_ERROR_NONE;
}
}
/* By default the reload is activated and executed immediately */
Lcd_Ctx[Instance].ReloadEnable = 1U;
}
}
return ret;
}
/**
* @brief De-Initializes the LCD resources.
* @param Instance LCD Instance
* @retval BSP status
*/
int32_t BSP_LCD_DeInit(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= LCD_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
LCD_DeInitSequence();
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 0)
LTDC_MspDeInit(&hlcd_ltdc);
#endif /* (USE_HAL_LTDC_REGISTER_CALLBACKS == 0) */
DMA2D_MspDeInit(&hlcd_dma2d);
#if (USE_HAL_DSI_REGISTER_CALLBACKS == 0)
DSI_MspDeInit(&hlcd_dsi);
#endif /* (USE_HAL_DSI_REGISTER_CALLBACKS == 0) */
if(HAL_DSI_DeInit(&hlcd_dsi) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
(void)HAL_LTDC_DeInit(&hlcd_ltdc);
if(HAL_DMA2D_DeInit(&hlcd_dma2d) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
Lcd_Ctx[Instance].IsMspCallbacksValid = 0;
}
}
}
return ret;
}
#if (USE_LCD_CTRL_ADV7533 > 0)
/**
* @brief Initializes the LCD HDMI Mode.
* @param Instance LCD Instance
* @param Format HDMI format could be HDMI_FORMAT_720_480 or HDMI_FORMAT_720_576
* @retval BSP status
*/
int32_t BSP_LCD_InitHDMI(uint32_t Instance, uint32_t Format)
{
int32_t ret;
DSI_PLLInitTypeDef dsiPllInit;
DSI_PHY_TimerTypeDef dsiPhyInit;
MX_LTDC_LayerConfig_t hdmi_config;
LCD_HDMI_Timing_t hdmi_timing;
DSI_VidCfgTypeDef hDsiVideoMode;
if(Instance >= LCD_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
LCD_Get_HDMI_VideoModeTiming(Format, &hdmi_timing);
Lcd_Ctx[Instance].XSize = hdmi_timing.HACT;
Lcd_Ctx[Instance].YSize = hdmi_timing.VACT;
Lcd_Ctx[Instance].PixelFormat = LCD_PIXEL_FORMAT_RGB888;
Lcd_Ctx[Instance].BppFactor = 4U;
/* Toggle Hardware Reset of the DSI LCD using
* its XRES signal (active low) */
BSP_LCD_Reset(Instance);
/* Initializes peripherals instance value */
hlcd_ltdc.Instance = LTDC;
hlcd_dma2d.Instance = DMA2D;
hlcd_dsi.Instance = DSI;
if(ADV7533_Probe() != BSP_ERROR_NONE)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
else if(Lcd_Drv->DisplayOn(Lcd_CompObj)!= BSP_ERROR_NONE)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
else
{
/* 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
*/
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
/* Register the LTDC MSP Callbacks */
if(Lcd_Ctx[Instance].IsMspCallbacksValid == 0U)
{
if(BSP_LCD_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#else
LTDC_MspInit(&hlcd_ltdc);
#endif
DMA2D_MspInit(&hlcd_dma2d);
#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
/* Register the DSI MSP Callbacks */
if(Lcd_Ctx[Instance].IsMspCallbacksValid == 0U)
{
if(BSP_LCD_RegisterDefaultMspCallbacks(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#else
DSI_MspInit(&hlcd_dsi);
#endif
/*************************DSI Initialization***********************************/
/* Base address of DSI Host/Wrapper registers to be set before calling De-Init */
hlcd_dsi.Instance = DSI;
/* Set number of Lanes */
hlcd_dsi.Init.NumberOfLanes = DSI_TWO_DATA_LANES;
/* Set the TX escape clock division ratio */
hlcd_dsi.Init.TXEscapeCkdiv = 3U;
hlcd_dsi.Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE;
/* Configure the DSI PLL */
dsiPllInit.PLLNDIV = 65U;
dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5;
dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
if(HAL_DSI_Init(&hlcd_dsi, &dsiPllInit) != HAL_OK)
{
return BSP_ERROR_PERIPH_FAILURE;
}
/* Configure the D-PHY Timings */
dsiPhyInit.ClockLaneHS2LPTime = hdmi_timing.ClockLaneHS2LPTime;
dsiPhyInit.ClockLaneLP2HSTime = hdmi_timing.ClockLaneLP2HSTime;
dsiPhyInit.DataLaneHS2LPTime = hdmi_timing.DataLaneHS2LPTime;
dsiPhyInit.DataLaneLP2HSTime = hdmi_timing.DataLaneLP2HSTime;
dsiPhyInit.DataLaneMaxReadTime = hdmi_timing.DataLaneMaxReadTime;
dsiPhyInit.StopWaitTime = hdmi_timing.StopWaitTime;
if(HAL_DSI_ConfigPhyTimer(&hlcd_dsi, &dsiPhyInit) != HAL_OK)
{
return BSP_ERROR_PERIPH_FAILURE;
}
/* Timing parameters for all Video modes */
/*
The lane byte clock is set 40625 Khz
The pixel clock is set to 27083 Khz
*/
hDsiVideoMode.VirtualChannelID = 0;
hDsiVideoMode.ColorCoding = DSI_RGB888;
hDsiVideoMode.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE;
hDsiVideoMode.VSPolarity = DSI_VSYNC_ACTIVE_LOW;
hDsiVideoMode.HSPolarity = DSI_HSYNC_ACTIVE_LOW;
hDsiVideoMode.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH;
hDsiVideoMode.Mode = DSI_VID_MODE_NB_PULSES;
hDsiVideoMode.NullPacketSize = 0U;
hDsiVideoMode.NumberOfChunks = 1U;
hDsiVideoMode.PacketSize = hdmi_timing.HACT; /* Value depending on display format */
hDsiVideoMode.HorizontalSyncActive = (hdmi_timing.HSYNC * 40625U)/27083U;
hDsiVideoMode.HorizontalBackPorch = (hdmi_timing.HBP * 40625U)/27083U;
hDsiVideoMode.HorizontalLine = ((hdmi_timing.HACT + hdmi_timing.HSYNC + hdmi_timing.HBP + hdmi_timing.HFP) * 40625U)/27083U; /* Value depending on display format */
hDsiVideoMode.VerticalSyncActive = hdmi_timing.VSYNC;
hDsiVideoMode.VerticalBackPorch = hdmi_timing.VBP;
hDsiVideoMode.VerticalFrontPorch = hdmi_timing.VFP;
hDsiVideoMode.VerticalActive = hdmi_timing.VACT; /* Value depending on display format */
/* Disable or disable sending LP command while streaming is active in video mode */
hDsiVideoMode.LPCommandEnable = DSI_LP_COMMAND_DISABLE; /* Disable sending commands in mode LP (Low Power) */
/* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */
/* Only useful when sending LP packets is allowed while streaming is active in video mode */
hDsiVideoMode.LPLargestPacketSize = 4;
/* Largest packet size possible to transmit in LP mode in HFP region during VACT period */
/* Only useful when sending LP packets is allowed while streaming is active in video mode */
hDsiVideoMode.LPVACTLargestPacketSize = 4;
/* Specify for each region, if the going in LP mode is allowed */
/* while streaming is active in video mode */
hDsiVideoMode.LPHorizontalFrontPorchEnable = DSI_LP_HFP_DISABLE;
hDsiVideoMode.LPHorizontalBackPorchEnable = DSI_LP_HBP_DISABLE;
hDsiVideoMode.LPVerticalActiveEnable = DSI_LP_VACT_DISABLE;
hDsiVideoMode.LPVerticalFrontPorchEnable = DSI_LP_VFP_DISABLE;
hDsiVideoMode.LPVerticalBackPorchEnable = DSI_LP_VBP_DISABLE;
hDsiVideoMode.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_DISABLE;
/* No acknowledge at the end of a frame */
hDsiVideoMode.FrameBTAAcknowledgeEnable = DSI_FBTAA_DISABLE;
/* Configure DSI Video mode timings with settings set above */
(void)HAL_DSI_ConfigVideoMode(&(hlcd_dsi), &(hDsiVideoMode));
if(MX_LTDC_ClockConfig2(&hlcd_ltdc) != HAL_OK)
{
return BSP_ERROR_CLOCK_FAILURE;
}
/* Initialize LTDC */
LTDC_HDMI_Init(&hdmi_timing);
hdmi_config.X0 = 0;
hdmi_config.X1 = Lcd_Ctx[Instance].XSize;
hdmi_config.Y0 = 0;
hdmi_config.Y1 = Lcd_Ctx[Instance].YSize;
hdmi_config.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
hdmi_config.Address = LCD_LAYER_0_ADDRESS;
if(MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, &hdmi_config) != HAL_OK)
{
return BSP_ERROR_PERIPH_FAILURE;
}
/* Enable the DSI host and wrapper after the LTDC initialization
To avoid any synchronization issue, the DSI shall be started after enabling the LTDC */
(void)HAL_DSI_Start(&(hlcd_dsi));
#if !defined(DATA_IN_ExtSDRAM)
/* Initialize the SDRAM */
if(BSP_SDRAM_Init(0) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
#endif /* DATA_IN_ExtSDRAM */
/** @brief NVIC configuration for LTDC interrupt that is now enabled */
HAL_NVIC_SetPriority(LTDC_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(LTDC_IRQn);
/** @brief NVIC configuration for DMA2D interrupt that is now enabled */
HAL_NVIC_SetPriority(DMA2D_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DMA2D_IRQn);
/** @brief NVIC configuration for DSI interrupt that is now enabled */
HAL_NVIC_SetPriority(DSI_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DSI_IRQn);
ret = BSP_ERROR_NONE;
}
}
return ret;
}
#endif /* USE_LCD_CTRL_ADV7533 */
/**
* @brief BSP LCD Reset
* Hw reset the LCD DSI activating its XRES signal (active low for some time)
* and deactivating it later.
* @param Instance LCD Instance
*/
void BSP_LCD_Reset(uint32_t Instance)
{
GPIO_InitTypeDef gpio_init_structure;
LCD_RESET_GPIO_CLK_ENABLE();
/* Configure the GPIO Reset pin */
gpio_init_structure.Pin = LCD_RESET_PIN;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(LCD_RESET_GPIO_PORT , &gpio_init_structure);
/* Activate XRES active low */
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT , LCD_RESET_PIN, GPIO_PIN_RESET);
HAL_Delay(20);/* wait 20 ms */
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT , LCD_RESET_PIN, GPIO_PIN_SET);/* Deactivate XRES */
HAL_Delay(10);/* Wait for 10ms after releasing XRES before sending commands */
}
/**
* @brief Configure LCD control pins (Back-light, Display Enable and TE)
* @retval None
*/
static void LCD_InitSequence(void)
{
GPIO_InitTypeDef gpio_init_structure;
/* LCD_BL_CTRL GPIO configuration */
LCD_BL_CTRL_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = LCD_BL_CTRL_PIN;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
gpio_init_structure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure);
/* Assert back-light LCD_BL_CTRL pin */
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET);
/* LCD_TE_CTRL GPIO configuration */
LCD_TE_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = LCD_TE_PIN;
gpio_init_structure.Mode = GPIO_MODE_INPUT;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LCD_TE_GPIO_PORT, &gpio_init_structure);
/* Assert back-light LCD_BL_CTRL pin */
HAL_GPIO_WritePin(LCD_TE_GPIO_PORT, LCD_TE_PIN, GPIO_PIN_SET);
/** @brief NVIC configuration for LTDC interrupt that is now enabled */
HAL_NVIC_SetPriority(LTDC_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(LTDC_IRQn);
/** @brief NVIC configuration for DMA2D interrupt that is now enabled */
HAL_NVIC_SetPriority(DMA2D_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DMA2D_IRQn);
/** @brief NVIC configuration for DSI interrupt that is now enabled */
HAL_NVIC_SetPriority(DSI_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(DSI_IRQn);
}
/**
* @brief DeInitializes LCD GPIO special pins MSP.
* @retval None
*/
static void LCD_DeInitSequence(void)
{
GPIO_InitTypeDef gpio_init_structure;
/* LCD_BL_CTRL GPIO configuration */
/* LCD_BL_CTRL GPIO deactivation */
gpio_init_structure.Pin = LCD_BL_CTRL_PIN;
HAL_GPIO_DeInit(LCD_BL_CTRL_GPIO_PORT, gpio_init_structure.Pin);
/* LCD_TE_CTRL GPIO configuration */
}
/**
* @brief Initializes the DSIHOST.
* @param hdsi DSI handle
* @param Width Horizontal active width
* @param Height Vertical active height
* @param PixelFormat DSI color coding RGB888 or RGB565
* @retval HAL status
*/
__weak HAL_StatusTypeDef MX_DSIHOST_DSI_Init(DSI_HandleTypeDef *hdsi, uint32_t Width, uint32_t Height, uint32_t PixelFormat)
{
DSI_PLLInitTypeDef PLLInit;
DSI_VidCfgTypeDef VidCfg;
hdsi->Instance = DSI;
hdsi->Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE;
hdsi->Init.TXEscapeCkdiv = 4;
hdsi->Init.NumberOfLanes = DSI_TWO_DATA_LANES;
PLLInit.PLLNDIV = 100;
PLLInit.PLLIDF = DSI_PLL_IN_DIV5;
PLLInit.PLLODF = DSI_PLL_OUT_DIV1;
if (HAL_DSI_Init(hdsi, &PLLInit) != HAL_OK)
{
return HAL_ERROR;
}
/* Timing parameters for all Video modes */
/*
The lane byte clock is set 62500 Khz
The pixel clock is set to 27429 Khz
*/
VidCfg.VirtualChannelID = 0;
VidCfg.ColorCoding = PixelFormat;
if(Lcd_Driver_Type == LCD_CTRL_NT35510)
{
VidCfg.LooselyPacked = DSI_LOOSELY_PACKED_ENABLE;
}
else
{
VidCfg.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE;
}
VidCfg.Mode = DSI_VID_MODE_BURST;
VidCfg.PacketSize = Width;
VidCfg.NumberOfChunks = 0;
VidCfg.NullPacketSize = 0xFFFU;
VidCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH;
VidCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH;
VidCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH;
if(Lcd_Driver_Type == LCD_CTRL_NT35510)
{
VidCfg.HorizontalSyncActive = (NT35510_480X800_HSYNC * 62500U)/27429U;
VidCfg.HorizontalBackPorch = (NT35510_480X800_HBP * 62500U)/27429U;
VidCfg.HorizontalLine = ((Width + NT35510_480X800_HSYNC + NT35510_480X800_HBP + NT35510_480X800_HFP) * 62500U)/27429U;
VidCfg.VerticalSyncActive = NT35510_480X800_VSYNC;
VidCfg.VerticalBackPorch = NT35510_480X800_VBP;
VidCfg.VerticalFrontPorch = NT35510_480X800_VFP;
}
else
{
VidCfg.HorizontalSyncActive = (OTM8009A_480X800_HSYNC * 62500U)/27429U;
VidCfg.HorizontalBackPorch = (OTM8009A_480X800_HBP * 62500U)/27429U;
VidCfg.HorizontalLine = ((Width + OTM8009A_480X800_HSYNC + OTM8009A_480X800_HBP + OTM8009A_480X800_HFP) * 62500U)/27429U;
VidCfg.VerticalSyncActive = OTM8009A_480X800_VSYNC;
VidCfg.VerticalBackPorch = OTM8009A_480X800_VBP;
VidCfg.VerticalFrontPorch = OTM8009A_480X800_VFP;
}
VidCfg.VerticalActive = Height;
VidCfg.LPCommandEnable = DSI_LP_COMMAND_ENABLE;
if(Lcd_Driver_Type == LCD_CTRL_NT35510)
{
VidCfg.LPLargestPacketSize = 64;
VidCfg.LPVACTLargestPacketSize = 64;
}
else
{
VidCfg.LPLargestPacketSize = 4;
VidCfg.LPVACTLargestPacketSize = 4;
}
VidCfg.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE;
VidCfg.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE;
VidCfg.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE;
VidCfg.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE;
VidCfg.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE;
VidCfg.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE;
VidCfg.FrameBTAAcknowledgeEnable = DSI_FBTAA_DISABLE;
if (HAL_DSI_ConfigVideoMode(hdsi, &VidCfg) != HAL_OK)
{
return HAL_ERROR;
}
return HAL_OK;
}
/**
* @brief Initializes the LTDC.
* @param hltdc LTDC handle
* @param Width LTDC width
* @param Height LTDC height
* @retval HAL status
*/
__weak HAL_StatusTypeDef MX_LTDC_Init(LTDC_HandleTypeDef *hltdc, uint32_t Width, uint32_t Height)
{
hltdc->Instance = LTDC;
hltdc->Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc->Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc->Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc->Init.PCPolarity = LTDC_PCPOLARITY_IPC;
if(Lcd_Driver_Type == LCD_CTRL_NT35510)
{
hltdc->Init.HorizontalSync = NT35510_480X800_HSYNC - 1;
hltdc->Init.AccumulatedHBP = NT35510_480X800_HSYNC + NT35510_480X800_HBP - 1;
hltdc->Init.AccumulatedActiveW = NT35510_480X800_HSYNC + Width + NT35510_480X800_HBP - 1;
hltdc->Init.TotalWidth = NT35510_480X800_HSYNC + Width + NT35510_480X800_HBP + NT35510_480X800_HFP - 1;
hltdc->Init.VerticalSync = NT35510_480X800_VSYNC - 1;
hltdc->Init.AccumulatedVBP = NT35510_480X800_VSYNC + NT35510_480X800_VBP - 1;
hltdc->Init.AccumulatedActiveH = NT35510_480X800_VSYNC + Height + NT35510_480X800_VBP - 1;
hltdc->Init.TotalHeigh = NT35510_480X800_VSYNC + Height + NT35510_480X800_VBP + NT35510_480X800_VFP - 1;
}
else
{
hltdc->Init.HorizontalSync = OTM8009A_480X800_HSYNC - 1;
hltdc->Init.AccumulatedHBP = OTM8009A_480X800_HSYNC + OTM8009A_480X800_HBP - 1;
hltdc->Init.AccumulatedActiveW = OTM8009A_480X800_HSYNC + Width + OTM8009A_480X800_HBP - 1;
hltdc->Init.TotalWidth = OTM8009A_480X800_HSYNC + Width + OTM8009A_480X800_HBP + OTM8009A_480X800_HFP - 1;
hltdc->Init.VerticalSync = OTM8009A_480X800_VSYNC - 1;
hltdc->Init.AccumulatedVBP = OTM8009A_480X800_VSYNC + OTM8009A_480X800_VBP - 1;
hltdc->Init.AccumulatedActiveH = OTM8009A_480X800_VSYNC + Height + OTM8009A_480X800_VBP - 1;
hltdc->Init.TotalHeigh = OTM8009A_480X800_VSYNC + Height + OTM8009A_480X800_VBP + OTM8009A_480X800_VFP - 1;
}
hltdc->Init.Backcolor.Blue = 0x00;
hltdc->Init.Backcolor.Green = 0x00;
hltdc->Init.Backcolor.Red = 0x00;
return HAL_LTDC_Init(hltdc);
}
/**
* @brief MX LTDC layer configuration.
* @param hltdc LTDC handle
* @param LayerIndex Layer 0 or 1
* @param Config Layer configuration
* @retval HAL status
*/
__weak HAL_StatusTypeDef MX_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, uint32_t LayerIndex, MX_LTDC_LayerConfig_t *Config)
{
LTDC_LayerCfgTypeDef pLayerCfg;
pLayerCfg.WindowX0 = Config->X0;
pLayerCfg.WindowX1 = Config->X1;
pLayerCfg.WindowY0 = Config->Y0;
pLayerCfg.WindowY1 = Config->Y1;
pLayerCfg.PixelFormat = Config->PixelFormat;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
pLayerCfg.FBStartAdress = Config->Address;
pLayerCfg.ImageWidth = (Config->X1 - Config->X0);
pLayerCfg.ImageHeight = (Config->Y1 - Config->Y0);
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
return HAL_LTDC_ConfigLayer(hltdc, &pLayerCfg, LayerIndex);
}
/**
* @brief LTDC Clock Config for LCD DSI display.
* @param hltdc LTDC Handle
* Being __weak it can be overwritten by the application
* @retval HAL_status
*/
__weak HAL_StatusTypeDef MX_LTDC_ClockConfig(LTDC_HandleTypeDef *hltdc)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
PeriphClkInitStruct.PLL3.PLL3M = 5U;
PeriphClkInitStruct.PLL3.PLL3N = 132U;
PeriphClkInitStruct.PLL3.PLL3P = 2U;
PeriphClkInitStruct.PLL3.PLL3Q = 2U;
PeriphClkInitStruct.PLL3.PLL3R = 24U;
PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLLCFGR_PLL3RGE_2;
PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE;
PeriphClkInitStruct.PLL3.PLL3FRACN = 0U;
return HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
}
/**
* @brief LTDC Clock Config for LCD 2 DPI display.
* @param hltdc LTDC Handle
* Being __weak it can be overwritten by the application
* @retval HAL_status
*/
__weak HAL_StatusTypeDef MX_LTDC_ClockConfig2(LTDC_HandleTypeDef *hltdc)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
PeriphClkInitStruct.PLL3.PLL3M = 1U;
PeriphClkInitStruct.PLL3.PLL3N = 13U;
PeriphClkInitStruct.PLL3.PLL3P = 2U;
PeriphClkInitStruct.PLL3.PLL3Q = 2U;
PeriphClkInitStruct.PLL3.PLL3R = 12U;
PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLLCFGR_PLL3RGE_2;
PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE;
PeriphClkInitStruct.PLL3.PLL3FRACN = 0U;
return HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
}
#if ((USE_HAL_LTDC_REGISTER_CALLBACKS == 1) || (USE_HAL_DSI_REGISTER_CALLBACKS == 1))
/**
* @brief Default BSP LCD Msp Callbacks
* @param Instance BSP LCD Instance
* @retval BSP status
*/
int32_t BSP_LCD_RegisterDefaultMspCallbacks (uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= LCD_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
if(HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPINIT_CB_ID, LTDC_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
if(HAL_LTDC_RegisterCallback(&hlcd_ltdc, HAL_LTDC_MSPDEINIT_CB_ID, LTDC_MspDeInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
#endif /* (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) */
#if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
if(ret == BSP_ERROR_NONE)
{
if(HAL_DSI_RegisterCallback(&hlcd_dsi, HAL_DSI_MSPINIT_CB_ID, DSI_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}