2 ******************************************************************************
3 * @file stm32f7xx_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
14 ==============================================================================
15 ##### How to use this driver #####
16 ==============================================================================
18 (#) Program the required configuration through the following parameters:
19 the LTDC timing, the horizontal and vertical polarity,
20 the pixel clock polarity, Data Enable polarity and the LTDC background color value
21 using HAL_LTDC_Init() function
23 (#) Program the required configuration through the following parameters:
24 the pixel format, the blending factors, input alpha value, the window size
25 and the image size using HAL_LTDC_ConfigLayer() function for foreground
26 or/and background layer.
28 (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
29 HAL_LTDC_EnableCLUT functions.
31 (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
33 (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
34 and HAL_LTDC_EnableColorKeying functions.
36 (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineEvent()
39 (#) If needed, reconfigure and change the pixel format value, the alpha value
40 value, the window size, the window position and the layer start address
41 for foreground or/and background layer using respectively the following
42 functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
43 HAL_LTDC_SetWindowPosition() and HAL_LTDC_SetAddress().
45 (#) Variant functions with _NoReload suffix allows to set the LTDC configuration/settings without immediate reload.
46 This is useful in case when the program requires to modify serval LTDC settings (on one or both layers)
47 then applying(reload) these settings in one shot by calling the function HAL_LTDC_Reload().
49 After calling the _NoReload functions to set different color/format/layer settings,
50 the program shall call the function HAL_LTDC_Reload() to apply(reload) these settings.
51 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_IMMEDIATE if
52 an immediate reload is required.
53 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_VERTICAL_BLANKING if
54 the reload should be done in the next vertical blanking period,
55 this option allows to avoid display flicker by applying the new settings during the vertical blanking period.
58 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
60 *** LTDC HAL driver macros list ***
61 =============================================
63 Below the list of most used macros in LTDC HAL driver.
65 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
66 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
67 (+) __HAL_LTDC_LAYER_ENABLE: Enable an LTDC Layer.
68 (+) __HAL_LTDC_LAYER_DISABLE: Disable an LTDC Layer.
69 (+) __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG: Reload Layer Configuration.
70 (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
71 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
72 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
73 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
74 (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
77 *** Callback registration ***
78 =============================================
80 The compilation define USE_HAL_LTDC_REGISTER_CALLBACKS when set to 1
81 allows the user to configure dynamically the driver callbacks.
82 Use Function @ref HAL_LTDC_RegisterCallback() to register a callback.
84 Function @ref HAL_LTDC_RegisterCallback() allows to register following callbacks:
85 (+) LineEventCallback : LTDC Line Event Callback.
86 (+) ReloadEventCallback : LTDC Reload Event Callback.
87 (+) ErrorCallback : LTDC Error Callback
88 (+) MspInitCallback : LTDC MspInit.
89 (+) MspDeInitCallback : LTDC MspDeInit.
90 This function takes as parameters the HAL peripheral handle, the Callback ID
91 and a pointer to the user callback function.
93 Use function @ref HAL_LTDC_UnRegisterCallback() to reset a callback to the default
95 @ref HAL_LTDC_UnRegisterCallback takes as parameters the HAL peripheral handle,
97 This function allows to reset following callbacks:
98 (+) LineEventCallback : LTDC Line Event Callback.
99 (+) ReloadEventCallback : LTDC Reload Event Callback.
100 (+) ErrorCallback : LTDC Error Callback
101 (+) MspInitCallback : LTDC MspInit.
102 (+) MspDeInitCallback : LTDC MspDeInit.
104 By default, after the HAL_LTDC_Init and when the state is HAL_LTDC_STATE_RESET
105 all callbacks are set to the corresponding weak functions:
106 examples @ref HAL_LTDC_LineEventCallback(), @ref HAL_LTDC_ErrorCallback().
107 Exception done for MspInit and MspDeInit functions that are
108 reset to the legacy weak function in the HAL_LTDC_Init/ @ref HAL_LTDC_DeInit only when
109 these callbacks are null (not registered beforehand).
110 if not, MspInit or MspDeInit are not null, the @ref HAL_LTDC_Init/ @ref HAL_LTDC_DeInit
111 keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
113 Callbacks can be registered/unregistered in HAL_LTDC_STATE_READY state only.
114 Exception done MspInit/MspDeInit that can be registered/unregistered
115 in HAL_LTDC_STATE_READY or HAL_LTDC_STATE_RESET state,
116 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
117 In that case first register the MspInit/MspDeInit user callbacks
118 using @ref HAL_LTDC_RegisterCallback() before calling @ref HAL_LTDC_DeInit
119 or HAL_LTDC_Init function.
121 When The compilation define USE_HAL_LTDC_REGISTER_CALLBACKS is set to 0 or
122 not defined, the callback registration feature is not available and all callbacks
123 are set to the corresponding weak functions.
126 (@) You can refer to the LTDC HAL driver header file for more useful macros
129 ******************************************************************************
132 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
133 * All rights reserved.</center></h2>
135 * This software component is licensed by ST under BSD 3-Clause license,
136 * the "License"; You may not use this file except in compliance with the
137 * License. You may obtain a copy of the License at:
138 * opensource.org/licenses/BSD-3-Clause
140 ******************************************************************************
143 /* Includes ------------------------------------------------------------------*/
144 #include "stm32f7xx_hal.h"
146 #ifdef HAL_LTDC_MODULE_ENABLED
148 /** @addtogroup STM32F7xx_HAL_Driver
152 /** @defgroup LTDC LTDC
153 * @brief LTDC HAL module driver
158 /* Private typedef -----------------------------------------------------------*/
159 /* Private define ------------------------------------------------------------*/
160 /* Private macro -------------------------------------------------------------*/
161 /* Private variables ---------------------------------------------------------*/
162 /* Private function prototypes -----------------------------------------------*/
163 static void LTDC_SetConfig(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
);
164 /* Private functions ---------------------------------------------------------*/
166 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
170 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
171 * @brief Initialization and Configuration functions
174 ===============================================================================
175 ##### Initialization and Configuration functions #####
176 ===============================================================================
177 [..] This section provides functions allowing to:
178 (+) Initialize and configure the LTDC
179 (+) De-initialize the LTDC
186 * @brief Initialize the LTDC according to the specified parameters in the LTDC_InitTypeDef.
187 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
188 * the configuration information for the LTDC.
191 HAL_StatusTypeDef
HAL_LTDC_Init(LTDC_HandleTypeDef
*hltdc
)
195 /* Check the LTDC peripheral state */
201 /* Check function parameters */
202 assert_param(IS_LTDC_ALL_INSTANCE(hltdc
->Instance
));
203 assert_param(IS_LTDC_HSYNC(hltdc
->Init
.HorizontalSync
));
204 assert_param(IS_LTDC_VSYNC(hltdc
->Init
.VerticalSync
));
205 assert_param(IS_LTDC_AHBP(hltdc
->Init
.AccumulatedHBP
));
206 assert_param(IS_LTDC_AVBP(hltdc
->Init
.AccumulatedVBP
));
207 assert_param(IS_LTDC_AAH(hltdc
->Init
.AccumulatedActiveH
));
208 assert_param(IS_LTDC_AAW(hltdc
->Init
.AccumulatedActiveW
));
209 assert_param(IS_LTDC_TOTALH(hltdc
->Init
.TotalHeigh
));
210 assert_param(IS_LTDC_TOTALW(hltdc
->Init
.TotalWidth
));
211 assert_param(IS_LTDC_HSPOL(hltdc
->Init
.HSPolarity
));
212 assert_param(IS_LTDC_VSPOL(hltdc
->Init
.VSPolarity
));
213 assert_param(IS_LTDC_DEPOL(hltdc
->Init
.DEPolarity
));
214 assert_param(IS_LTDC_PCPOL(hltdc
->Init
.PCPolarity
));
216 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
217 if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
219 /* Allocate lock resource and initialize it */
220 hltdc
->Lock
= HAL_UNLOCKED
;
222 /* Reset the LTDC callback to the legacy weak callbacks */
223 hltdc
->LineEventCallback
= HAL_LTDC_LineEventCallback
; /* Legacy weak LineEventCallback */
224 hltdc
->ReloadEventCallback
= HAL_LTDC_ReloadEventCallback
; /* Legacy weak ReloadEventCallback */
225 hltdc
->ErrorCallback
= HAL_LTDC_ErrorCallback
; /* Legacy weak ErrorCallback */
227 if (hltdc
->MspInitCallback
== NULL
)
229 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
;
231 /* Init the low level hardware */
232 hltdc
->MspInitCallback(hltdc
);
235 if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
237 /* Allocate lock resource and initialize it */
238 hltdc
->Lock
= HAL_UNLOCKED
;
239 /* Init the low level hardware */
240 HAL_LTDC_MspInit(hltdc
);
242 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
244 /* Change LTDC peripheral state */
245 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
247 /* Configure the HS, VS, DE and PC polarity */
248 hltdc
->Instance
->GCR
&= ~(LTDC_GCR_HSPOL
| LTDC_GCR_VSPOL
| LTDC_GCR_DEPOL
| LTDC_GCR_PCPOL
);
249 hltdc
->Instance
->GCR
|= (uint32_t)(hltdc
->Init
.HSPolarity
| hltdc
->Init
.VSPolarity
| \
250 hltdc
->Init
.DEPolarity
| hltdc
->Init
.PCPolarity
);
252 /* Set Synchronization size */
253 hltdc
->Instance
->SSCR
&= ~(LTDC_SSCR_VSH
| LTDC_SSCR_HSW
);
254 tmp
= (hltdc
->Init
.HorizontalSync
<< 16U);
255 hltdc
->Instance
->SSCR
|= (tmp
| hltdc
->Init
.VerticalSync
);
257 /* Set Accumulated Back porch */
258 hltdc
->Instance
->BPCR
&= ~(LTDC_BPCR_AVBP
| LTDC_BPCR_AHBP
);
259 tmp
= (hltdc
->Init
.AccumulatedHBP
<< 16U);
260 hltdc
->Instance
->BPCR
|= (tmp
| hltdc
->Init
.AccumulatedVBP
);
262 /* Set Accumulated Active Width */
263 hltdc
->Instance
->AWCR
&= ~(LTDC_AWCR_AAH
| LTDC_AWCR_AAW
);
264 tmp
= (hltdc
->Init
.AccumulatedActiveW
<< 16U);
265 hltdc
->Instance
->AWCR
|= (tmp
| hltdc
->Init
.AccumulatedActiveH
);
267 /* Set Total Width */
268 hltdc
->Instance
->TWCR
&= ~(LTDC_TWCR_TOTALH
| LTDC_TWCR_TOTALW
);
269 tmp
= (hltdc
->Init
.TotalWidth
<< 16U);
270 hltdc
->Instance
->TWCR
|= (tmp
| hltdc
->Init
.TotalHeigh
);
272 /* Set the background color value */
273 tmp
= ((uint32_t)(hltdc
->Init
.Backcolor
.Green
) << 8U);
274 tmp1
= ((uint32_t)(hltdc
->Init
.Backcolor
.Red
) << 16U);
275 hltdc
->Instance
->BCCR
&= ~(LTDC_BCCR_BCBLUE
| LTDC_BCCR_BCGREEN
| LTDC_BCCR_BCRED
);
276 hltdc
->Instance
->BCCR
|= (tmp1
| tmp
| hltdc
->Init
.Backcolor
.Blue
);
278 /* Enable the Transfer Error and FIFO underrun interrupts */
279 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_TE
| LTDC_IT_FU
);
281 /* Enable LTDC by setting LTDCEN bit */
282 __HAL_LTDC_ENABLE(hltdc
);
284 /* Initialize the error code */
285 hltdc
->ErrorCode
= HAL_LTDC_ERROR_NONE
;
287 /* Initialize the LTDC state*/
288 hltdc
->State
= HAL_LTDC_STATE_READY
;
294 * @brief De-initialize the LTDC peripheral.
295 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
296 * the configuration information for the LTDC.
300 HAL_StatusTypeDef
HAL_LTDC_DeInit(LTDC_HandleTypeDef
*hltdc
)
302 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
303 if (hltdc
->MspDeInitCallback
== NULL
)
305 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
;
307 /* DeInit the low level hardware */
308 hltdc
->MspDeInitCallback(hltdc
);
310 /* DeInit the low level hardware */
311 HAL_LTDC_MspDeInit(hltdc
);
312 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
314 /* Initialize the error code */
315 hltdc
->ErrorCode
= HAL_LTDC_ERROR_NONE
;
317 /* Initialize the LTDC state*/
318 hltdc
->State
= HAL_LTDC_STATE_RESET
;
327 * @brief Initialize the LTDC MSP.
328 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
329 * the configuration information for the LTDC.
332 __weak
void HAL_LTDC_MspInit(LTDC_HandleTypeDef
*hltdc
)
334 /* Prevent unused argument(s) compilation warning */
337 /* NOTE : This function should not be modified, when the callback is needed,
338 the HAL_LTDC_MspInit could be implemented in the user file
343 * @brief De-initialize the LTDC MSP.
344 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
345 * the configuration information for the LTDC.
348 __weak
void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef
*hltdc
)
350 /* Prevent unused argument(s) compilation warning */
353 /* NOTE : This function should not be modified, when the callback is needed,
354 the HAL_LTDC_MspDeInit could be implemented in the user file
358 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
360 * @brief Register a User LTDC Callback
361 * To be used instead of the weak predefined callback
362 * @param hltdc ltdc handle
363 * @param CallbackID ID of the callback to be registered
364 * This parameter can be one of the following values:
365 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
366 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
367 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
368 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
369 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
370 * @param pCallback pointer to the Callback function
373 HAL_StatusTypeDef
HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef
*hltdc
, HAL_LTDC_CallbackIDTypeDef CallbackID
, pLTDC_CallbackTypeDef pCallback
)
375 HAL_StatusTypeDef status
= HAL_OK
;
377 if (pCallback
== NULL
)
379 /* Update the error code */
380 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
387 if (hltdc
->State
== HAL_LTDC_STATE_READY
)
391 case HAL_LTDC_LINE_EVENT_CB_ID
:
392 hltdc
->LineEventCallback
= pCallback
;
395 case HAL_LTDC_RELOAD_EVENT_CB_ID
:
396 hltdc
->ReloadEventCallback
= pCallback
;
399 case HAL_LTDC_ERROR_CB_ID
:
400 hltdc
->ErrorCallback
= pCallback
;
403 case HAL_LTDC_MSPINIT_CB_ID
:
404 hltdc
->MspInitCallback
= pCallback
;
407 case HAL_LTDC_MSPDEINIT_CB_ID
:
408 hltdc
->MspDeInitCallback
= pCallback
;
412 /* Update the error code */
413 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
414 /* Return error status */
419 else if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
423 case HAL_LTDC_MSPINIT_CB_ID
:
424 hltdc
->MspInitCallback
= pCallback
;
427 case HAL_LTDC_MSPDEINIT_CB_ID
:
428 hltdc
->MspDeInitCallback
= pCallback
;
432 /* Update the error code */
433 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
434 /* Return error status */
441 /* Update the error code */
442 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
443 /* Return error status */
454 * @brief Unregister an LTDC Callback
455 * LTDC callabck is redirected to the weak predefined callback
456 * @param hltdc ltdc handle
457 * @param CallbackID ID of the callback to be unregistered
458 * This parameter can be one of the following values:
459 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
460 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
461 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
462 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
463 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
466 HAL_StatusTypeDef
HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef
*hltdc
, HAL_LTDC_CallbackIDTypeDef CallbackID
)
468 HAL_StatusTypeDef status
= HAL_OK
;
473 if (hltdc
->State
== HAL_LTDC_STATE_READY
)
477 case HAL_LTDC_LINE_EVENT_CB_ID
:
478 hltdc
->LineEventCallback
= HAL_LTDC_LineEventCallback
; /* Legacy weak LineEventCallback */
481 case HAL_LTDC_RELOAD_EVENT_CB_ID
:
482 hltdc
->ReloadEventCallback
= HAL_LTDC_ReloadEventCallback
; /* Legacy weak ReloadEventCallback */
485 case HAL_LTDC_ERROR_CB_ID
:
486 hltdc
->ErrorCallback
= HAL_LTDC_ErrorCallback
; /* Legacy weak ErrorCallback */
489 case HAL_LTDC_MSPINIT_CB_ID
:
490 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
; /* Legcay weak MspInit Callback */
493 case HAL_LTDC_MSPDEINIT_CB_ID
:
494 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
; /* Legcay weak MspDeInit Callback */
498 /* Update the error code */
499 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
500 /* Return error status */
505 else if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
509 case HAL_LTDC_MSPINIT_CB_ID
:
510 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
; /* Legcay weak MspInit Callback */
513 case HAL_LTDC_MSPDEINIT_CB_ID
:
514 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
; /* Legcay weak MspDeInit Callback */
518 /* Update the error code */
519 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
520 /* Return error status */
527 /* Update the error code */
528 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
529 /* Return error status */
538 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
544 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
545 * @brief IO operation functions
548 ===============================================================================
549 ##### IO operation functions #####
550 ===============================================================================
551 [..] This section provides function allowing to:
552 (+) Handle LTDC interrupt request
558 * @brief Handle LTDC interrupt request.
559 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
560 * the configuration information for the LTDC.
563 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef
*hltdc
)
565 uint32_t isrflags
= READ_REG(hltdc
->Instance
->ISR
);
566 uint32_t itsources
= READ_REG(hltdc
->Instance
->IER
);
568 /* Transfer Error Interrupt management ***************************************/
569 if (((isrflags
& LTDC_ISR_TERRIF
) != 0U) && ((itsources
& LTDC_IER_TERRIE
) != 0U))
571 /* Disable the transfer Error interrupt */
572 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_TE
);
574 /* Clear the transfer error flag */
575 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_TE
);
577 /* Update error code */
578 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_TE
;
580 /* Change LTDC state */
581 hltdc
->State
= HAL_LTDC_STATE_ERROR
;
583 /* Process unlocked */
586 /* Transfer error Callback */
587 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
588 /*Call registered error callback*/
589 hltdc
->ErrorCallback(hltdc
);
591 /* Call legacy error callback*/
592 HAL_LTDC_ErrorCallback(hltdc
);
593 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
596 /* FIFO underrun Interrupt management ***************************************/
597 if (((isrflags
& LTDC_ISR_FUIF
) != 0U) && ((itsources
& LTDC_IER_FUIE
) != 0U))
599 /* Disable the FIFO underrun interrupt */
600 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_FU
);
602 /* Clear the FIFO underrun flag */
603 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_FU
);
605 /* Update error code */
606 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_FU
;
608 /* Change LTDC state */
609 hltdc
->State
= HAL_LTDC_STATE_ERROR
;
611 /* Process unlocked */
614 /* Transfer error Callback */
615 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
616 /*Call registered error callback*/
617 hltdc
->ErrorCallback(hltdc
);
619 /* Call legacy error callback*/
620 HAL_LTDC_ErrorCallback(hltdc
);
621 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
624 /* Line Interrupt management ************************************************/
625 if (((isrflags
& LTDC_ISR_LIF
) != 0U) && ((itsources
& LTDC_IER_LIE
) != 0U))
627 /* Disable the Line interrupt */
628 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_LI
);
630 /* Clear the Line interrupt flag */
631 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_LI
);
633 /* Change LTDC state */
634 hltdc
->State
= HAL_LTDC_STATE_READY
;
636 /* Process unlocked */
639 /* Line interrupt Callback */
640 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
641 /*Call registered Line Event callback */
642 hltdc
->LineEventCallback(hltdc
);
644 /*Call Legacy Line Event callback */
645 HAL_LTDC_LineEventCallback(hltdc
);
646 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
649 /* Register reload Interrupt management ***************************************/
650 if (((isrflags
& LTDC_ISR_RRIF
) != 0U) && ((itsources
& LTDC_IER_RRIE
) != 0U))
652 /* Disable the register reload interrupt */
653 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_RR
);
655 /* Clear the register reload flag */
656 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_RR
);
658 /* Change LTDC state */
659 hltdc
->State
= HAL_LTDC_STATE_READY
;
661 /* Process unlocked */
664 /* Reload interrupt Callback */
665 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
666 /*Call registered reload Event callback */
667 hltdc
->ReloadEventCallback(hltdc
);
669 /*Call Legacy Reload Event callback */
670 HAL_LTDC_ReloadEventCallback(hltdc
);
671 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
676 * @brief Error LTDC callback.
677 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
678 * the configuration information for the LTDC.
681 __weak
void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef
*hltdc
)
683 /* Prevent unused argument(s) compilation warning */
686 /* NOTE : This function should not be modified, when the callback is needed,
687 the HAL_LTDC_ErrorCallback could be implemented in the user file
692 * @brief Line Event callback.
693 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
694 * the configuration information for the LTDC.
697 __weak
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef
*hltdc
)
699 /* Prevent unused argument(s) compilation warning */
702 /* NOTE : This function should not be modified, when the callback is needed,
703 the HAL_LTDC_LineEventCallback could be implemented in the user file
708 * @brief Reload Event callback.
709 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
710 * the configuration information for the LTDC.
713 __weak
void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef
*hltdc
)
715 /* Prevent unused argument(s) compilation warning */
718 /* NOTE : This function should not be modified, when the callback is needed,
719 the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
727 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
728 * @brief Peripheral Control functions
731 ===============================================================================
732 ##### Peripheral Control functions #####
733 ===============================================================================
734 [..] This section provides functions allowing to:
735 (+) Configure the LTDC foreground or/and background parameters.
736 (+) Set the active layer.
737 (+) Configure the color keying.
738 (+) Configure the C-LUT.
739 (+) Enable / Disable the color keying.
740 (+) Enable / Disable the C-LUT.
741 (+) Update the layer position.
742 (+) Update the layer size.
743 (+) Update pixel format on the fly.
744 (+) Update transparency on the fly.
745 (+) Update address on the fly.
752 * @brief Configure the LTDC Layer according to the specified
753 * parameters in the LTDC_InitTypeDef and create the associated handle.
754 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
755 * the configuration information for the LTDC.
756 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
757 * the configuration information for the Layer.
758 * @param LayerIdx LTDC Layer index.
759 * This parameter can be one of the following values:
760 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
763 HAL_StatusTypeDef
HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
765 /* Check the parameters */
766 assert_param(IS_LTDC_LAYER(LayerIdx
));
767 assert_param(IS_LTDC_HCONFIGST(pLayerCfg
->WindowX0
));
768 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg
->WindowX1
));
769 assert_param(IS_LTDC_VCONFIGST(pLayerCfg
->WindowY0
));
770 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg
->WindowY1
));
771 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg
->PixelFormat
));
772 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha
));
773 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha0
));
774 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg
->BlendingFactor1
));
775 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg
->BlendingFactor2
));
776 assert_param(IS_LTDC_CFBLL(pLayerCfg
->ImageWidth
));
777 assert_param(IS_LTDC_CFBLNBR(pLayerCfg
->ImageHeight
));
782 /* Change LTDC peripheral state */
783 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
785 /* Copy new layer configuration into handle structure */
786 hltdc
->LayerCfg
[LayerIdx
] = *pLayerCfg
;
788 /* Configure the LTDC Layer */
789 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
791 /* Set the Immediate Reload type */
792 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
794 /* Initialize the LTDC state*/
795 hltdc
->State
= HAL_LTDC_STATE_READY
;
797 /* Process unlocked */
804 * @brief Configure the color keying.
805 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
806 * the configuration information for the LTDC.
807 * @param RGBValue the color key value
808 * @param LayerIdx LTDC Layer index.
809 * This parameter can be one of the following values:
810 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
813 HAL_StatusTypeDef
HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t RGBValue
, uint32_t LayerIdx
)
815 /* Check the parameters */
816 assert_param(IS_LTDC_LAYER(LayerIdx
));
821 /* Change LTDC peripheral state */
822 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
824 /* Configure the default color values */
825 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
&= ~(LTDC_LxCKCR_CKBLUE
| LTDC_LxCKCR_CKGREEN
| LTDC_LxCKCR_CKRED
);
826 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
= RGBValue
;
828 /* Set the Immediate Reload type */
829 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
831 /* Change the LTDC state*/
832 hltdc
->State
= HAL_LTDC_STATE_READY
;
834 /* Process unlocked */
841 * @brief Load the color lookup table.
842 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
843 * the configuration information for the LTDC.
844 * @param pCLUT pointer to the color lookup table address.
845 * @param CLUTSize the color lookup table size.
846 * @param LayerIdx LTDC Layer index.
847 * This parameter can be one of the following values:
848 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
851 HAL_StatusTypeDef
HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t *pCLUT
, uint32_t CLUTSize
, uint32_t LayerIdx
)
855 uint32_t *pcolorlut
= pCLUT
;
856 /* Check the parameters */
857 assert_param(IS_LTDC_LAYER(LayerIdx
));
862 /* Change LTDC peripheral state */
863 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
865 for (counter
= 0U; (counter
< CLUTSize
); counter
++)
867 if (hltdc
->LayerCfg
[LayerIdx
].PixelFormat
== LTDC_PIXEL_FORMAT_AL44
)
869 tmp
= (((counter
+ (16U*counter
)) << 24U) | ((uint32_t)(*pcolorlut
) & 0xFFU
) | ((uint32_t)(*pcolorlut
) & 0xFF00U
) | ((uint32_t)(*pcolorlut
) & 0xFF0000U
));
873 tmp
= ((counter
<< 24U) | ((uint32_t)(*pcolorlut
) & 0xFFU
) | ((uint32_t)(*pcolorlut
) & 0xFF00U
) | ((uint32_t)(*pcolorlut
) & 0xFF0000U
));
878 /* Specifies the C-LUT address and RGB value */
879 LTDC_LAYER(hltdc
, LayerIdx
)->CLUTWR
= tmp
;
882 /* Change the LTDC state*/
883 hltdc
->State
= HAL_LTDC_STATE_READY
;
885 /* Process unlocked */
892 * @brief Enable the color keying.
893 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
894 * the configuration information for the LTDC.
895 * @param LayerIdx LTDC Layer index.
896 * This parameter can be one of the following values:
897 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
900 HAL_StatusTypeDef
HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
902 /* Check the parameters */
903 assert_param(IS_LTDC_LAYER(LayerIdx
));
908 /* Change LTDC peripheral state */
909 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
911 /* Enable LTDC color keying by setting COLKEN bit */
912 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_COLKEN
;
914 /* Set the Immediate Reload type */
915 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
917 /* Change the LTDC state*/
918 hltdc
->State
= HAL_LTDC_STATE_READY
;
920 /* Process unlocked */
927 * @brief Disable the color keying.
928 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
929 * the configuration information for the LTDC.
930 * @param LayerIdx LTDC Layer index.
931 * This parameter can be one of the following values:
932 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
935 HAL_StatusTypeDef
HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
937 /* Check the parameters */
938 assert_param(IS_LTDC_LAYER(LayerIdx
));
943 /* Change LTDC peripheral state */
944 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
946 /* Disable LTDC color keying by setting COLKEN bit */
947 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_COLKEN
;
949 /* Set the Immediate Reload type */
950 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
952 /* Change the LTDC state*/
953 hltdc
->State
= HAL_LTDC_STATE_READY
;
955 /* Process unlocked */
962 * @brief Enable the color lookup table.
963 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
964 * the configuration information for the LTDC.
965 * @param LayerIdx LTDC Layer index.
966 * This parameter can be one of the following values:
967 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
970 HAL_StatusTypeDef
HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
972 /* Check the parameters */
973 assert_param(IS_LTDC_LAYER(LayerIdx
));
978 /* Change LTDC peripheral state */
979 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
981 /* Enable LTDC color lookup table by setting CLUTEN bit */
982 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_CLUTEN
;
984 /* Set the Immediate Reload type */
985 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
987 /* Change the LTDC state*/
988 hltdc
->State
= HAL_LTDC_STATE_READY
;
990 /* Process unlocked */
997 * @brief Disable the color lookup table.
998 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
999 * the configuration information for the LTDC.
1000 * @param LayerIdx LTDC Layer index.
1001 * This parameter can be one of the following values:
1002 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1003 * @retval HAL status
1005 HAL_StatusTypeDef
HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1007 /* Check the parameters */
1008 assert_param(IS_LTDC_LAYER(LayerIdx
));
1010 /* Process locked */
1013 /* Change LTDC peripheral state */
1014 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1016 /* Disable LTDC color lookup table by setting CLUTEN bit */
1017 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_CLUTEN
;
1019 /* Set the Immediate Reload type */
1020 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1022 /* Change the LTDC state*/
1023 hltdc
->State
= HAL_LTDC_STATE_READY
;
1025 /* Process unlocked */
1026 __HAL_UNLOCK(hltdc
);
1032 * @brief Enable Dither.
1033 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1034 * the configuration information for the LTDC.
1035 * @retval HAL status
1038 HAL_StatusTypeDef
HAL_LTDC_EnableDither(LTDC_HandleTypeDef
*hltdc
)
1040 /* Process locked */
1043 /* Change LTDC peripheral state */
1044 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1046 /* Enable Dither by setting DTEN bit */
1047 LTDC
->GCR
|= (uint32_t)LTDC_GCR_DEN
;
1049 /* Change the LTDC state*/
1050 hltdc
->State
= HAL_LTDC_STATE_READY
;
1052 /* Process unlocked */
1053 __HAL_UNLOCK(hltdc
);
1059 * @brief Disable Dither.
1060 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1061 * the configuration information for the LTDC.
1062 * @retval HAL status
1065 HAL_StatusTypeDef
HAL_LTDC_DisableDither(LTDC_HandleTypeDef
*hltdc
)
1067 /* Process locked */
1070 /* Change LTDC peripheral state */
1071 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1073 /* Disable Dither by setting DTEN bit */
1074 LTDC
->GCR
&= ~(uint32_t)LTDC_GCR_DEN
;
1076 /* Change the LTDC state*/
1077 hltdc
->State
= HAL_LTDC_STATE_READY
;
1079 /* Process unlocked */
1080 __HAL_UNLOCK(hltdc
);
1086 * @brief Set the LTDC window size.
1087 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1088 * the configuration information for the LTDC.
1089 * @param XSize LTDC Pixel per line
1090 * @param YSize LTDC Line number
1091 * @param LayerIdx LTDC Layer index.
1092 * This parameter can be one of the following values:
1093 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1094 * @retval HAL status
1096 HAL_StatusTypeDef
HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef
*hltdc
, uint32_t XSize
, uint32_t YSize
, uint32_t LayerIdx
)
1098 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1100 /* Check the parameters (Layers parameters)*/
1101 assert_param(IS_LTDC_LAYER(LayerIdx
));
1102 assert_param(IS_LTDC_CFBLL(XSize
));
1103 assert_param(IS_LTDC_CFBLNBR(YSize
));
1105 /* Process locked */
1108 /* Change LTDC peripheral state */
1109 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1111 /* Get layer configuration from handle structure */
1112 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1114 /* update horizontal stop */
1115 pLayerCfg
->WindowX1
= XSize
+ pLayerCfg
->WindowX0
;
1117 /* update vertical stop */
1118 pLayerCfg
->WindowY1
= YSize
+ pLayerCfg
->WindowY0
;
1120 /* Reconfigures the color frame buffer pitch in byte */
1121 pLayerCfg
->ImageWidth
= XSize
;
1123 /* Reconfigures the frame buffer line number */
1124 pLayerCfg
->ImageHeight
= YSize
;
1126 /* Set LTDC parameters */
1127 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1129 /* Set the Immediate Reload type */
1130 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1132 /* Change the LTDC state*/
1133 hltdc
->State
= HAL_LTDC_STATE_READY
;
1135 /* Process unlocked */
1136 __HAL_UNLOCK(hltdc
);
1142 * @brief Set the LTDC window position.
1143 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1144 * the configuration information for the LTDC.
1145 * @param X0 LTDC window X offset
1146 * @param Y0 LTDC window Y offset
1147 * @param LayerIdx LTDC Layer index.
1148 * This parameter can be one of the following values:
1149 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1150 * @retval HAL status
1152 HAL_StatusTypeDef
HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef
*hltdc
, uint32_t X0
, uint32_t Y0
, uint32_t LayerIdx
)
1154 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1156 /* Check the parameters */
1157 assert_param(IS_LTDC_LAYER(LayerIdx
));
1158 assert_param(IS_LTDC_CFBLL(X0
));
1159 assert_param(IS_LTDC_CFBLNBR(Y0
));
1161 /* Process locked */
1164 /* Change LTDC peripheral state */
1165 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1167 /* Get layer configuration from handle structure */
1168 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1170 /* update horizontal start/stop */
1171 pLayerCfg
->WindowX0
= X0
;
1172 pLayerCfg
->WindowX1
= X0
+ pLayerCfg
->ImageWidth
;
1174 /* update vertical start/stop */
1175 pLayerCfg
->WindowY0
= Y0
;
1176 pLayerCfg
->WindowY1
= Y0
+ pLayerCfg
->ImageHeight
;
1178 /* Set LTDC parameters */
1179 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1181 /* Set the Immediate Reload type */
1182 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1184 /* Change the LTDC state*/
1185 hltdc
->State
= HAL_LTDC_STATE_READY
;
1187 /* Process unlocked */
1188 __HAL_UNLOCK(hltdc
);
1194 * @brief Reconfigure the pixel format.
1195 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1196 * the configuration information for the LTDC.
1197 * @param Pixelformat new pixel format value.
1198 * @param LayerIdx LTDC Layer index.
1199 * This parameter can be one of the following values:
1200 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1201 * @retval HAL status
1203 HAL_StatusTypeDef
HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef
*hltdc
, uint32_t Pixelformat
, uint32_t LayerIdx
)
1205 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1207 /* Check the parameters */
1208 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat
));
1209 assert_param(IS_LTDC_LAYER(LayerIdx
));
1211 /* Process locked */
1214 /* Change LTDC peripheral state */
1215 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1217 /* Get layer configuration from handle structure */
1218 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1220 /* Reconfigure the pixel format */
1221 pLayerCfg
->PixelFormat
= Pixelformat
;
1223 /* Set LTDC parameters */
1224 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1226 /* Set the Immediate Reload type */
1227 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1229 /* Change the LTDC state*/
1230 hltdc
->State
= HAL_LTDC_STATE_READY
;
1232 /* Process unlocked */
1233 __HAL_UNLOCK(hltdc
);
1239 * @brief Reconfigure the layer alpha value.
1240 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1241 * the configuration information for the LTDC.
1242 * @param Alpha new alpha value.
1243 * @param LayerIdx LTDC Layer index.
1244 * This parameter can be one of the following values:
1245 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1246 * @retval HAL status
1248 HAL_StatusTypeDef
HAL_LTDC_SetAlpha(LTDC_HandleTypeDef
*hltdc
, uint32_t Alpha
, uint32_t LayerIdx
)
1250 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1252 /* Check the parameters */
1253 assert_param(IS_LTDC_ALPHA(Alpha
));
1254 assert_param(IS_LTDC_LAYER(LayerIdx
));
1256 /* Process locked */
1259 /* Change LTDC peripheral state */
1260 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1262 /* Get layer configuration from handle structure */
1263 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1265 /* Reconfigure the Alpha value */
1266 pLayerCfg
->Alpha
= Alpha
;
1268 /* Set LTDC parameters */
1269 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1271 /* Set the Immediate Reload type */
1272 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1274 /* Change the LTDC state*/
1275 hltdc
->State
= HAL_LTDC_STATE_READY
;
1277 /* Process unlocked */
1278 __HAL_UNLOCK(hltdc
);
1283 * @brief Reconfigure the frame buffer Address.
1284 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1285 * the configuration information for the LTDC.
1286 * @param Address new address value.
1287 * @param LayerIdx LTDC Layer index.
1288 * This parameter can be one of the following values:
1289 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1290 * @retval HAL status
1292 HAL_StatusTypeDef
HAL_LTDC_SetAddress(LTDC_HandleTypeDef
*hltdc
, uint32_t Address
, uint32_t LayerIdx
)
1294 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1296 /* Check the parameters */
1297 assert_param(IS_LTDC_LAYER(LayerIdx
));
1299 /* Process locked */
1302 /* Change LTDC peripheral state */
1303 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1305 /* Get layer configuration from handle structure */
1306 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1308 /* Reconfigure the Address */
1309 pLayerCfg
->FBStartAdress
= Address
;
1311 /* Set LTDC parameters */
1312 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1314 /* Set the Immediate Reload type */
1315 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1317 /* Change the LTDC state*/
1318 hltdc
->State
= HAL_LTDC_STATE_READY
;
1320 /* Process unlocked */
1321 __HAL_UNLOCK(hltdc
);
1327 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
1328 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
1329 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
1330 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
1331 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
1332 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1333 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1334 * the configuration information for the LTDC.
1335 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1336 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1337 * @retval HAL status
1339 HAL_StatusTypeDef
HAL_LTDC_SetPitch(LTDC_HandleTypeDef
*hltdc
, uint32_t LinePitchInPixels
, uint32_t LayerIdx
)
1342 uint32_t pitchUpdate
;
1343 uint32_t pixelFormat
;
1345 /* Check the parameters */
1346 assert_param(IS_LTDC_LAYER(LayerIdx
));
1348 /* Process locked */
1351 /* Change LTDC peripheral state */
1352 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1354 /* get LayerIdx used pixel format */
1355 pixelFormat
= hltdc
->LayerCfg
[LayerIdx
].PixelFormat
;
1357 if (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
1361 else if (pixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
1365 else if ((pixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
1366 (pixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
1367 (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
1368 (pixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
1377 pitchUpdate
= ((LinePitchInPixels
* tmp
) << 16U);
1379 /* Clear previously set standard pitch */
1380 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~LTDC_LxCFBLR_CFBP
;
1382 /* Set the Reload type as immediate update of LTDC pitch configured above */
1383 LTDC
->SRCR
|= LTDC_SRCR_IMR
;
1385 /* Set new line pitch value */
1386 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
|= pitchUpdate
;
1388 /* Set the Reload type as immediate update of LTDC pitch configured above */
1389 LTDC
->SRCR
|= LTDC_SRCR_IMR
;
1391 /* Change the LTDC state*/
1392 hltdc
->State
= HAL_LTDC_STATE_READY
;
1394 /* Process unlocked */
1395 __HAL_UNLOCK(hltdc
);
1401 * @brief Define the position of the line interrupt.
1402 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1403 * the configuration information for the LTDC.
1404 * @param Line Line Interrupt Position.
1405 * @note User application may resort to HAL_LTDC_LineEventCallback() at line interrupt generation.
1406 * @retval HAL status
1408 HAL_StatusTypeDef
HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef
*hltdc
, uint32_t Line
)
1410 /* Check the parameters */
1411 assert_param(IS_LTDC_LIPOS(Line
));
1413 /* Process locked */
1416 /* Change LTDC peripheral state */
1417 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1419 /* Disable the Line interrupt */
1420 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_LI
);
1422 /* Set the Line Interrupt position */
1423 LTDC
->LIPCR
= (uint32_t)Line
;
1425 /* Enable the Line interrupt */
1426 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_LI
);
1428 /* Change the LTDC state*/
1429 hltdc
->State
= HAL_LTDC_STATE_READY
;
1431 /* Process unlocked */
1432 __HAL_UNLOCK(hltdc
);
1438 * @brief Reload LTDC Layers configuration.
1439 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1440 * the configuration information for the LTDC.
1441 * @param ReloadType This parameter can be one of the following values :
1442 * LTDC_RELOAD_IMMEDIATE : Immediate Reload
1443 * LTDC_RELOAD_VERTICAL_BLANKING : Reload in the next Vertical Blanking
1444 * @note User application may resort to HAL_LTDC_ReloadEventCallback() at reload interrupt generation.
1445 * @retval HAL status
1447 HAL_StatusTypeDef
HAL_LTDC_Reload(LTDC_HandleTypeDef
*hltdc
, uint32_t ReloadType
)
1449 /* Check the parameters */
1450 assert_param(IS_LTDC_RELOAD(ReloadType
));
1452 /* Process locked */
1455 /* Change LTDC peripheral state */
1456 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1458 /* Enable the Reload interrupt */
1459 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_RR
);
1461 /* Apply Reload type */
1462 hltdc
->Instance
->SRCR
= ReloadType
;
1464 /* Change the LTDC state*/
1465 hltdc
->State
= HAL_LTDC_STATE_READY
;
1467 /* Process unlocked */
1468 __HAL_UNLOCK(hltdc
);
1474 * @brief Configure the LTDC Layer according to the specified without reloading
1475 * parameters in the LTDC_InitTypeDef and create the associated handle.
1476 * Variant of the function HAL_LTDC_ConfigLayer without immediate reload.
1477 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1478 * the configuration information for the LTDC.
1479 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
1480 * the configuration information for the Layer.
1481 * @param LayerIdx LTDC Layer index.
1482 * This parameter can be one of the following values:
1483 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1484 * @retval HAL status
1486 HAL_StatusTypeDef
HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
1488 /* Check the parameters */
1489 assert_param(IS_LTDC_LAYER(LayerIdx
));
1490 assert_param(IS_LTDC_HCONFIGST(pLayerCfg
->WindowX0
));
1491 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg
->WindowX1
));
1492 assert_param(IS_LTDC_VCONFIGST(pLayerCfg
->WindowY0
));
1493 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg
->WindowY1
));
1494 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg
->PixelFormat
));
1495 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha
));
1496 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha0
));
1497 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg
->BlendingFactor1
));
1498 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg
->BlendingFactor2
));
1499 assert_param(IS_LTDC_CFBLL(pLayerCfg
->ImageWidth
));
1500 assert_param(IS_LTDC_CFBLNBR(pLayerCfg
->ImageHeight
));
1502 /* Process locked */
1505 /* Change LTDC peripheral state */
1506 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1508 /* Copy new layer configuration into handle structure */
1509 hltdc
->LayerCfg
[LayerIdx
] = *pLayerCfg
;
1511 /* Configure the LTDC Layer */
1512 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1514 /* Initialize the LTDC state*/
1515 hltdc
->State
= HAL_LTDC_STATE_READY
;
1517 /* Process unlocked */
1518 __HAL_UNLOCK(hltdc
);
1524 * @brief Set the LTDC window size without reloading.
1525 * Variant of the function HAL_LTDC_SetWindowSize without immediate reload.
1526 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1527 * the configuration information for the LTDC.
1528 * @param XSize LTDC Pixel per line
1529 * @param YSize LTDC Line number
1530 * @param LayerIdx LTDC Layer index.
1531 * This parameter can be one of the following values:
1532 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1533 * @retval HAL status
1535 HAL_StatusTypeDef
HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t XSize
, uint32_t YSize
, uint32_t LayerIdx
)
1537 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1539 /* Check the parameters (Layers parameters)*/
1540 assert_param(IS_LTDC_LAYER(LayerIdx
));
1541 assert_param(IS_LTDC_CFBLL(XSize
));
1542 assert_param(IS_LTDC_CFBLNBR(YSize
));
1544 /* Process locked */
1547 /* Change LTDC peripheral state */
1548 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1550 /* Get layer configuration from handle structure */
1551 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1553 /* update horizontal stop */
1554 pLayerCfg
->WindowX1
= XSize
+ pLayerCfg
->WindowX0
;
1556 /* update vertical stop */
1557 pLayerCfg
->WindowY1
= YSize
+ pLayerCfg
->WindowY0
;
1559 /* Reconfigures the color frame buffer pitch in byte */
1560 pLayerCfg
->ImageWidth
= XSize
;
1562 /* Reconfigures the frame buffer line number */
1563 pLayerCfg
->ImageHeight
= YSize
;
1565 /* Set LTDC parameters */
1566 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1568 /* Change the LTDC state*/
1569 hltdc
->State
= HAL_LTDC_STATE_READY
;
1571 /* Process unlocked */
1572 __HAL_UNLOCK(hltdc
);
1578 * @brief Set the LTDC window position without reloading.
1579 * Variant of the function HAL_LTDC_SetWindowPosition without immediate reload.
1580 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1581 * the configuration information for the LTDC.
1582 * @param X0 LTDC window X offset
1583 * @param Y0 LTDC window Y offset
1584 * @param LayerIdx LTDC Layer index.
1585 * This parameter can be one of the following values:
1586 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1587 * @retval HAL status
1589 HAL_StatusTypeDef
HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t X0
, uint32_t Y0
, uint32_t LayerIdx
)
1591 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1593 /* Check the parameters */
1594 assert_param(IS_LTDC_LAYER(LayerIdx
));
1595 assert_param(IS_LTDC_CFBLL(X0
));
1596 assert_param(IS_LTDC_CFBLNBR(Y0
));
1598 /* Process locked */
1601 /* Change LTDC peripheral state */
1602 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1604 /* Get layer configuration from handle structure */
1605 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1607 /* update horizontal start/stop */
1608 pLayerCfg
->WindowX0
= X0
;
1609 pLayerCfg
->WindowX1
= X0
+ pLayerCfg
->ImageWidth
;
1611 /* update vertical start/stop */
1612 pLayerCfg
->WindowY0
= Y0
;
1613 pLayerCfg
->WindowY1
= Y0
+ pLayerCfg
->ImageHeight
;
1615 /* Set LTDC parameters */
1616 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1618 /* Change the LTDC state*/
1619 hltdc
->State
= HAL_LTDC_STATE_READY
;
1621 /* Process unlocked */
1622 __HAL_UNLOCK(hltdc
);
1628 * @brief Reconfigure the pixel format without reloading.
1629 * Variant of the function HAL_LTDC_SetPixelFormat without immediate reload.
1630 * @param hltdc pointer to a LTDC_HandleTypeDfef structure that contains
1631 * the configuration information for the LTDC.
1632 * @param Pixelformat new pixel format value.
1633 * @param LayerIdx LTDC Layer index.
1634 * This parameter can be one of the following values:
1635 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1636 * @retval HAL status
1638 HAL_StatusTypeDef
HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Pixelformat
, uint32_t LayerIdx
)
1640 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1642 /* Check the parameters */
1643 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat
));
1644 assert_param(IS_LTDC_LAYER(LayerIdx
));
1646 /* Process locked */
1649 /* Change LTDC peripheral state */
1650 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1652 /* Get layer configuration from handle structure */
1653 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1655 /* Reconfigure the pixel format */
1656 pLayerCfg
->PixelFormat
= Pixelformat
;
1658 /* Set LTDC parameters */
1659 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1661 /* Change the LTDC state*/
1662 hltdc
->State
= HAL_LTDC_STATE_READY
;
1664 /* Process unlocked */
1665 __HAL_UNLOCK(hltdc
);
1671 * @brief Reconfigure the layer alpha value without reloading.
1672 * Variant of the function HAL_LTDC_SetAlpha without immediate reload.
1673 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1674 * the configuration information for the LTDC.
1675 * @param Alpha new alpha value.
1676 * @param LayerIdx LTDC Layer index.
1677 * This parameter can be one of the following values:
1678 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1679 * @retval HAL status
1681 HAL_StatusTypeDef
HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Alpha
, uint32_t LayerIdx
)
1683 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1685 /* Check the parameters */
1686 assert_param(IS_LTDC_ALPHA(Alpha
));
1687 assert_param(IS_LTDC_LAYER(LayerIdx
));
1689 /* Process locked */
1692 /* Change LTDC peripheral state */
1693 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1695 /* Get layer configuration from handle structure */
1696 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1698 /* Reconfigure the Alpha value */
1699 pLayerCfg
->Alpha
= Alpha
;
1701 /* Set LTDC parameters */
1702 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1704 /* Change the LTDC state*/
1705 hltdc
->State
= HAL_LTDC_STATE_READY
;
1707 /* Process unlocked */
1708 __HAL_UNLOCK(hltdc
);
1714 * @brief Reconfigure the frame buffer Address without reloading.
1715 * Variant of the function HAL_LTDC_SetAddress without immediate reload.
1716 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1717 * the configuration information for the LTDC.
1718 * @param Address new address value.
1719 * @param LayerIdx LTDC Layer index.
1720 * This parameter can be one of the following values:
1721 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1722 * @retval HAL status
1724 HAL_StatusTypeDef
HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Address
, uint32_t LayerIdx
)
1726 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1728 /* Check the parameters */
1729 assert_param(IS_LTDC_LAYER(LayerIdx
));
1731 /* Process locked */
1734 /* Change LTDC peripheral state */
1735 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1737 /* Get layer configuration from handle structure */
1738 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1740 /* Reconfigure the Address */
1741 pLayerCfg
->FBStartAdress
= Address
;
1743 /* Set LTDC parameters */
1744 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1746 /* Change the LTDC state*/
1747 hltdc
->State
= HAL_LTDC_STATE_READY
;
1749 /* Process unlocked */
1750 __HAL_UNLOCK(hltdc
);
1756 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
1757 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
1758 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
1759 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
1760 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
1761 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1762 * Variant of the function HAL_LTDC_SetPitch without immediate reload.
1763 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1764 * the configuration information for the LTDC.
1765 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1766 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1767 * @retval HAL status
1769 HAL_StatusTypeDef
HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LinePitchInPixels
, uint32_t LayerIdx
)
1772 uint32_t pitchUpdate
;
1773 uint32_t pixelFormat
;
1775 /* Check the parameters */
1776 assert_param(IS_LTDC_LAYER(LayerIdx
));
1778 /* Process locked */
1781 /* Change LTDC peripheral state */
1782 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1784 /* get LayerIdx used pixel format */
1785 pixelFormat
= hltdc
->LayerCfg
[LayerIdx
].PixelFormat
;
1787 if (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
1791 else if (pixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
1795 else if ((pixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
1796 (pixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
1797 (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
1798 (pixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
1807 pitchUpdate
= ((LinePitchInPixels
* tmp
) << 16U);
1809 /* Clear previously set standard pitch */
1810 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~LTDC_LxCFBLR_CFBP
;
1812 /* Set new line pitch value */
1813 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
|= pitchUpdate
;
1815 /* Change the LTDC state*/
1816 hltdc
->State
= HAL_LTDC_STATE_READY
;
1818 /* Process unlocked */
1819 __HAL_UNLOCK(hltdc
);
1826 * @brief Configure the color keying without reloading.
1827 * Variant of the function HAL_LTDC_ConfigColorKeying without immediate reload.
1828 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1829 * the configuration information for the LTDC.
1830 * @param RGBValue the color key value
1831 * @param LayerIdx LTDC Layer index.
1832 * This parameter can be one of the following values:
1833 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1834 * @retval HAL status
1836 HAL_StatusTypeDef
HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t RGBValue
, uint32_t LayerIdx
)
1838 /* Check the parameters */
1839 assert_param(IS_LTDC_LAYER(LayerIdx
));
1841 /* Process locked */
1844 /* Change LTDC peripheral state */
1845 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1847 /* Configure the default color values */
1848 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
&= ~(LTDC_LxCKCR_CKBLUE
| LTDC_LxCKCR_CKGREEN
| LTDC_LxCKCR_CKRED
);
1849 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
= RGBValue
;
1851 /* Change the LTDC state*/
1852 hltdc
->State
= HAL_LTDC_STATE_READY
;
1854 /* Process unlocked */
1855 __HAL_UNLOCK(hltdc
);
1861 * @brief Enable the color keying without reloading.
1862 * Variant of the function HAL_LTDC_EnableColorKeying without immediate reload.
1863 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1864 * the configuration information for the LTDC.
1865 * @param LayerIdx LTDC Layer index.
1866 * This parameter can be one of the following values:
1867 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1868 * @retval HAL status
1870 HAL_StatusTypeDef
HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1872 /* Check the parameters */
1873 assert_param(IS_LTDC_LAYER(LayerIdx
));
1875 /* Process locked */
1878 /* Change LTDC peripheral state */
1879 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1881 /* Enable LTDC color keying by setting COLKEN bit */
1882 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_COLKEN
;
1884 /* Change the LTDC state*/
1885 hltdc
->State
= HAL_LTDC_STATE_READY
;
1887 /* Process unlocked */
1888 __HAL_UNLOCK(hltdc
);
1894 * @brief Disable the color keying without reloading.
1895 * Variant of the function HAL_LTDC_DisableColorKeying without immediate reload.
1896 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1897 * the configuration information for the LTDC.
1898 * @param LayerIdx LTDC Layer index.
1899 * This parameter can be one of the following values:
1900 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1901 * @retval HAL status
1903 HAL_StatusTypeDef
HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1905 /* Check the parameters */
1906 assert_param(IS_LTDC_LAYER(LayerIdx
));
1908 /* Process locked */
1911 /* Change LTDC peripheral state */
1912 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1914 /* Disable LTDC color keying by setting COLKEN bit */
1915 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_COLKEN
;
1917 /* Change the LTDC state*/
1918 hltdc
->State
= HAL_LTDC_STATE_READY
;
1920 /* Process unlocked */
1921 __HAL_UNLOCK(hltdc
);
1927 * @brief Enable the color lookup table without reloading.
1928 * Variant of the function HAL_LTDC_EnableCLUT without immediate reload.
1929 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1930 * the configuration information for the LTDC.
1931 * @param LayerIdx LTDC Layer index.
1932 * This parameter can be one of the following values:
1933 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1934 * @retval HAL status
1936 HAL_StatusTypeDef
HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1938 /* Check the parameters */
1939 assert_param(IS_LTDC_LAYER(LayerIdx
));
1941 /* Process locked */
1944 /* Change LTDC peripheral state */
1945 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1947 /* Disable LTDC color lookup table by setting CLUTEN bit */
1948 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_CLUTEN
;
1950 /* Change the LTDC state*/
1951 hltdc
->State
= HAL_LTDC_STATE_READY
;
1953 /* Process unlocked */
1954 __HAL_UNLOCK(hltdc
);
1960 * @brief Disable the color lookup table without reloading.
1961 * Variant of the function HAL_LTDC_DisableCLUT without immediate reload.
1962 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1963 * the configuration information for the LTDC.
1964 * @param LayerIdx LTDC Layer index.
1965 * This parameter can be one of the following values:
1966 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1967 * @retval HAL status
1969 HAL_StatusTypeDef
HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1971 /* Check the parameters */
1972 assert_param(IS_LTDC_LAYER(LayerIdx
));
1974 /* Process locked */
1977 /* Change LTDC peripheral state */
1978 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1980 /* Disable LTDC color lookup table by setting CLUTEN bit */
1981 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_CLUTEN
;
1983 /* Change the LTDC state*/
1984 hltdc
->State
= HAL_LTDC_STATE_READY
;
1986 /* Process unlocked */
1987 __HAL_UNLOCK(hltdc
);
1996 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
1997 * @brief Peripheral State and Errors functions
2000 ===============================================================================
2001 ##### Peripheral State and Errors functions #####
2002 ===============================================================================
2004 This subsection provides functions allowing to
2005 (+) Check the LTDC handle state.
2006 (+) Get the LTDC handle error code.
2013 * @brief Return the LTDC handle state.
2014 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2015 * the configuration information for the LTDC.
2018 HAL_LTDC_StateTypeDef
HAL_LTDC_GetState(LTDC_HandleTypeDef
*hltdc
)
2020 return hltdc
->State
;
2024 * @brief Return the LTDC handle error code.
2025 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2026 * the configuration information for the LTDC.
2027 * @retval LTDC Error Code
2029 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef
*hltdc
)
2031 return hltdc
->ErrorCode
;
2042 /** @defgroup LTDC_Private_Functions LTDC Private Functions
2047 * @brief Configure the LTDC peripheral
2048 * @param hltdc Pointer to a LTDC_HandleTypeDef structure that contains
2049 * the configuration information for the LTDC.
2050 * @param pLayerCfg Pointer LTDC Layer Configuration structure
2051 * @param LayerIdx LTDC Layer index.
2052 * This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
2055 static void LTDC_SetConfig(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
2061 /* Configure the horizontal start and stop position */
2062 tmp
= ((pLayerCfg
->WindowX1
+ ((hltdc
->Instance
->BPCR
& LTDC_BPCR_AHBP
) >> 16U)) << 16U);
2063 LTDC_LAYER(hltdc
, LayerIdx
)->WHPCR
&= ~(LTDC_LxWHPCR_WHSTPOS
| LTDC_LxWHPCR_WHSPPOS
);
2064 LTDC_LAYER(hltdc
, LayerIdx
)->WHPCR
= ((pLayerCfg
->WindowX0
+ ((hltdc
->Instance
->BPCR
& LTDC_BPCR_AHBP
) >> 16U) + 1U) | tmp
);
2066 /* Configure the vertical start and stop position */
2067 tmp
= ((pLayerCfg
->WindowY1
+ (hltdc
->Instance
->BPCR
& LTDC_BPCR_AVBP
)) << 16U);
2068 LTDC_LAYER(hltdc
, LayerIdx
)->WVPCR
&= ~(LTDC_LxWVPCR_WVSTPOS
| LTDC_LxWVPCR_WVSPPOS
);
2069 LTDC_LAYER(hltdc
, LayerIdx
)->WVPCR
= ((pLayerCfg
->WindowY0
+ (hltdc
->Instance
->BPCR
& LTDC_BPCR_AVBP
) + 1U) | tmp
);
2071 /* Specifies the pixel format */
2072 LTDC_LAYER(hltdc
, LayerIdx
)->PFCR
&= ~(LTDC_LxPFCR_PF
);
2073 LTDC_LAYER(hltdc
, LayerIdx
)->PFCR
= (pLayerCfg
->PixelFormat
);
2075 /* Configure the default color values */
2076 tmp
= ((uint32_t)(pLayerCfg
->Backcolor
.Green
) << 8U);
2077 tmp1
= ((uint32_t)(pLayerCfg
->Backcolor
.Red
) << 16U);
2078 tmp2
= (pLayerCfg
->Alpha0
<< 24U);
2079 LTDC_LAYER(hltdc
, LayerIdx
)->DCCR
&= ~(LTDC_LxDCCR_DCBLUE
| LTDC_LxDCCR_DCGREEN
| LTDC_LxDCCR_DCRED
| LTDC_LxDCCR_DCALPHA
);
2080 LTDC_LAYER(hltdc
, LayerIdx
)->DCCR
= (pLayerCfg
->Backcolor
.Blue
| tmp
| tmp1
| tmp2
);
2082 /* Specifies the constant alpha value */
2083 LTDC_LAYER(hltdc
, LayerIdx
)->CACR
&= ~(LTDC_LxCACR_CONSTA
);
2084 LTDC_LAYER(hltdc
, LayerIdx
)->CACR
= (pLayerCfg
->Alpha
);
2086 /* Specifies the blending factors */
2087 LTDC_LAYER(hltdc
, LayerIdx
)->BFCR
&= ~(LTDC_LxBFCR_BF2
| LTDC_LxBFCR_BF1
);
2088 LTDC_LAYER(hltdc
, LayerIdx
)->BFCR
= (pLayerCfg
->BlendingFactor1
| pLayerCfg
->BlendingFactor2
);
2090 /* Configure the color frame buffer start address */
2091 LTDC_LAYER(hltdc
, LayerIdx
)->CFBAR
&= ~(LTDC_LxCFBAR_CFBADD
);
2092 LTDC_LAYER(hltdc
, LayerIdx
)->CFBAR
= (pLayerCfg
->FBStartAdress
);
2094 if (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
2098 else if (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
2102 else if ((pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
2103 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
2104 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
2105 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
2114 /* Configure the color frame buffer pitch in byte */
2115 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~(LTDC_LxCFBLR_CFBLL
| LTDC_LxCFBLR_CFBP
);
2116 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
= (((pLayerCfg
->ImageWidth
* tmp
) << 16U) | (((pLayerCfg
->WindowX1
- pLayerCfg
->WindowX0
) * tmp
) + 3U));
2117 /* Configure the frame buffer line number */
2118 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLNR
&= ~(LTDC_LxCFBLNR_CFBLNBR
);
2119 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLNR
= (pLayerCfg
->ImageHeight
);
2121 /* Enable LTDC_Layer by setting LEN bit */
2122 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_LEN
;
2140 #endif /* HAL_LTDC_MODULE_ENABLED */
2142 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/