1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_ltdc.c
4 * @author MCD Application Team
5 * @brief LTDC HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the LTDC peripheral:
8 * + Initialization and de-initialization functions
9 * + IO operation functions
10 * + Peripheral Control functions
11 * + Peripheral State and Errors functions
12 *
13 ******************************************************************************
14 * @attention
15 *
16 * Copyright (c) 2017 STMicroelectronics.
17 * All rights reserved.
18 *
19 * This software is licensed under terms that can be found in the LICENSE file
20 * in the root directory of this software component.
21 * If no LICENSE file comes with this software, it is provided AS-IS.
22 *
23 ******************************************************************************
24 @verbatim
25 ==============================================================================
26 ##### How to use this driver #####
27 ==============================================================================
28 [..]
29 The LTDC HAL driver can be used as follows:
30
31 (#) Declare a LTDC_HandleTypeDef handle structure, for example: LTDC_HandleTypeDef hltdc;
32
33 (#) Initialize the LTDC low level resources by implementing the HAL_LTDC_MspInit() API:
34 (##) Enable the LTDC interface clock
35 (##) NVIC configuration if you need to use interrupt process
36 (+++) Configure the LTDC interrupt priority
37 (+++) Enable the NVIC LTDC IRQ Channel
38
39 (#) Initialize the required configuration through the following parameters:
40 the LTDC timing, the horizontal and vertical polarity, the pixel clock polarity,
41 Data Enable polarity and the LTDC background color value using HAL_LTDC_Init() function
42
43 *** Configuration ***
44 =========================
45 [..]
46 (#) Program the required configuration through the following parameters:
47 the pixel format, the blending factors, input alpha value, the window size
48 and the image size using HAL_LTDC_ConfigLayer() function for foreground
49 or/and background layer.
50
51 (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
52 HAL_LTDC_EnableCLUT functions.
53
54 (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
55
56 (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
57 and HAL_LTDC_EnableColorKeying functions.
58
59 (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineEvent()
60 function
61
62 (#) If needed, reconfigure and change the pixel format value, the alpha value
63 value, the window size, the window position and the layer start address
64 for foreground or/and background layer using respectively the following
65 functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
66 HAL_LTDC_SetWindowPosition() and HAL_LTDC_SetAddress().
67
68 (#) Variant functions with _NoReload suffix allows to set the LTDC configuration/settings without immediate reload.
69 This is useful in case when the program requires to modify serval LTDC settings (on one or both layers)
70 then applying(reload) these settings in one shot by calling the function HAL_LTDC_Reload().
71
72 After calling the _NoReload functions to set different color/format/layer settings,
73 the program shall call the function HAL_LTDC_Reload() to apply(reload) these settings.
74 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_IMMEDIATE if
75 an immediate reload is required.
76 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_VERTICAL_BLANKING if
77 the reload should be done in the next vertical blanking period,
78 this option allows to avoid display flicker by applying the new settings during the vertical blanking period.
79
80
81 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
82
83 *** LTDC HAL driver macros list ***
84 =============================================
85 [..]
86 Below the list of most used macros in LTDC HAL driver.
87
88 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
89 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
90 (+) __HAL_LTDC_LAYER_ENABLE: Enable an LTDC Layer.
91 (+) __HAL_LTDC_LAYER_DISABLE: Disable an LTDC Layer.
92 (+) __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG: Reload Layer Configuration.
93 (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
94 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
95 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
96 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
97 (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
98
99 [..]
100 (@) You can refer to the LTDC HAL driver header file for more useful macros
101
102
103 *** Callback registration ***
104 =============================================
105 [..]
106 The compilation define USE_HAL_LTDC_REGISTER_CALLBACKS when set to 1
107 allows the user to configure dynamically the driver callbacks.
108 Use function HAL_LTDC_RegisterCallback() to register a callback.
109
110 [..]
111 Function HAL_LTDC_RegisterCallback() allows to register following callbacks:
112 (+) LineEventCallback : LTDC Line Event Callback.
113 (+) ReloadEventCallback : LTDC Reload Event Callback.
114 (+) ErrorCallback : LTDC Error Callback
115 (+) MspInitCallback : LTDC MspInit.
116 (+) MspDeInitCallback : LTDC MspDeInit.
117 [..]
118 This function takes as parameters the HAL peripheral handle, the callback ID
119 and a pointer to the user callback function.
120
121 [..]
122 Use function HAL_LTDC_UnRegisterCallback() to reset a callback to the default
123 weak function.
124 HAL_LTDC_UnRegisterCallback() takes as parameters the HAL peripheral handle
125 and the callback ID.
126 [..]
127 This function allows to reset following callbacks:
128 (+) LineEventCallback : LTDC Line Event Callback
129 (+) ReloadEventCallback : LTDC Reload Event Callback
130 (+) ErrorCallback : LTDC Error Callback
131 (+) MspInitCallback : LTDC MspInit
132 (+) MspDeInitCallback : LTDC MspDeInit.
133
134 [..]
135 By default, after the HAL_LTDC_Init and when the state is HAL_LTDC_STATE_RESET
136 all callbacks are set to the corresponding weak functions:
137 examples HAL_LTDC_LineEventCallback(), HAL_LTDC_ErrorCallback().
138 Exception done for MspInit and MspDeInit functions that are
139 reset to the legacy weak (surcharged) functions in the HAL_LTDC_Init() and HAL_LTDC_DeInit()
140 only when these callbacks are null (not registered beforehand).
141 If not, MspInit or MspDeInit are not null, the HAL_LTDC_Init() and HAL_LTDC_DeInit()
142 keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
143
144 [..]
145 Callbacks can be registered/unregistered in HAL_LTDC_STATE_READY state only.
146 Exception done MspInit/MspDeInit that can be registered/unregistered
147 in HAL_LTDC_STATE_READY or HAL_LTDC_STATE_RESET state,
148 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
149 In that case first register the MspInit/MspDeInit user callbacks
150 using HAL_LTDC_RegisterCallback() before calling HAL_LTDC_DeInit()
151 or HAL_LTDC_Init() function.
152
153 [..]
154 When the compilation define USE_HAL_LTDC_REGISTER_CALLBACKS is set to 0 or
155 not defined, the callback registration feature is not available and all callbacks
156 are set to the corresponding weak functions.
157
158 @endverbatim
159 ******************************************************************************
160 */
161
162 /* Includes ------------------------------------------------------------------*/
163 #include "stm32h7xx_hal.h"
164
165 /** @addtogroup STM32H7xx_HAL_Driver
166 * @{
167 */
168
169 #ifdef HAL_LTDC_MODULE_ENABLED
170
171 #if defined (LTDC)
172
173 /** @defgroup LTDC LTDC
174 * @brief LTDC HAL module driver
175 * @{
176 */
177
178
179 /* Private typedef -----------------------------------------------------------*/
180 /* Private define ------------------------------------------------------------*/
181 /** @defgroup LTDC_Private_Define LTDC Private Define
182 * @{
183 */
184 #define LTDC_TIMEOUT_VALUE ((uint32_t)100U) /* 100ms */
185 /**
186 * @}
187 */
188 /* Private macro -------------------------------------------------------------*/
189 /* Private variables ---------------------------------------------------------*/
190 /* Private function prototypes -----------------------------------------------*/
191 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
192 /* Private functions ---------------------------------------------------------*/
193
194 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
195 * @{
196 */
197
198 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
199 * @brief Initialization and Configuration functions
200 *
201 @verbatim
202 ===============================================================================
203 ##### Initialization and Configuration functions #####
204 ===============================================================================
205 [..] This section provides functions allowing to:
206 (+) Initialize and configure the LTDC
207 (+) De-initialize the LTDC
208
209 @endverbatim
210 * @{
211 */
212
213 /**
214 * @brief Initialize the LTDC according to the specified parameters in the LTDC_InitTypeDef.
215 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
216 * the configuration information for the LTDC.
217 * @retval HAL status
218 */
HAL_LTDC_Init(LTDC_HandleTypeDef * hltdc)219 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
220 {
221 uint32_t tmp;
222 uint32_t tmp1;
223
224 /* Check the LTDC peripheral state */
225 if (hltdc == NULL)
226 {
227 return HAL_ERROR;
228 }
229
230 /* Check function parameters */
231 assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
232 assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
233 assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
234 assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
235 assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
236 assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
237 assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
238 assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
239 assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
240 assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
241 assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
242 assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
243 assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
244
245 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
246 if (hltdc->State == HAL_LTDC_STATE_RESET)
247 {
248 /* Allocate lock resource and initialize it */
249 hltdc->Lock = HAL_UNLOCKED;
250
251 /* Reset the LTDC callback to the legacy weak callbacks */
252 hltdc->LineEventCallback = HAL_LTDC_LineEventCallback; /* Legacy weak LineEventCallback */
253 hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback; /* Legacy weak ReloadEventCallback */
254 hltdc->ErrorCallback = HAL_LTDC_ErrorCallback; /* Legacy weak ErrorCallback */
255
256 if (hltdc->MspInitCallback == NULL)
257 {
258 hltdc->MspInitCallback = HAL_LTDC_MspInit;
259 }
260 /* Init the low level hardware */
261 hltdc->MspInitCallback(hltdc);
262 }
263 #else
264 if (hltdc->State == HAL_LTDC_STATE_RESET)
265 {
266 /* Allocate lock resource and initialize it */
267 hltdc->Lock = HAL_UNLOCKED;
268 /* Init the low level hardware */
269 HAL_LTDC_MspInit(hltdc);
270 }
271 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
272
273 /* Change LTDC peripheral state */
274 hltdc->State = HAL_LTDC_STATE_BUSY;
275
276 /* Configure the HS, VS, DE and PC polarity */
277 hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
278 hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
279 hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
280
281 /* Set Synchronization size */
282 tmp = (hltdc->Init.HorizontalSync << 16U);
283 WRITE_REG(hltdc->Instance->SSCR, (tmp | hltdc->Init.VerticalSync));
284
285 /* Set Accumulated Back porch */
286 tmp = (hltdc->Init.AccumulatedHBP << 16U);
287 WRITE_REG(hltdc->Instance->BPCR, (tmp | hltdc->Init.AccumulatedVBP));
288
289 /* Set Accumulated Active Width */
290 tmp = (hltdc->Init.AccumulatedActiveW << 16U);
291 WRITE_REG(hltdc->Instance->AWCR, (tmp | hltdc->Init.AccumulatedActiveH));
292
293 /* Set Total Width */
294 tmp = (hltdc->Init.TotalWidth << 16U);
295 WRITE_REG(hltdc->Instance->TWCR, (tmp | hltdc->Init.TotalHeigh));
296
297 /* Set the background color value */
298 tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8U);
299 tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16U);
300 hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
301 hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
302
303 /* Enable the Transfer Error and FIFO underrun interrupts */
304 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE | LTDC_IT_FU);
305
306 /* Enable LTDC by setting LTDCEN bit */
307 __HAL_LTDC_ENABLE(hltdc);
308
309 /* Initialize the error code */
310 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
311
312 /* Initialize the LTDC state*/
313 hltdc->State = HAL_LTDC_STATE_READY;
314
315 return HAL_OK;
316 }
317
318 /**
319 * @brief De-initialize the LTDC peripheral.
320 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
321 * the configuration information for the LTDC.
322 * @retval None
323 */
324
HAL_LTDC_DeInit(LTDC_HandleTypeDef * hltdc)325 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
326 {
327 uint32_t tickstart;
328
329 /* Check the LTDC peripheral state */
330 if (hltdc == NULL)
331 {
332 return HAL_ERROR;
333 }
334
335 /* Check function parameters */
336 assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
337
338 /* Disable LTDC Layer 1 */
339 __HAL_LTDC_LAYER_DISABLE(hltdc, LTDC_LAYER_1);
340
341 #if defined(LTDC_Layer2_BASE)
342 /* Disable LTDC Layer 2 */
343 __HAL_LTDC_LAYER_DISABLE(hltdc, LTDC_LAYER_2);
344 #endif /* LTDC_Layer2_BASE */
345
346 /* Reload during vertical blanking period */
347 __HAL_LTDC_VERTICAL_BLANKING_RELOAD_CONFIG(hltdc);
348
349 /* Get tick */
350 tickstart = HAL_GetTick();
351
352 /* Wait for VSYNC Interrupt */
353 while (READ_BIT(hltdc->Instance->CDSR, LTDC_CDSR_VSYNCS) == 0U)
354 {
355 /* Check for the Timeout */
356 if ((HAL_GetTick() - tickstart) > LTDC_TIMEOUT_VALUE)
357 {
358 break;
359 }
360 }
361
362 /* Disable LTDC */
363 __HAL_LTDC_DISABLE(hltdc);
364
365 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
366 if (hltdc->MspDeInitCallback == NULL)
367 {
368 hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit;
369 }
370 /* DeInit the low level hardware */
371 hltdc->MspDeInitCallback(hltdc);
372 #else
373 /* DeInit the low level hardware */
374 HAL_LTDC_MspDeInit(hltdc);
375 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
376
377 /* Initialize the error code */
378 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
379
380 /* Initialize the LTDC state*/
381 hltdc->State = HAL_LTDC_STATE_RESET;
382
383 /* Release Lock */
384 __HAL_UNLOCK(hltdc);
385
386 return HAL_OK;
387 }
388
389 /**
390 * @brief Initialize the LTDC MSP.
391 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
392 * the configuration information for the LTDC.
393 * @retval None
394 */
HAL_LTDC_MspInit(LTDC_HandleTypeDef * hltdc)395 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
396 {
397 /* Prevent unused argument(s) compilation warning */
398 UNUSED(hltdc);
399
400 /* NOTE : This function should not be modified, when the callback is needed,
401 the HAL_LTDC_MspInit could be implemented in the user file
402 */
403 }
404
405 /**
406 * @brief De-initialize the LTDC MSP.
407 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
408 * the configuration information for the LTDC.
409 * @retval None
410 */
HAL_LTDC_MspDeInit(LTDC_HandleTypeDef * hltdc)411 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc)
412 {
413 /* Prevent unused argument(s) compilation warning */
414 UNUSED(hltdc);
415
416 /* NOTE : This function should not be modified, when the callback is needed,
417 the HAL_LTDC_MspDeInit could be implemented in the user file
418 */
419 }
420
421 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
422 /**
423 * @brief Register a User LTDC Callback
424 * To be used instead of the weak predefined callback
425 * @param hltdc ltdc handle
426 * @param CallbackID ID of the callback to be registered
427 * This parameter can be one of the following values:
428 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
429 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
430 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
431 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
432 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
433 * @param pCallback pointer to the Callback function
434 * @retval status
435 */
HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef * hltdc,HAL_LTDC_CallbackIDTypeDef CallbackID,pLTDC_CallbackTypeDef pCallback)436 HAL_StatusTypeDef HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID,
437 pLTDC_CallbackTypeDef pCallback)
438 {
439 HAL_StatusTypeDef status = HAL_OK;
440
441 if (pCallback == NULL)
442 {
443 /* Update the error code */
444 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
445
446 return HAL_ERROR;
447 }
448 /* Process locked */
449 __HAL_LOCK(hltdc);
450
451 if (hltdc->State == HAL_LTDC_STATE_READY)
452 {
453 switch (CallbackID)
454 {
455 case HAL_LTDC_LINE_EVENT_CB_ID :
456 hltdc->LineEventCallback = pCallback;
457 break;
458
459 case HAL_LTDC_RELOAD_EVENT_CB_ID :
460 hltdc->ReloadEventCallback = pCallback;
461 break;
462
463 case HAL_LTDC_ERROR_CB_ID :
464 hltdc->ErrorCallback = pCallback;
465 break;
466
467 case HAL_LTDC_MSPINIT_CB_ID :
468 hltdc->MspInitCallback = pCallback;
469 break;
470
471 case HAL_LTDC_MSPDEINIT_CB_ID :
472 hltdc->MspDeInitCallback = pCallback;
473 break;
474
475 default :
476 /* Update the error code */
477 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
478 /* Return error status */
479 status = HAL_ERROR;
480 break;
481 }
482 }
483 else if (hltdc->State == HAL_LTDC_STATE_RESET)
484 {
485 switch (CallbackID)
486 {
487 case HAL_LTDC_MSPINIT_CB_ID :
488 hltdc->MspInitCallback = pCallback;
489 break;
490
491 case HAL_LTDC_MSPDEINIT_CB_ID :
492 hltdc->MspDeInitCallback = pCallback;
493 break;
494
495 default :
496 /* Update the error code */
497 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
498 /* Return error status */
499 status = HAL_ERROR;
500 break;
501 }
502 }
503 else
504 {
505 /* Update the error code */
506 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
507 /* Return error status */
508 status = HAL_ERROR;
509 }
510
511 /* Release Lock */
512 __HAL_UNLOCK(hltdc);
513
514 return status;
515 }
516
517 /**
518 * @brief Unregister an LTDC Callback
519 * LTDC callback is redirected to the weak predefined callback
520 * @param hltdc ltdc handle
521 * @param CallbackID ID of the callback to be unregistered
522 * This parameter can be one of the following values:
523 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
524 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
525 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
526 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
527 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
528 * @retval status
529 */
HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef * hltdc,HAL_LTDC_CallbackIDTypeDef CallbackID)530 HAL_StatusTypeDef HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID)
531 {
532 HAL_StatusTypeDef status = HAL_OK;
533
534 /* Process locked */
535 __HAL_LOCK(hltdc);
536
537 if (hltdc->State == HAL_LTDC_STATE_READY)
538 {
539 switch (CallbackID)
540 {
541 case HAL_LTDC_LINE_EVENT_CB_ID :
542 hltdc->LineEventCallback = HAL_LTDC_LineEventCallback; /* Legacy weak LineEventCallback */
543 break;
544
545 case HAL_LTDC_RELOAD_EVENT_CB_ID :
546 hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback; /* Legacy weak ReloadEventCallback */
547 break;
548
549 case HAL_LTDC_ERROR_CB_ID :
550 hltdc->ErrorCallback = HAL_LTDC_ErrorCallback; /* Legacy weak ErrorCallback */
551 break;
552
553 case HAL_LTDC_MSPINIT_CB_ID :
554 hltdc->MspInitCallback = HAL_LTDC_MspInit; /* Legcay weak MspInit Callback */
555 break;
556
557 case HAL_LTDC_MSPDEINIT_CB_ID :
558 hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit; /* Legcay weak MspDeInit Callback */
559 break;
560
561 default :
562 /* Update the error code */
563 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
564 /* Return error status */
565 status = HAL_ERROR;
566 break;
567 }
568 }
569 else if (hltdc->State == HAL_LTDC_STATE_RESET)
570 {
571 switch (CallbackID)
572 {
573 case HAL_LTDC_MSPINIT_CB_ID :
574 hltdc->MspInitCallback = HAL_LTDC_MspInit; /* Legcay weak MspInit Callback */
575 break;
576
577 case HAL_LTDC_MSPDEINIT_CB_ID :
578 hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit; /* Legcay weak MspDeInit Callback */
579 break;
580
581 default :
582 /* Update the error code */
583 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
584 /* Return error status */
585 status = HAL_ERROR;
586 break;
587 }
588 }
589 else
590 {
591 /* Update the error code */
592 hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
593 /* Return error status */
594 status = HAL_ERROR;
595 }
596
597 /* Release Lock */
598 __HAL_UNLOCK(hltdc);
599
600 return status;
601 }
602 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
603
604 /**
605 * @}
606 */
607
608 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
609 * @brief IO operation functions
610 *
611 @verbatim
612 ===============================================================================
613 ##### IO operation functions #####
614 ===============================================================================
615 [..] This section provides function allowing to:
616 (+) Handle LTDC interrupt request
617
618 @endverbatim
619 * @{
620 */
621 /**
622 * @brief Handle LTDC interrupt request.
623 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
624 * the configuration information for the LTDC.
625 * @retval HAL status
626 */
HAL_LTDC_IRQHandler(LTDC_HandleTypeDef * hltdc)627 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
628 {
629 uint32_t isrflags = READ_REG(hltdc->Instance->ISR);
630 uint32_t itsources = READ_REG(hltdc->Instance->IER);
631
632 /* Transfer Error Interrupt management ***************************************/
633 if (((isrflags & LTDC_ISR_TERRIF) != 0U) && ((itsources & LTDC_IER_TERRIE) != 0U))
634 {
635 /* Disable the transfer Error interrupt */
636 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
637
638 /* Clear the transfer error flag */
639 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
640
641 /* Update error code */
642 hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
643
644 /* Change LTDC state */
645 hltdc->State = HAL_LTDC_STATE_ERROR;
646
647 /* Process unlocked */
648 __HAL_UNLOCK(hltdc);
649
650 /* Transfer error Callback */
651 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
652 /*Call registered error callback*/
653 hltdc->ErrorCallback(hltdc);
654 #else
655 /* Call legacy error callback*/
656 HAL_LTDC_ErrorCallback(hltdc);
657 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
658 }
659
660 /* FIFO underrun Interrupt management ***************************************/
661 if (((isrflags & LTDC_ISR_FUIF) != 0U) && ((itsources & LTDC_IER_FUIE) != 0U))
662 {
663 /* Disable the FIFO underrun interrupt */
664 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
665
666 /* Clear the FIFO underrun flag */
667 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
668
669 /* Update error code */
670 hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
671
672 /* Change LTDC state */
673 hltdc->State = HAL_LTDC_STATE_ERROR;
674
675 /* Process unlocked */
676 __HAL_UNLOCK(hltdc);
677
678 /* Transfer error Callback */
679 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
680 /*Call registered error callback*/
681 hltdc->ErrorCallback(hltdc);
682 #else
683 /* Call legacy error callback*/
684 HAL_LTDC_ErrorCallback(hltdc);
685 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
686 }
687
688 /* Line Interrupt management ************************************************/
689 if (((isrflags & LTDC_ISR_LIF) != 0U) && ((itsources & LTDC_IER_LIE) != 0U))
690 {
691 /* Disable the Line interrupt */
692 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
693
694 /* Clear the Line interrupt flag */
695 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
696
697 /* Change LTDC state */
698 hltdc->State = HAL_LTDC_STATE_READY;
699
700 /* Process unlocked */
701 __HAL_UNLOCK(hltdc);
702
703 /* Line interrupt Callback */
704 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
705 /*Call registered Line Event callback */
706 hltdc->LineEventCallback(hltdc);
707 #else
708 /*Call Legacy Line Event callback */
709 HAL_LTDC_LineEventCallback(hltdc);
710 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
711 }
712
713 /* Register reload Interrupt management ***************************************/
714 if (((isrflags & LTDC_ISR_RRIF) != 0U) && ((itsources & LTDC_IER_RRIE) != 0U))
715 {
716 /* Disable the register reload interrupt */
717 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_RR);
718
719 /* Clear the register reload flag */
720 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_RR);
721
722 /* Change LTDC state */
723 hltdc->State = HAL_LTDC_STATE_READY;
724
725 /* Process unlocked */
726 __HAL_UNLOCK(hltdc);
727
728 /* Reload interrupt Callback */
729 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
730 /*Call registered reload Event callback */
731 hltdc->ReloadEventCallback(hltdc);
732 #else
733 /*Call Legacy Reload Event callback */
734 HAL_LTDC_ReloadEventCallback(hltdc);
735 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
736 }
737 }
738
739 /**
740 * @brief Error LTDC callback.
741 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
742 * the configuration information for the LTDC.
743 * @retval None
744 */
HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef * hltdc)745 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
746 {
747 /* Prevent unused argument(s) compilation warning */
748 UNUSED(hltdc);
749
750 /* NOTE : This function should not be modified, when the callback is needed,
751 the HAL_LTDC_ErrorCallback could be implemented in the user file
752 */
753 }
754
755 /**
756 * @brief Line Event callback.
757 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
758 * the configuration information for the LTDC.
759 * @retval None
760 */
HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef * hltdc)761 __weak void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
762 {
763 /* Prevent unused argument(s) compilation warning */
764 UNUSED(hltdc);
765
766 /* NOTE : This function should not be modified, when the callback is needed,
767 the HAL_LTDC_LineEventCallback could be implemented in the user file
768 */
769 }
770
771 /**
772 * @brief Reload Event callback.
773 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
774 * the configuration information for the LTDC.
775 * @retval None
776 */
HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef * hltdc)777 __weak void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc)
778 {
779 /* Prevent unused argument(s) compilation warning */
780 UNUSED(hltdc);
781
782 /* NOTE : This function should not be modified, when the callback is needed,
783 the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
784 */
785 }
786
787 /**
788 * @}
789 */
790
791 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
792 * @brief Peripheral Control functions
793 *
794 @verbatim
795 ===============================================================================
796 ##### Peripheral Control functions #####
797 ===============================================================================
798 [..] This section provides functions allowing to:
799 (+) Configure the LTDC foreground or/and background parameters.
800 (+) Set the active layer.
801 (+) Configure the color keying.
802 (+) Configure the C-LUT.
803 (+) Enable / Disable the color keying.
804 (+) Enable / Disable the C-LUT.
805 (+) Update the layer position.
806 (+) Update the layer size.
807 (+) Update pixel format on the fly.
808 (+) Update transparency on the fly.
809 (+) Update address on the fly.
810
811 @endverbatim
812 * @{
813 */
814
815 /**
816 * @brief Configure the LTDC Layer according to the specified
817 * parameters in the LTDC_InitTypeDef and create the associated handle.
818 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
819 * the configuration information for the LTDC.
820 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
821 * the configuration information for the Layer.
822 * @param LayerIdx LTDC Layer index.
823 * This parameter can be one of the following values:
824 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
825 * @retval HAL status
826 */
HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef * hltdc,LTDC_LayerCfgTypeDef * pLayerCfg,uint32_t LayerIdx)827 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
828 {
829 /* Check the parameters */
830 assert_param(IS_LTDC_LAYER(LayerIdx));
831 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
832 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
833 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
834 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
835 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
836 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
837 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
838 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
839 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
840 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
841 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
842
843 /* Process locked */
844 __HAL_LOCK(hltdc);
845
846 /* Change LTDC peripheral state */
847 hltdc->State = HAL_LTDC_STATE_BUSY;
848
849 /* Copy new layer configuration into handle structure */
850 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
851
852 /* Configure the LTDC Layer */
853 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
854
855 /* Set the Immediate Reload type */
856 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
857
858 /* Initialize the LTDC state*/
859 hltdc->State = HAL_LTDC_STATE_READY;
860
861 /* Process unlocked */
862 __HAL_UNLOCK(hltdc);
863
864 return HAL_OK;
865 }
866
867 /**
868 * @brief Configure the color keying.
869 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
870 * the configuration information for the LTDC.
871 * @param RGBValue the color key value
872 * @param LayerIdx LTDC Layer index.
873 * This parameter can be one of the following values:
874 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
875 * @retval HAL status
876 */
HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef * hltdc,uint32_t RGBValue,uint32_t LayerIdx)877 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
878 {
879 /* Check the parameters */
880 assert_param(IS_LTDC_LAYER(LayerIdx));
881
882 /* Process locked */
883 __HAL_LOCK(hltdc);
884
885 /* Change LTDC peripheral state */
886 hltdc->State = HAL_LTDC_STATE_BUSY;
887
888 /* Configure the default color values */
889 LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
890 LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
891
892 /* Set the Immediate Reload type */
893 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
894
895 /* Change the LTDC state*/
896 hltdc->State = HAL_LTDC_STATE_READY;
897
898 /* Process unlocked */
899 __HAL_UNLOCK(hltdc);
900
901 return HAL_OK;
902 }
903
904 /**
905 * @brief Load the color lookup table.
906 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
907 * the configuration information for the LTDC.
908 * @param pCLUT pointer to the color lookup table address.
909 * @param CLUTSize the color lookup table size.
910 * @param LayerIdx LTDC Layer index.
911 * This parameter can be one of the following values:
912 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
913 * @retval HAL status
914 */
HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef * hltdc,const uint32_t * pCLUT,uint32_t CLUTSize,uint32_t LayerIdx)915 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, const uint32_t *pCLUT, uint32_t CLUTSize,
916 uint32_t LayerIdx)
917 {
918 uint32_t tmp;
919 uint32_t counter;
920 const uint32_t *pcolorlut = pCLUT;
921 /* Check the parameters */
922 assert_param(IS_LTDC_LAYER(LayerIdx));
923
924 /* Process locked */
925 __HAL_LOCK(hltdc);
926
927 /* Change LTDC peripheral state */
928 hltdc->State = HAL_LTDC_STATE_BUSY;
929
930 for (counter = 0U; (counter < CLUTSize); counter++)
931 {
932 if (hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
933 {
934 tmp = (((counter + (16U * counter)) << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | \
935 ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
936 }
937 else
938 {
939 tmp = ((counter << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | \
940 ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
941 }
942
943 pcolorlut++;
944
945 /* Specifies the C-LUT address and RGB value */
946 LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
947 }
948
949 /* Change the LTDC state*/
950 hltdc->State = HAL_LTDC_STATE_READY;
951
952 /* Process unlocked */
953 __HAL_UNLOCK(hltdc);
954
955 return HAL_OK;
956 }
957
958 /**
959 * @brief Enable the color keying.
960 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
961 * the configuration information for the LTDC.
962 * @param LayerIdx LTDC Layer index.
963 * This parameter can be one of the following values:
964 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
965 * @retval HAL status
966 */
HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)967 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
968 {
969 /* Check the parameters */
970 assert_param(IS_LTDC_LAYER(LayerIdx));
971
972 /* Process locked */
973 __HAL_LOCK(hltdc);
974
975 /* Change LTDC peripheral state */
976 hltdc->State = HAL_LTDC_STATE_BUSY;
977
978 /* Enable LTDC color keying by setting COLKEN bit */
979 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
980
981 /* Set the Immediate Reload type */
982 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
983
984 /* Change the LTDC state*/
985 hltdc->State = HAL_LTDC_STATE_READY;
986
987 /* Process unlocked */
988 __HAL_UNLOCK(hltdc);
989
990 return HAL_OK;
991 }
992
993 /**
994 * @brief Disable the color keying.
995 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
996 * the configuration information for the LTDC.
997 * @param LayerIdx LTDC Layer index.
998 * This parameter can be one of the following values:
999 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1000 * @retval HAL status
1001 */
HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)1002 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1003 {
1004 /* Check the parameters */
1005 assert_param(IS_LTDC_LAYER(LayerIdx));
1006
1007 /* Process locked */
1008 __HAL_LOCK(hltdc);
1009
1010 /* Change LTDC peripheral state */
1011 hltdc->State = HAL_LTDC_STATE_BUSY;
1012
1013 /* Disable LTDC color keying by setting COLKEN bit */
1014 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
1015
1016 /* Set the Immediate Reload type */
1017 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1018
1019 /* Change the LTDC state*/
1020 hltdc->State = HAL_LTDC_STATE_READY;
1021
1022 /* Process unlocked */
1023 __HAL_UNLOCK(hltdc);
1024
1025 return HAL_OK;
1026 }
1027
1028 /**
1029 * @brief Enable the color lookup table.
1030 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1031 * the configuration information for the LTDC.
1032 * @param LayerIdx LTDC Layer index.
1033 * This parameter can be one of the following values:
1034 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1035 * @retval HAL status
1036 */
HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)1037 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1038 {
1039 /* Check the parameters */
1040 assert_param(IS_LTDC_LAYER(LayerIdx));
1041
1042 /* Process locked */
1043 __HAL_LOCK(hltdc);
1044
1045 /* Change LTDC peripheral state */
1046 hltdc->State = HAL_LTDC_STATE_BUSY;
1047
1048 /* Enable LTDC color lookup table by setting CLUTEN bit */
1049 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
1050
1051 /* Set the Immediate Reload type */
1052 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1053
1054 /* Change the LTDC state*/
1055 hltdc->State = HAL_LTDC_STATE_READY;
1056
1057 /* Process unlocked */
1058 __HAL_UNLOCK(hltdc);
1059
1060 return HAL_OK;
1061 }
1062
1063 /**
1064 * @brief Disable the color lookup table.
1065 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1066 * the configuration information for the LTDC.
1067 * @param LayerIdx LTDC Layer index.
1068 * This parameter can be one of the following values:
1069 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1070 * @retval HAL status
1071 */
HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)1072 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1073 {
1074 /* Check the parameters */
1075 assert_param(IS_LTDC_LAYER(LayerIdx));
1076
1077 /* Process locked */
1078 __HAL_LOCK(hltdc);
1079
1080 /* Change LTDC peripheral state */
1081 hltdc->State = HAL_LTDC_STATE_BUSY;
1082
1083 /* Disable LTDC color lookup table by setting CLUTEN bit */
1084 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
1085
1086 /* Set the Immediate Reload type */
1087 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1088
1089 /* Change the LTDC state*/
1090 hltdc->State = HAL_LTDC_STATE_READY;
1091
1092 /* Process unlocked */
1093 __HAL_UNLOCK(hltdc);
1094
1095 return HAL_OK;
1096 }
1097
1098 /**
1099 * @brief Enable Dither.
1100 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1101 * the configuration information for the LTDC.
1102 * @retval HAL status
1103 */
1104
HAL_LTDC_EnableDither(LTDC_HandleTypeDef * hltdc)1105 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
1106 {
1107 /* Process locked */
1108 __HAL_LOCK(hltdc);
1109
1110 /* Change LTDC peripheral state */
1111 hltdc->State = HAL_LTDC_STATE_BUSY;
1112
1113 /* Enable Dither by setting DTEN bit */
1114 LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
1115
1116 /* Change the LTDC state*/
1117 hltdc->State = HAL_LTDC_STATE_READY;
1118
1119 /* Process unlocked */
1120 __HAL_UNLOCK(hltdc);
1121
1122 return HAL_OK;
1123 }
1124
1125 /**
1126 * @brief Disable Dither.
1127 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1128 * the configuration information for the LTDC.
1129 * @retval HAL status
1130 */
1131
HAL_LTDC_DisableDither(LTDC_HandleTypeDef * hltdc)1132 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
1133 {
1134 /* Process locked */
1135 __HAL_LOCK(hltdc);
1136
1137 /* Change LTDC peripheral state */
1138 hltdc->State = HAL_LTDC_STATE_BUSY;
1139
1140 /* Disable Dither by setting DTEN bit */
1141 LTDC->GCR &= ~(uint32_t)LTDC_GCR_DEN;
1142
1143 /* Change the LTDC state*/
1144 hltdc->State = HAL_LTDC_STATE_READY;
1145
1146 /* Process unlocked */
1147 __HAL_UNLOCK(hltdc);
1148
1149 return HAL_OK;
1150 }
1151
1152 /**
1153 * @brief Set the LTDC window size.
1154 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1155 * the configuration information for the LTDC.
1156 * @param XSize LTDC Pixel per line
1157 * @param YSize LTDC Line number
1158 * @param LayerIdx LTDC Layer index.
1159 * This parameter can be one of the following values:
1160 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1161 * @retval HAL status
1162 */
HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef * hltdc,uint32_t XSize,uint32_t YSize,uint32_t LayerIdx)1163 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
1164 {
1165 LTDC_LayerCfgTypeDef *pLayerCfg;
1166
1167 /* Check the parameters (Layers parameters)*/
1168 assert_param(IS_LTDC_LAYER(LayerIdx));
1169 assert_param(IS_LTDC_CFBLL(XSize));
1170 assert_param(IS_LTDC_CFBLNBR(YSize));
1171
1172 /* Process locked */
1173 __HAL_LOCK(hltdc);
1174
1175 /* Change LTDC peripheral state */
1176 hltdc->State = HAL_LTDC_STATE_BUSY;
1177
1178 /* Get layer configuration from handle structure */
1179 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1180
1181 /* update horizontal stop */
1182 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
1183
1184 /* update vertical stop */
1185 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
1186
1187 /* Reconfigures the color frame buffer pitch in byte */
1188 pLayerCfg->ImageWidth = XSize;
1189
1190 /* Reconfigures the frame buffer line number */
1191 pLayerCfg->ImageHeight = YSize;
1192
1193 /* Set LTDC parameters */
1194 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1195
1196 /* Set the Immediate Reload type */
1197 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1198
1199 /* Change the LTDC state*/
1200 hltdc->State = HAL_LTDC_STATE_READY;
1201
1202 /* Process unlocked */
1203 __HAL_UNLOCK(hltdc);
1204
1205 return HAL_OK;
1206 }
1207
1208 /**
1209 * @brief Set the LTDC window position.
1210 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1211 * the configuration information for the LTDC.
1212 * @param X0 LTDC window X offset
1213 * @param Y0 LTDC window Y offset
1214 * @param LayerIdx LTDC Layer index.
1215 * This parameter can be one of the following values:
1216 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1217 * @retval HAL status
1218 */
HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef * hltdc,uint32_t X0,uint32_t Y0,uint32_t LayerIdx)1219 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
1220 {
1221 LTDC_LayerCfgTypeDef *pLayerCfg;
1222
1223 /* Check the parameters */
1224 assert_param(IS_LTDC_LAYER(LayerIdx));
1225 assert_param(IS_LTDC_CFBLL(X0));
1226 assert_param(IS_LTDC_CFBLNBR(Y0));
1227
1228 /* Process locked */
1229 __HAL_LOCK(hltdc);
1230
1231 /* Change LTDC peripheral state */
1232 hltdc->State = HAL_LTDC_STATE_BUSY;
1233
1234 /* Get layer configuration from handle structure */
1235 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1236
1237 /* update horizontal start/stop */
1238 pLayerCfg->WindowX0 = X0;
1239 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
1240
1241 /* update vertical start/stop */
1242 pLayerCfg->WindowY0 = Y0;
1243 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
1244
1245 /* Set LTDC parameters */
1246 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1247
1248 /* Set the Immediate Reload type */
1249 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1250
1251 /* Change the LTDC state*/
1252 hltdc->State = HAL_LTDC_STATE_READY;
1253
1254 /* Process unlocked */
1255 __HAL_UNLOCK(hltdc);
1256
1257 return HAL_OK;
1258 }
1259
1260 /**
1261 * @brief Reconfigure the pixel format.
1262 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1263 * the configuration information for the LTDC.
1264 * @param Pixelformat new pixel format value.
1265 * @param LayerIdx LTDC Layer index.
1266 * This parameter can be one of the following values:
1267 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1268 * @retval HAL status
1269 */
HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef * hltdc,uint32_t Pixelformat,uint32_t LayerIdx)1270 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
1271 {
1272 LTDC_LayerCfgTypeDef *pLayerCfg;
1273
1274 /* Check the parameters */
1275 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
1276 assert_param(IS_LTDC_LAYER(LayerIdx));
1277
1278 /* Process locked */
1279 __HAL_LOCK(hltdc);
1280
1281 /* Change LTDC peripheral state */
1282 hltdc->State = HAL_LTDC_STATE_BUSY;
1283
1284 /* Get layer configuration from handle structure */
1285 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1286
1287 /* Reconfigure the pixel format */
1288 pLayerCfg->PixelFormat = Pixelformat;
1289
1290 /* Set LTDC parameters */
1291 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1292
1293 /* Set the Immediate Reload type */
1294 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1295
1296 /* Change the LTDC state*/
1297 hltdc->State = HAL_LTDC_STATE_READY;
1298
1299 /* Process unlocked */
1300 __HAL_UNLOCK(hltdc);
1301
1302 return HAL_OK;
1303 }
1304
1305 /**
1306 * @brief Reconfigure the layer alpha value.
1307 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1308 * the configuration information for the LTDC.
1309 * @param Alpha new alpha value.
1310 * @param LayerIdx LTDC Layer index.
1311 * This parameter can be one of the following values:
1312 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1313 * @retval HAL status
1314 */
HAL_LTDC_SetAlpha(LTDC_HandleTypeDef * hltdc,uint32_t Alpha,uint32_t LayerIdx)1315 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1316 {
1317 LTDC_LayerCfgTypeDef *pLayerCfg;
1318
1319 /* Check the parameters */
1320 assert_param(IS_LTDC_ALPHA(Alpha));
1321 assert_param(IS_LTDC_LAYER(LayerIdx));
1322
1323 /* Process locked */
1324 __HAL_LOCK(hltdc);
1325
1326 /* Change LTDC peripheral state */
1327 hltdc->State = HAL_LTDC_STATE_BUSY;
1328
1329 /* Get layer configuration from handle structure */
1330 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1331
1332 /* Reconfigure the Alpha value */
1333 pLayerCfg->Alpha = Alpha;
1334
1335 /* Set LTDC parameters */
1336 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1337
1338 /* Set the Immediate Reload type */
1339 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1340
1341 /* Change the LTDC state*/
1342 hltdc->State = HAL_LTDC_STATE_READY;
1343
1344 /* Process unlocked */
1345 __HAL_UNLOCK(hltdc);
1346
1347 return HAL_OK;
1348 }
1349 /**
1350 * @brief Reconfigure the frame buffer Address.
1351 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1352 * the configuration information for the LTDC.
1353 * @param Address new address value.
1354 * @param LayerIdx LTDC Layer index.
1355 * This parameter can be one of the following values:
1356 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1357 * @retval HAL status
1358 */
HAL_LTDC_SetAddress(LTDC_HandleTypeDef * hltdc,uint32_t Address,uint32_t LayerIdx)1359 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1360 {
1361 LTDC_LayerCfgTypeDef *pLayerCfg;
1362
1363 /* Check the parameters */
1364 assert_param(IS_LTDC_LAYER(LayerIdx));
1365
1366 /* Process locked */
1367 __HAL_LOCK(hltdc);
1368
1369 /* Change LTDC peripheral state */
1370 hltdc->State = HAL_LTDC_STATE_BUSY;
1371
1372 /* Get layer configuration from handle structure */
1373 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1374
1375 /* Reconfigure the Address */
1376 pLayerCfg->FBStartAdress = Address;
1377
1378 /* Set LTDC parameters */
1379 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1380
1381 /* Set the Immediate Reload type */
1382 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1383
1384 /* Change the LTDC state*/
1385 hltdc->State = HAL_LTDC_STATE_READY;
1386
1387 /* Process unlocked */
1388 __HAL_UNLOCK(hltdc);
1389
1390 return HAL_OK;
1391 }
1392
1393 /**
1394 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width
1395 * that is larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to
1396 * layer for which we want to read and display on screen only a portion 320x240 taken in the center
1397 * of the buffer.
1398 * The pitch in pixels will be in that case 800 pixels and not 320 pixels as initially configured by previous
1399 * call to HAL_LTDC_ConfigLayer().
1400 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default
1401 * pitch configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1402 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1403 * the configuration information for the LTDC.
1404 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1405 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1406 * @retval HAL status
1407 */
HAL_LTDC_SetPitch(LTDC_HandleTypeDef * hltdc,uint32_t LinePitchInPixels,uint32_t LayerIdx)1408 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1409 {
1410 uint32_t tmp;
1411 uint32_t pitchUpdate;
1412 uint32_t pixelFormat;
1413
1414 /* Check the parameters */
1415 assert_param(IS_LTDC_LAYER(LayerIdx));
1416
1417 /* Process locked */
1418 __HAL_LOCK(hltdc);
1419
1420 /* Change LTDC peripheral state */
1421 hltdc->State = HAL_LTDC_STATE_BUSY;
1422
1423 /* get LayerIdx used pixel format */
1424 pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1425
1426 if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1427 {
1428 tmp = 4U;
1429 }
1430 else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1431 {
1432 tmp = 3U;
1433 }
1434 else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1435 (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1436 (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1437 (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1438 {
1439 tmp = 2U;
1440 }
1441 else
1442 {
1443 tmp = 1U;
1444 }
1445
1446 pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
1447
1448 /* Clear previously set standard pitch */
1449 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1450
1451 /* Set the Reload type as immediate update of LTDC pitch configured above */
1452 LTDC->SRCR |= LTDC_SRCR_IMR;
1453
1454 /* Set new line pitch value */
1455 LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1456
1457 /* Set the Reload type as immediate update of LTDC pitch configured above */
1458 LTDC->SRCR |= LTDC_SRCR_IMR;
1459
1460 /* Change the LTDC state*/
1461 hltdc->State = HAL_LTDC_STATE_READY;
1462
1463 /* Process unlocked */
1464 __HAL_UNLOCK(hltdc);
1465
1466 return HAL_OK;
1467 }
1468
1469 /**
1470 * @brief Define the position of the line interrupt.
1471 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1472 * the configuration information for the LTDC.
1473 * @param Line Line Interrupt Position.
1474 * @note User application may resort to HAL_LTDC_LineEventCallback() at line interrupt generation.
1475 * @retval HAL status
1476 */
HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef * hltdc,uint32_t Line)1477 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
1478 {
1479 /* Check the parameters */
1480 assert_param(IS_LTDC_LIPOS(Line));
1481
1482 /* Process locked */
1483 __HAL_LOCK(hltdc);
1484
1485 /* Change LTDC peripheral state */
1486 hltdc->State = HAL_LTDC_STATE_BUSY;
1487
1488 /* Disable the Line interrupt */
1489 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
1490
1491 /* Set the Line Interrupt position */
1492 LTDC->LIPCR = (uint32_t)Line;
1493
1494 /* Enable the Line interrupt */
1495 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
1496
1497 /* Change the LTDC state*/
1498 hltdc->State = HAL_LTDC_STATE_READY;
1499
1500 /* Process unlocked */
1501 __HAL_UNLOCK(hltdc);
1502
1503 return HAL_OK;
1504 }
1505
1506 /**
1507 * @brief Reload LTDC Layers configuration.
1508 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1509 * the configuration information for the LTDC.
1510 * @param ReloadType This parameter can be one of the following values :
1511 * LTDC_RELOAD_IMMEDIATE : Immediate Reload
1512 * LTDC_RELOAD_VERTICAL_BLANKING : Reload in the next Vertical Blanking
1513 * @note User application may resort to HAL_LTDC_ReloadEventCallback() at reload interrupt generation.
1514 * @retval HAL status
1515 */
HAL_LTDC_Reload(LTDC_HandleTypeDef * hltdc,uint32_t ReloadType)1516 HAL_StatusTypeDef HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType)
1517 {
1518 /* Check the parameters */
1519 assert_param(IS_LTDC_RELOAD(ReloadType));
1520
1521 /* Process locked */
1522 __HAL_LOCK(hltdc);
1523
1524 /* Change LTDC peripheral state */
1525 hltdc->State = HAL_LTDC_STATE_BUSY;
1526
1527 /* Enable the Reload interrupt */
1528 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_RR);
1529
1530 /* Apply Reload type */
1531 hltdc->Instance->SRCR = ReloadType;
1532
1533 /* Change the LTDC state*/
1534 hltdc->State = HAL_LTDC_STATE_READY;
1535
1536 /* Process unlocked */
1537 __HAL_UNLOCK(hltdc);
1538
1539 return HAL_OK;
1540 }
1541
1542 /**
1543 * @brief Configure the LTDC Layer according to the specified without reloading
1544 * parameters in the LTDC_InitTypeDef and create the associated handle.
1545 * Variant of the function HAL_LTDC_ConfigLayer without immediate reload.
1546 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1547 * the configuration information for the LTDC.
1548 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
1549 * the configuration information for the Layer.
1550 * @param LayerIdx LTDC Layer index.
1551 * This parameter can be one of the following values:
1552 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1553 * @retval HAL status
1554 */
HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef * hltdc,LTDC_LayerCfgTypeDef * pLayerCfg,uint32_t LayerIdx)1555 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg,
1556 uint32_t LayerIdx)
1557 {
1558 /* Check the parameters */
1559 assert_param(IS_LTDC_LAYER(LayerIdx));
1560 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
1561 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
1562 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
1563 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
1564 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
1565 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
1566 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
1567 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
1568 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
1569 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
1570 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
1571
1572 /* Process locked */
1573 __HAL_LOCK(hltdc);
1574
1575 /* Change LTDC peripheral state */
1576 hltdc->State = HAL_LTDC_STATE_BUSY;
1577
1578 /* Copy new layer configuration into handle structure */
1579 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
1580
1581 /* Configure the LTDC Layer */
1582 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1583
1584 /* Initialize the LTDC state*/
1585 hltdc->State = HAL_LTDC_STATE_READY;
1586
1587 /* Process unlocked */
1588 __HAL_UNLOCK(hltdc);
1589
1590 return HAL_OK;
1591 }
1592
1593 /**
1594 * @brief Set the LTDC window size without reloading.
1595 * Variant of the function HAL_LTDC_SetWindowSize without immediate reload.
1596 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1597 * the configuration information for the LTDC.
1598 * @param XSize LTDC Pixel per line
1599 * @param YSize LTDC Line number
1600 * @param LayerIdx LTDC Layer index.
1601 * This parameter can be one of the following values:
1602 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1603 * @retval HAL status
1604 */
HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t XSize,uint32_t YSize,uint32_t LayerIdx)1605 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize,
1606 uint32_t LayerIdx)
1607 {
1608 LTDC_LayerCfgTypeDef *pLayerCfg;
1609
1610 /* Check the parameters (Layers parameters)*/
1611 assert_param(IS_LTDC_LAYER(LayerIdx));
1612 assert_param(IS_LTDC_CFBLL(XSize));
1613 assert_param(IS_LTDC_CFBLNBR(YSize));
1614
1615 /* Process locked */
1616 __HAL_LOCK(hltdc);
1617
1618 /* Change LTDC peripheral state */
1619 hltdc->State = HAL_LTDC_STATE_BUSY;
1620
1621 /* Get layer configuration from handle structure */
1622 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1623
1624 /* update horizontal stop */
1625 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
1626
1627 /* update vertical stop */
1628 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
1629
1630 /* Reconfigures the color frame buffer pitch in byte */
1631 pLayerCfg->ImageWidth = XSize;
1632
1633 /* Reconfigures the frame buffer line number */
1634 pLayerCfg->ImageHeight = YSize;
1635
1636 /* Set LTDC parameters */
1637 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1638
1639 /* Change the LTDC state*/
1640 hltdc->State = HAL_LTDC_STATE_READY;
1641
1642 /* Process unlocked */
1643 __HAL_UNLOCK(hltdc);
1644
1645 return HAL_OK;
1646 }
1647
1648 /**
1649 * @brief Set the LTDC window position without reloading.
1650 * Variant of the function HAL_LTDC_SetWindowPosition without immediate reload.
1651 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1652 * the configuration information for the LTDC.
1653 * @param X0 LTDC window X offset
1654 * @param Y0 LTDC window Y offset
1655 * @param LayerIdx LTDC Layer index.
1656 * This parameter can be one of the following values:
1657 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1658 * @retval HAL status
1659 */
HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t X0,uint32_t Y0,uint32_t LayerIdx)1660 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0,
1661 uint32_t LayerIdx)
1662 {
1663 LTDC_LayerCfgTypeDef *pLayerCfg;
1664
1665 /* Check the parameters */
1666 assert_param(IS_LTDC_LAYER(LayerIdx));
1667 assert_param(IS_LTDC_CFBLL(X0));
1668 assert_param(IS_LTDC_CFBLNBR(Y0));
1669
1670 /* Process locked */
1671 __HAL_LOCK(hltdc);
1672
1673 /* Change LTDC peripheral state */
1674 hltdc->State = HAL_LTDC_STATE_BUSY;
1675
1676 /* Get layer configuration from handle structure */
1677 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1678
1679 /* update horizontal start/stop */
1680 pLayerCfg->WindowX0 = X0;
1681 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
1682
1683 /* update vertical start/stop */
1684 pLayerCfg->WindowY0 = Y0;
1685 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
1686
1687 /* Set LTDC parameters */
1688 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1689
1690 /* Change the LTDC state*/
1691 hltdc->State = HAL_LTDC_STATE_READY;
1692
1693 /* Process unlocked */
1694 __HAL_UNLOCK(hltdc);
1695
1696 return HAL_OK;
1697 }
1698
1699 /**
1700 * @brief Reconfigure the pixel format without reloading.
1701 * Variant of the function HAL_LTDC_SetPixelFormat without immediate reload.
1702 * @param hltdc pointer to a LTDC_HandleTypeDfef structure that contains
1703 * the configuration information for the LTDC.
1704 * @param Pixelformat new pixel format value.
1705 * @param LayerIdx LTDC Layer index.
1706 * This parameter can be one of the following values:
1707 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1708 * @retval HAL status
1709 */
HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t Pixelformat,uint32_t LayerIdx)1710 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
1711 {
1712 LTDC_LayerCfgTypeDef *pLayerCfg;
1713
1714 /* Check the parameters */
1715 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
1716 assert_param(IS_LTDC_LAYER(LayerIdx));
1717
1718 /* Process locked */
1719 __HAL_LOCK(hltdc);
1720
1721 /* Change LTDC peripheral state */
1722 hltdc->State = HAL_LTDC_STATE_BUSY;
1723
1724 /* Get layer configuration from handle structure */
1725 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1726
1727 /* Reconfigure the pixel format */
1728 pLayerCfg->PixelFormat = Pixelformat;
1729
1730 /* Set LTDC parameters */
1731 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1732
1733 /* Change the LTDC state*/
1734 hltdc->State = HAL_LTDC_STATE_READY;
1735
1736 /* Process unlocked */
1737 __HAL_UNLOCK(hltdc);
1738
1739 return HAL_OK;
1740 }
1741
1742 /**
1743 * @brief Reconfigure the layer alpha value without reloading.
1744 * Variant of the function HAL_LTDC_SetAlpha without immediate reload.
1745 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1746 * the configuration information for the LTDC.
1747 * @param Alpha new alpha value.
1748 * @param LayerIdx LTDC Layer index.
1749 * This parameter can be one of the following values:
1750 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1751 * @retval HAL status
1752 */
HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t Alpha,uint32_t LayerIdx)1753 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
1754 {
1755 LTDC_LayerCfgTypeDef *pLayerCfg;
1756
1757 /* Check the parameters */
1758 assert_param(IS_LTDC_ALPHA(Alpha));
1759 assert_param(IS_LTDC_LAYER(LayerIdx));
1760
1761 /* Process locked */
1762 __HAL_LOCK(hltdc);
1763
1764 /* Change LTDC peripheral state */
1765 hltdc->State = HAL_LTDC_STATE_BUSY;
1766
1767 /* Get layer configuration from handle structure */
1768 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1769
1770 /* Reconfigure the Alpha value */
1771 pLayerCfg->Alpha = Alpha;
1772
1773 /* Set LTDC parameters */
1774 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1775
1776 /* Change the LTDC state*/
1777 hltdc->State = HAL_LTDC_STATE_READY;
1778
1779 /* Process unlocked */
1780 __HAL_UNLOCK(hltdc);
1781
1782 return HAL_OK;
1783 }
1784
1785 /**
1786 * @brief Reconfigure the frame buffer Address without reloading.
1787 * Variant of the function HAL_LTDC_SetAddress without immediate reload.
1788 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1789 * the configuration information for the LTDC.
1790 * @param Address new address value.
1791 * @param LayerIdx LTDC Layer index.
1792 * This parameter can be one of the following values:
1793 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1794 * @retval HAL status
1795 */
HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t Address,uint32_t LayerIdx)1796 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
1797 {
1798 LTDC_LayerCfgTypeDef *pLayerCfg;
1799
1800 /* Check the parameters */
1801 assert_param(IS_LTDC_LAYER(LayerIdx));
1802
1803 /* Process locked */
1804 __HAL_LOCK(hltdc);
1805
1806 /* Change LTDC peripheral state */
1807 hltdc->State = HAL_LTDC_STATE_BUSY;
1808
1809 /* Get layer configuration from handle structure */
1810 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
1811
1812 /* Reconfigure the Address */
1813 pLayerCfg->FBStartAdress = Address;
1814
1815 /* Set LTDC parameters */
1816 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1817
1818 /* Change the LTDC state*/
1819 hltdc->State = HAL_LTDC_STATE_READY;
1820
1821 /* Process unlocked */
1822 __HAL_UNLOCK(hltdc);
1823
1824 return HAL_OK;
1825 }
1826
1827 /**
1828 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width
1829 * that is larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to
1830 * layer for which we want to read and display on screen only a portion 320x240 taken in the center
1831 * of the buffer.
1832 * The pitch in pixels will be in that case 800 pixels and not 320 pixels as initially configured by
1833 * previous call to HAL_LTDC_ConfigLayer().
1834 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default
1835 * pitch configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1836 * Variant of the function HAL_LTDC_SetPitch without immediate reload.
1837 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1838 * the configuration information for the LTDC.
1839 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1840 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1841 * @retval HAL status
1842 */
HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t LinePitchInPixels,uint32_t LayerIdx)1843 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
1844 {
1845 uint32_t tmp;
1846 uint32_t pitchUpdate;
1847 uint32_t pixelFormat;
1848
1849 /* Check the parameters */
1850 assert_param(IS_LTDC_LAYER(LayerIdx));
1851
1852 /* Process locked */
1853 __HAL_LOCK(hltdc);
1854
1855 /* Change LTDC peripheral state */
1856 hltdc->State = HAL_LTDC_STATE_BUSY;
1857
1858 /* get LayerIdx used pixel format */
1859 pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
1860
1861 if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1862 {
1863 tmp = 4U;
1864 }
1865 else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1866 {
1867 tmp = 3U;
1868 }
1869 else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1870 (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1871 (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1872 (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
1873 {
1874 tmp = 2U;
1875 }
1876 else
1877 {
1878 tmp = 1U;
1879 }
1880
1881 pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
1882
1883 /* Clear previously set standard pitch */
1884 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
1885
1886 /* Set new line pitch value */
1887 LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
1888
1889 /* Change the LTDC state*/
1890 hltdc->State = HAL_LTDC_STATE_READY;
1891
1892 /* Process unlocked */
1893 __HAL_UNLOCK(hltdc);
1894
1895 return HAL_OK;
1896 }
1897
1898
1899 /**
1900 * @brief Configure the color keying without reloading.
1901 * Variant of the function HAL_LTDC_ConfigColorKeying without immediate reload.
1902 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1903 * the configuration information for the LTDC.
1904 * @param RGBValue the color key value
1905 * @param LayerIdx LTDC Layer index.
1906 * This parameter can be one of the following values:
1907 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1908 * @retval HAL status
1909 */
HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t RGBValue,uint32_t LayerIdx)1910 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
1911 {
1912 /* Check the parameters */
1913 assert_param(IS_LTDC_LAYER(LayerIdx));
1914
1915 /* Process locked */
1916 __HAL_LOCK(hltdc);
1917
1918 /* Change LTDC peripheral state */
1919 hltdc->State = HAL_LTDC_STATE_BUSY;
1920
1921 /* Configure the default color values */
1922 LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
1923 LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
1924
1925 /* Change the LTDC state*/
1926 hltdc->State = HAL_LTDC_STATE_READY;
1927
1928 /* Process unlocked */
1929 __HAL_UNLOCK(hltdc);
1930
1931 return HAL_OK;
1932 }
1933
1934 /**
1935 * @brief Enable the color keying without reloading.
1936 * Variant of the function HAL_LTDC_EnableColorKeying without immediate reload.
1937 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1938 * the configuration information for the LTDC.
1939 * @param LayerIdx LTDC Layer index.
1940 * This parameter can be one of the following values:
1941 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1942 * @retval HAL status
1943 */
HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)1944 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1945 {
1946 /* Check the parameters */
1947 assert_param(IS_LTDC_LAYER(LayerIdx));
1948
1949 /* Process locked */
1950 __HAL_LOCK(hltdc);
1951
1952 /* Change LTDC peripheral state */
1953 hltdc->State = HAL_LTDC_STATE_BUSY;
1954
1955 /* Enable LTDC color keying by setting COLKEN bit */
1956 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
1957
1958 /* Change the LTDC state*/
1959 hltdc->State = HAL_LTDC_STATE_READY;
1960
1961 /* Process unlocked */
1962 __HAL_UNLOCK(hltdc);
1963
1964 return HAL_OK;
1965 }
1966
1967 /**
1968 * @brief Disable the color keying without reloading.
1969 * Variant of the function HAL_LTDC_DisableColorKeying without immediate reload.
1970 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1971 * the configuration information for the LTDC.
1972 * @param LayerIdx LTDC Layer index.
1973 * This parameter can be one of the following values:
1974 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1975 * @retval HAL status
1976 */
HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)1977 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
1978 {
1979 /* Check the parameters */
1980 assert_param(IS_LTDC_LAYER(LayerIdx));
1981
1982 /* Process locked */
1983 __HAL_LOCK(hltdc);
1984
1985 /* Change LTDC peripheral state */
1986 hltdc->State = HAL_LTDC_STATE_BUSY;
1987
1988 /* Disable LTDC color keying by setting COLKEN bit */
1989 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
1990
1991 /* Change the LTDC state*/
1992 hltdc->State = HAL_LTDC_STATE_READY;
1993
1994 /* Process unlocked */
1995 __HAL_UNLOCK(hltdc);
1996
1997 return HAL_OK;
1998 }
1999
2000 /**
2001 * @brief Enable the color lookup table without reloading.
2002 * Variant of the function HAL_LTDC_EnableCLUT without immediate reload.
2003 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2004 * the configuration information for the LTDC.
2005 * @param LayerIdx LTDC Layer index.
2006 * This parameter can be one of the following values:
2007 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
2008 * @retval HAL status
2009 */
HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)2010 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
2011 {
2012 /* Check the parameters */
2013 assert_param(IS_LTDC_LAYER(LayerIdx));
2014
2015 /* Process locked */
2016 __HAL_LOCK(hltdc);
2017
2018 /* Change LTDC peripheral state */
2019 hltdc->State = HAL_LTDC_STATE_BUSY;
2020
2021 /* Disable LTDC color lookup table by setting CLUTEN bit */
2022 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
2023
2024 /* Change the LTDC state*/
2025 hltdc->State = HAL_LTDC_STATE_READY;
2026
2027 /* Process unlocked */
2028 __HAL_UNLOCK(hltdc);
2029
2030 return HAL_OK;
2031 }
2032
2033 /**
2034 * @brief Disable the color lookup table without reloading.
2035 * Variant of the function HAL_LTDC_DisableCLUT without immediate reload.
2036 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2037 * the configuration information for the LTDC.
2038 * @param LayerIdx LTDC Layer index.
2039 * This parameter can be one of the following values:
2040 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
2041 * @retval HAL status
2042 */
HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef * hltdc,uint32_t LayerIdx)2043 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
2044 {
2045 /* Check the parameters */
2046 assert_param(IS_LTDC_LAYER(LayerIdx));
2047
2048 /* Process locked */
2049 __HAL_LOCK(hltdc);
2050
2051 /* Change LTDC peripheral state */
2052 hltdc->State = HAL_LTDC_STATE_BUSY;
2053
2054 /* Disable LTDC color lookup table by setting CLUTEN bit */
2055 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
2056
2057 /* Change the LTDC state*/
2058 hltdc->State = HAL_LTDC_STATE_READY;
2059
2060 /* Process unlocked */
2061 __HAL_UNLOCK(hltdc);
2062
2063 return HAL_OK;
2064 }
2065
2066 /**
2067 * @}
2068 */
2069
2070 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
2071 * @brief Peripheral State and Errors functions
2072 *
2073 @verbatim
2074 ===============================================================================
2075 ##### Peripheral State and Errors functions #####
2076 ===============================================================================
2077 [..]
2078 This subsection provides functions allowing to
2079 (+) Check the LTDC handle state.
2080 (+) Get the LTDC handle error code.
2081
2082 @endverbatim
2083 * @{
2084 */
2085
2086 /**
2087 * @brief Return the LTDC handle state.
2088 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2089 * the configuration information for the LTDC.
2090 * @retval HAL state
2091 */
HAL_LTDC_GetState(const LTDC_HandleTypeDef * hltdc)2092 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(const LTDC_HandleTypeDef *hltdc)
2093 {
2094 return hltdc->State;
2095 }
2096
2097 /**
2098 * @brief Return the LTDC handle error code.
2099 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2100 * the configuration information for the LTDC.
2101 * @retval LTDC Error Code
2102 */
HAL_LTDC_GetError(const LTDC_HandleTypeDef * hltdc)2103 uint32_t HAL_LTDC_GetError(const LTDC_HandleTypeDef *hltdc)
2104 {
2105 return hltdc->ErrorCode;
2106 }
2107
2108 /**
2109 * @}
2110 */
2111
2112 /**
2113 * @}
2114 */
2115
2116 /** @defgroup LTDC_Private_Functions LTDC Private Functions
2117 * @{
2118 */
2119
2120 /**
2121 * @brief Configure the LTDC peripheral
2122 * @param hltdc Pointer to a LTDC_HandleTypeDef structure that contains
2123 * the configuration information for the LTDC.
2124 * @param pLayerCfg Pointer LTDC Layer Configuration structure
2125 * @param LayerIdx LTDC Layer index.
2126 * This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
2127 * @retval None
2128 */
LTDC_SetConfig(LTDC_HandleTypeDef * hltdc,LTDC_LayerCfgTypeDef * pLayerCfg,uint32_t LayerIdx)2129 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
2130 {
2131 uint32_t tmp;
2132 uint32_t tmp1;
2133 uint32_t tmp2;
2134
2135 /* Configure the horizontal start and stop position */
2136 tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U)) << 16U);
2137 LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
2138 LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + \
2139 ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U) + 1U) | tmp);
2140
2141 /* Configure the vertical start and stop position */
2142 tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16U);
2143 LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
2144 LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1U) | tmp);
2145
2146 /* Specifies the pixel format */
2147 LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
2148 LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
2149
2150 /* Configure the default color values */
2151 tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8U);
2152 tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16U);
2153 tmp2 = (pLayerCfg->Alpha0 << 24U);
2154 WRITE_REG(LTDC_LAYER(hltdc, LayerIdx)->DCCR, (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2));
2155
2156 /* Specifies the constant alpha value */
2157 LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
2158 LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
2159
2160 /* Specifies the blending factors */
2161 LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
2162 LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
2163
2164 /* Configure the color frame buffer start address */
2165 WRITE_REG(LTDC_LAYER(hltdc, LayerIdx)->CFBAR, pLayerCfg->FBStartAdress);
2166
2167 if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
2168 {
2169 tmp = 4U;
2170 }
2171 else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
2172 {
2173 tmp = 3U;
2174 }
2175 else if ((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
2176 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
2177 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
2178 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
2179 {
2180 tmp = 2U;
2181 }
2182 else
2183 {
2184 tmp = 1U;
2185 }
2186
2187 /* Configure the color frame buffer pitch in byte */
2188 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
2189 LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16U) |
2190 (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp) + 7U));
2191 /* Configure the frame buffer line number */
2192 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
2193 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
2194
2195 /* Enable LTDC_Layer by setting LEN bit */
2196 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
2197 }
2198
2199 /**
2200 * @}
2201 */
2202
2203
2204 /**
2205 * @}
2206 */
2207
2208 #endif /* LTDC */
2209
2210 #endif /* HAL_LTDC_MODULE_ENABLED */
2211
2212 /**
2213 * @}
2214 */
2215
2216