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
14 ==============================================================================
15 ##### How to use this driver #####
16 ==============================================================================
18 The LTDC HAL driver can be used as follows:
20 (#) Declare a LTDC_HandleTypeDef handle structure, for example: LTDC_HandleTypeDef hltdc;
22 (#) Initialize the LTDC low level resources by implementing the HAL_LTDC_MspInit() API:
23 (##) Enable the LTDC interface clock
24 (##) NVIC configuration if you need to use interrupt process
25 (+++) Configure the LTDC interrupt priority
26 (+++) Enable the NVIC LTDC IRQ Channel
28 (#) Initialize the required configuration through the following parameters:
29 the LTDC timing, the horizontal and vertical polarity, the pixel clock polarity,
30 Data Enable polarity and the LTDC background color value using HAL_LTDC_Init() function
33 =========================
35 (#) Program the required configuration through the following parameters:
36 the pixel format, the blending factors, input alpha value, the window size
37 and the image size using HAL_LTDC_ConfigLayer() function for foreground
38 or/and background layer.
40 (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
41 HAL_LTDC_EnableCLUT functions.
43 (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
45 (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
46 and HAL_LTDC_EnableColorKeying functions.
48 (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineEvent()
51 (#) If needed, reconfigure and change the pixel format value, the alpha value
52 value, the window size, the window position and the layer start address
53 for foreground or/and background layer using respectively the following
54 functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
55 HAL_LTDC_SetWindowPosition() and HAL_LTDC_SetAddress().
57 (#) Variant functions with _NoReload suffix allows to set the LTDC configuration/settings without immediate reload.
58 This is useful in case when the program requires to modify serval LTDC settings (on one or both layers)
59 then applying(reload) these settings in one shot by calling the function HAL_LTDC_Reload().
61 After calling the _NoReload functions to set different color/format/layer settings,
62 the program shall call the function HAL_LTDC_Reload() to apply(reload) these settings.
63 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_IMMEDIATE if
64 an immediate reload is required.
65 Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_VERTICAL_BLANKING if
66 the reload should be done in the next vertical blanking period,
67 this option allows to avoid display flicker by applying the new settings during the vertical blanking period.
70 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
72 *** LTDC HAL driver macros list ***
73 =============================================
75 Below the list of most used macros in LTDC HAL driver.
77 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
78 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
79 (+) __HAL_LTDC_LAYER_ENABLE: Enable an LTDC Layer.
80 (+) __HAL_LTDC_LAYER_DISABLE: Disable an LTDC Layer.
81 (+) __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG: Reload Layer Configuration.
82 (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
83 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
84 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
85 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
86 (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
89 (@) You can refer to the LTDC HAL driver header file for more useful macros
92 *** Callback registration ***
93 =============================================
95 The compilation define USE_HAL_LTDC_REGISTER_CALLBACKS when set to 1
96 allows the user to configure dynamically the driver callbacks.
97 Use function HAL_LTDC_RegisterCallback() to register a callback.
100 Function HAL_LTDC_RegisterCallback() allows to register following callbacks:
101 (+) LineEventCallback : LTDC Line Event Callback.
102 (+) ReloadEventCallback : LTDC Reload Event Callback.
103 (+) ErrorCallback : LTDC Error Callback
104 (+) MspInitCallback : LTDC MspInit.
105 (+) MspDeInitCallback : LTDC MspDeInit.
107 This function takes as parameters the HAL peripheral handle, the callback ID
108 and a pointer to the user callback function.
111 Use function HAL_LTDC_UnRegisterCallback() to reset a callback to the default
113 HAL_LTDC_UnRegisterCallback() takes as parameters the HAL peripheral handle
116 This function allows to reset following callbacks:
117 (+) LineEventCallback : LTDC Line Event Callback
118 (+) ReloadEventCallback : LTDC Reload Event Callback
119 (+) ErrorCallback : LTDC Error Callback
120 (+) MspInitCallback : LTDC MspInit
121 (+) MspDeInitCallback : LTDC MspDeInit.
124 By default, after the HAL_LTDC_Init and when the state is HAL_LTDC_STATE_RESET
125 all callbacks are set to the corresponding weak functions:
126 examples HAL_LTDC_LineEventCallback(), HAL_LTDC_ErrorCallback().
127 Exception done for MspInit and MspDeInit functions that are
128 reset to the legacy weak (surcharged) functions in the HAL_LTDC_Init() and HAL_LTDC_DeInit()
129 only when these callbacks are null (not registered beforehand).
130 If not, MspInit or MspDeInit are not null, the HAL_LTDC_Init() and HAL_LTDC_DeInit()
131 keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
134 Callbacks can be registered/unregistered in HAL_LTDC_STATE_READY state only.
135 Exception done MspInit/MspDeInit that can be registered/unregistered
136 in HAL_LTDC_STATE_READY or HAL_LTDC_STATE_RESET state,
137 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
138 In that case first register the MspInit/MspDeInit user callbacks
139 using HAL_LTDC_RegisterCallback() before calling HAL_LTDC_DeInit()
140 or HAL_LTDC_Init() function.
143 When the compilation define USE_HAL_LTDC_REGISTER_CALLBACKS is set to 0 or
144 not defined, the callback registration feature is not available and all callbacks
145 are set to the corresponding weak functions.
148 ******************************************************************************
151 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
152 * All rights reserved.</center></h2>
154 * This software component is licensed by ST under BSD 3-Clause license,
155 * the "License"; You may not use this file except in compliance with the
156 * License. You may obtain a copy of the License at:
157 * opensource.org/licenses/BSD-3-Clause
159 ******************************************************************************
162 /* Includes ------------------------------------------------------------------*/
163 #include "stm32h7xx_hal.h"
165 /** @addtogroup STM32H7xx_HAL_Driver
169 #ifdef HAL_LTDC_MODULE_ENABLED
173 /** @defgroup LTDC LTDC
174 * @brief LTDC HAL module driver
179 /* Private typedef -----------------------------------------------------------*/
180 /* Private define ------------------------------------------------------------*/
181 /* Private macro -------------------------------------------------------------*/
182 /* Private variables ---------------------------------------------------------*/
183 /* Private function prototypes -----------------------------------------------*/
184 static void LTDC_SetConfig(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
);
185 /* Private functions ---------------------------------------------------------*/
187 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
191 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
192 * @brief Initialization and Configuration functions
195 ===============================================================================
196 ##### Initialization and Configuration functions #####
197 ===============================================================================
198 [..] This section provides functions allowing to:
199 (+) Initialize and configure the LTDC
200 (+) De-initialize the LTDC
207 * @brief Initialize the LTDC according to the specified parameters in the LTDC_InitTypeDef.
208 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
209 * the configuration information for the LTDC.
212 HAL_StatusTypeDef
HAL_LTDC_Init(LTDC_HandleTypeDef
*hltdc
)
216 /* Check the LTDC peripheral state */
222 /* Check function parameters */
223 assert_param(IS_LTDC_ALL_INSTANCE(hltdc
->Instance
));
224 assert_param(IS_LTDC_HSYNC(hltdc
->Init
.HorizontalSync
));
225 assert_param(IS_LTDC_VSYNC(hltdc
->Init
.VerticalSync
));
226 assert_param(IS_LTDC_AHBP(hltdc
->Init
.AccumulatedHBP
));
227 assert_param(IS_LTDC_AVBP(hltdc
->Init
.AccumulatedVBP
));
228 assert_param(IS_LTDC_AAH(hltdc
->Init
.AccumulatedActiveH
));
229 assert_param(IS_LTDC_AAW(hltdc
->Init
.AccumulatedActiveW
));
230 assert_param(IS_LTDC_TOTALH(hltdc
->Init
.TotalHeigh
));
231 assert_param(IS_LTDC_TOTALW(hltdc
->Init
.TotalWidth
));
232 assert_param(IS_LTDC_HSPOL(hltdc
->Init
.HSPolarity
));
233 assert_param(IS_LTDC_VSPOL(hltdc
->Init
.VSPolarity
));
234 assert_param(IS_LTDC_DEPOL(hltdc
->Init
.DEPolarity
));
235 assert_param(IS_LTDC_PCPOL(hltdc
->Init
.PCPolarity
));
237 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
238 if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
240 /* Allocate lock resource and initialize it */
241 hltdc
->Lock
= HAL_UNLOCKED
;
243 /* Reset the LTDC callback to the legacy weak callbacks */
244 hltdc
->LineEventCallback
= HAL_LTDC_LineEventCallback
; /* Legacy weak LineEventCallback */
245 hltdc
->ReloadEventCallback
= HAL_LTDC_ReloadEventCallback
; /* Legacy weak ReloadEventCallback */
246 hltdc
->ErrorCallback
= HAL_LTDC_ErrorCallback
; /* Legacy weak ErrorCallback */
248 if (hltdc
->MspInitCallback
== NULL
)
250 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
;
252 /* Init the low level hardware */
253 hltdc
->MspInitCallback(hltdc
);
256 if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
258 /* Allocate lock resource and initialize it */
259 hltdc
->Lock
= HAL_UNLOCKED
;
260 /* Init the low level hardware */
261 HAL_LTDC_MspInit(hltdc
);
263 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
265 /* Change LTDC peripheral state */
266 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
268 /* Configure the HS, VS, DE and PC polarity */
269 hltdc
->Instance
->GCR
&= ~(LTDC_GCR_HSPOL
| LTDC_GCR_VSPOL
| LTDC_GCR_DEPOL
| LTDC_GCR_PCPOL
);
270 hltdc
->Instance
->GCR
|= (uint32_t)(hltdc
->Init
.HSPolarity
| hltdc
->Init
.VSPolarity
| \
271 hltdc
->Init
.DEPolarity
| hltdc
->Init
.PCPolarity
);
273 /* Set Synchronization size */
274 hltdc
->Instance
->SSCR
&= ~(LTDC_SSCR_VSH
| LTDC_SSCR_HSW
);
275 tmp
= (hltdc
->Init
.HorizontalSync
<< 16U);
276 hltdc
->Instance
->SSCR
|= (tmp
| hltdc
->Init
.VerticalSync
);
278 /* Set Accumulated Back porch */
279 hltdc
->Instance
->BPCR
&= ~(LTDC_BPCR_AVBP
| LTDC_BPCR_AHBP
);
280 tmp
= (hltdc
->Init
.AccumulatedHBP
<< 16U);
281 hltdc
->Instance
->BPCR
|= (tmp
| hltdc
->Init
.AccumulatedVBP
);
283 /* Set Accumulated Active Width */
284 hltdc
->Instance
->AWCR
&= ~(LTDC_AWCR_AAH
| LTDC_AWCR_AAW
);
285 tmp
= (hltdc
->Init
.AccumulatedActiveW
<< 16U);
286 hltdc
->Instance
->AWCR
|= (tmp
| hltdc
->Init
.AccumulatedActiveH
);
288 /* Set Total Width */
289 hltdc
->Instance
->TWCR
&= ~(LTDC_TWCR_TOTALH
| LTDC_TWCR_TOTALW
);
290 tmp
= (hltdc
->Init
.TotalWidth
<< 16U);
291 hltdc
->Instance
->TWCR
|= (tmp
| hltdc
->Init
.TotalHeigh
);
293 /* Set the background color value */
294 tmp
= ((uint32_t)(hltdc
->Init
.Backcolor
.Green
) << 8U);
295 tmp1
= ((uint32_t)(hltdc
->Init
.Backcolor
.Red
) << 16U);
296 hltdc
->Instance
->BCCR
&= ~(LTDC_BCCR_BCBLUE
| LTDC_BCCR_BCGREEN
| LTDC_BCCR_BCRED
);
297 hltdc
->Instance
->BCCR
|= (tmp1
| tmp
| hltdc
->Init
.Backcolor
.Blue
);
299 /* Enable the Transfer Error and FIFO underrun interrupts */
300 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_TE
| LTDC_IT_FU
);
302 /* Enable LTDC by setting LTDCEN bit */
303 __HAL_LTDC_ENABLE(hltdc
);
305 /* Initialize the error code */
306 hltdc
->ErrorCode
= HAL_LTDC_ERROR_NONE
;
308 /* Initialize the LTDC state*/
309 hltdc
->State
= HAL_LTDC_STATE_READY
;
315 * @brief De-initialize the LTDC peripheral.
316 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
317 * the configuration information for the LTDC.
321 HAL_StatusTypeDef
HAL_LTDC_DeInit(LTDC_HandleTypeDef
*hltdc
)
323 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
324 if (hltdc
->MspDeInitCallback
== NULL
)
326 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
;
328 /* DeInit the low level hardware */
329 hltdc
->MspDeInitCallback(hltdc
);
331 /* DeInit the low level hardware */
332 HAL_LTDC_MspDeInit(hltdc
);
333 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
335 /* Initialize the error code */
336 hltdc
->ErrorCode
= HAL_LTDC_ERROR_NONE
;
338 /* Initialize the LTDC state*/
339 hltdc
->State
= HAL_LTDC_STATE_RESET
;
348 * @brief Initialize the LTDC MSP.
349 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
350 * the configuration information for the LTDC.
353 __weak
void HAL_LTDC_MspInit(LTDC_HandleTypeDef
*hltdc
)
355 /* Prevent unused argument(s) compilation warning */
358 /* NOTE : This function should not be modified, when the callback is needed,
359 the HAL_LTDC_MspInit could be implemented in the user file
364 * @brief De-initialize the LTDC MSP.
365 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
366 * the configuration information for the LTDC.
369 __weak
void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef
*hltdc
)
371 /* Prevent unused argument(s) compilation warning */
374 /* NOTE : This function should not be modified, when the callback is needed,
375 the HAL_LTDC_MspDeInit could be implemented in the user file
379 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
381 * @brief Register a User LTDC Callback
382 * To be used instead of the weak predefined callback
383 * @param hltdc ltdc handle
384 * @param CallbackID ID of the callback to be registered
385 * This parameter can be one of the following values:
386 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
387 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
388 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
389 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
390 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
391 * @param pCallback pointer to the Callback function
394 HAL_StatusTypeDef
HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef
*hltdc
, HAL_LTDC_CallbackIDTypeDef CallbackID
, pLTDC_CallbackTypeDef pCallback
)
396 HAL_StatusTypeDef status
= HAL_OK
;
398 if (pCallback
== NULL
)
400 /* Update the error code */
401 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
408 if (hltdc
->State
== HAL_LTDC_STATE_READY
)
412 case HAL_LTDC_LINE_EVENT_CB_ID
:
413 hltdc
->LineEventCallback
= pCallback
;
416 case HAL_LTDC_RELOAD_EVENT_CB_ID
:
417 hltdc
->ReloadEventCallback
= pCallback
;
420 case HAL_LTDC_ERROR_CB_ID
:
421 hltdc
->ErrorCallback
= pCallback
;
424 case HAL_LTDC_MSPINIT_CB_ID
:
425 hltdc
->MspInitCallback
= pCallback
;
428 case HAL_LTDC_MSPDEINIT_CB_ID
:
429 hltdc
->MspDeInitCallback
= pCallback
;
433 /* Update the error code */
434 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
435 /* Return error status */
440 else if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
444 case HAL_LTDC_MSPINIT_CB_ID
:
445 hltdc
->MspInitCallback
= pCallback
;
448 case HAL_LTDC_MSPDEINIT_CB_ID
:
449 hltdc
->MspDeInitCallback
= pCallback
;
453 /* Update the error code */
454 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
455 /* Return error status */
462 /* Update the error code */
463 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
464 /* Return error status */
475 * @brief Unregister an LTDC Callback
476 * LTDC callabck is redirected to the weak predefined callback
477 * @param hltdc ltdc handle
478 * @param CallbackID ID of the callback to be unregistered
479 * This parameter can be one of the following values:
480 * @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
481 * @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
482 * @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
483 * @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
484 * @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
487 HAL_StatusTypeDef
HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef
*hltdc
, HAL_LTDC_CallbackIDTypeDef CallbackID
)
489 HAL_StatusTypeDef status
= HAL_OK
;
494 if (hltdc
->State
== HAL_LTDC_STATE_READY
)
498 case HAL_LTDC_LINE_EVENT_CB_ID
:
499 hltdc
->LineEventCallback
= HAL_LTDC_LineEventCallback
; /* Legacy weak LineEventCallback */
502 case HAL_LTDC_RELOAD_EVENT_CB_ID
:
503 hltdc
->ReloadEventCallback
= HAL_LTDC_ReloadEventCallback
; /* Legacy weak ReloadEventCallback */
506 case HAL_LTDC_ERROR_CB_ID
:
507 hltdc
->ErrorCallback
= HAL_LTDC_ErrorCallback
; /* Legacy weak ErrorCallback */
510 case HAL_LTDC_MSPINIT_CB_ID
:
511 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
; /* Legcay weak MspInit Callback */
514 case HAL_LTDC_MSPDEINIT_CB_ID
:
515 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
; /* Legcay weak MspDeInit Callback */
519 /* Update the error code */
520 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
521 /* Return error status */
526 else if (hltdc
->State
== HAL_LTDC_STATE_RESET
)
530 case HAL_LTDC_MSPINIT_CB_ID
:
531 hltdc
->MspInitCallback
= HAL_LTDC_MspInit
; /* Legcay weak MspInit Callback */
534 case HAL_LTDC_MSPDEINIT_CB_ID
:
535 hltdc
->MspDeInitCallback
= HAL_LTDC_MspDeInit
; /* Legcay weak MspDeInit Callback */
539 /* Update the error code */
540 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
541 /* Return error status */
548 /* Update the error code */
549 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_INVALID_CALLBACK
;
550 /* Return error status */
559 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
565 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
566 * @brief IO operation functions
569 ===============================================================================
570 ##### IO operation functions #####
571 ===============================================================================
572 [..] This section provides function allowing to:
573 (+) Handle LTDC interrupt request
579 * @brief Handle LTDC interrupt request.
580 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
581 * the configuration information for the LTDC.
584 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef
*hltdc
)
586 uint32_t isrflags
= READ_REG(hltdc
->Instance
->ISR
);
587 uint32_t itsources
= READ_REG(hltdc
->Instance
->IER
);
589 /* Transfer Error Interrupt management ***************************************/
590 if (((isrflags
& LTDC_ISR_TERRIF
) != 0U) && ((itsources
& LTDC_IER_TERRIE
) != 0U))
592 /* Disable the transfer Error interrupt */
593 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_TE
);
595 /* Clear the transfer error flag */
596 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_TE
);
598 /* Update error code */
599 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_TE
;
601 /* Change LTDC state */
602 hltdc
->State
= HAL_LTDC_STATE_ERROR
;
604 /* Process unlocked */
607 /* Transfer error Callback */
608 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
609 /*Call registered error callback*/
610 hltdc
->ErrorCallback(hltdc
);
612 /* Call legacy error callback*/
613 HAL_LTDC_ErrorCallback(hltdc
);
614 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
617 /* FIFO underrun Interrupt management ***************************************/
618 if (((isrflags
& LTDC_ISR_FUIF
) != 0U) && ((itsources
& LTDC_IER_FUIE
) != 0U))
620 /* Disable the FIFO underrun interrupt */
621 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_FU
);
623 /* Clear the FIFO underrun flag */
624 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_FU
);
626 /* Update error code */
627 hltdc
->ErrorCode
|= HAL_LTDC_ERROR_FU
;
629 /* Change LTDC state */
630 hltdc
->State
= HAL_LTDC_STATE_ERROR
;
632 /* Process unlocked */
635 /* Transfer error Callback */
636 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
637 /*Call registered error callback*/
638 hltdc
->ErrorCallback(hltdc
);
640 /* Call legacy error callback*/
641 HAL_LTDC_ErrorCallback(hltdc
);
642 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
645 /* Line Interrupt management ************************************************/
646 if (((isrflags
& LTDC_ISR_LIF
) != 0U) && ((itsources
& LTDC_IER_LIE
) != 0U))
648 /* Disable the Line interrupt */
649 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_LI
);
651 /* Clear the Line interrupt flag */
652 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_LI
);
654 /* Change LTDC state */
655 hltdc
->State
= HAL_LTDC_STATE_READY
;
657 /* Process unlocked */
660 /* Line interrupt Callback */
661 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
662 /*Call registered Line Event callback */
663 hltdc
->LineEventCallback(hltdc
);
665 /*Call Legacy Line Event callback */
666 HAL_LTDC_LineEventCallback(hltdc
);
667 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
670 /* Register reload Interrupt management ***************************************/
671 if (((isrflags
& LTDC_ISR_RRIF
) != 0U) && ((itsources
& LTDC_IER_RRIE
) != 0U))
673 /* Disable the register reload interrupt */
674 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_RR
);
676 /* Clear the register reload flag */
677 __HAL_LTDC_CLEAR_FLAG(hltdc
, LTDC_FLAG_RR
);
679 /* Change LTDC state */
680 hltdc
->State
= HAL_LTDC_STATE_READY
;
682 /* Process unlocked */
685 /* Reload interrupt Callback */
686 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
687 /*Call registered reload Event callback */
688 hltdc
->ReloadEventCallback(hltdc
);
690 /*Call Legacy Reload Event callback */
691 HAL_LTDC_ReloadEventCallback(hltdc
);
692 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
697 * @brief Error LTDC callback.
698 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
699 * the configuration information for the LTDC.
702 __weak
void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef
*hltdc
)
704 /* Prevent unused argument(s) compilation warning */
707 /* NOTE : This function should not be modified, when the callback is needed,
708 the HAL_LTDC_ErrorCallback could be implemented in the user file
713 * @brief Line Event callback.
714 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
715 * the configuration information for the LTDC.
718 __weak
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef
*hltdc
)
720 /* Prevent unused argument(s) compilation warning */
723 /* NOTE : This function should not be modified, when the callback is needed,
724 the HAL_LTDC_LineEventCallback could be implemented in the user file
729 * @brief Reload Event callback.
730 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
731 * the configuration information for the LTDC.
734 __weak
void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef
*hltdc
)
736 /* Prevent unused argument(s) compilation warning */
739 /* NOTE : This function should not be modified, when the callback is needed,
740 the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
748 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
749 * @brief Peripheral Control functions
752 ===============================================================================
753 ##### Peripheral Control functions #####
754 ===============================================================================
755 [..] This section provides functions allowing to:
756 (+) Configure the LTDC foreground or/and background parameters.
757 (+) Set the active layer.
758 (+) Configure the color keying.
759 (+) Configure the C-LUT.
760 (+) Enable / Disable the color keying.
761 (+) Enable / Disable the C-LUT.
762 (+) Update the layer position.
763 (+) Update the layer size.
764 (+) Update pixel format on the fly.
765 (+) Update transparency on the fly.
766 (+) Update address on the fly.
773 * @brief Configure the LTDC Layer according to the specified
774 * parameters in the LTDC_InitTypeDef and create the associated handle.
775 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
776 * the configuration information for the LTDC.
777 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
778 * the configuration information for the Layer.
779 * @param LayerIdx LTDC Layer index.
780 * This parameter can be one of the following values:
781 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
784 HAL_StatusTypeDef
HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
786 /* Check the parameters */
787 assert_param(IS_LTDC_LAYER(LayerIdx
));
788 assert_param(IS_LTDC_HCONFIGST(pLayerCfg
->WindowX0
));
789 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg
->WindowX1
));
790 assert_param(IS_LTDC_VCONFIGST(pLayerCfg
->WindowY0
));
791 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg
->WindowY1
));
792 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg
->PixelFormat
));
793 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha
));
794 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha0
));
795 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg
->BlendingFactor1
));
796 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg
->BlendingFactor2
));
797 assert_param(IS_LTDC_CFBLL(pLayerCfg
->ImageWidth
));
798 assert_param(IS_LTDC_CFBLNBR(pLayerCfg
->ImageHeight
));
803 /* Change LTDC peripheral state */
804 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
806 /* Copy new layer configuration into handle structure */
807 hltdc
->LayerCfg
[LayerIdx
] = *pLayerCfg
;
809 /* Configure the LTDC Layer */
810 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
812 /* Set the Immediate Reload type */
813 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
815 /* Initialize the LTDC state*/
816 hltdc
->State
= HAL_LTDC_STATE_READY
;
818 /* Process unlocked */
825 * @brief Configure the color keying.
826 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
827 * the configuration information for the LTDC.
828 * @param RGBValue the color key value
829 * @param LayerIdx LTDC Layer index.
830 * This parameter can be one of the following values:
831 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
834 HAL_StatusTypeDef
HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t RGBValue
, uint32_t LayerIdx
)
836 /* Check the parameters */
837 assert_param(IS_LTDC_LAYER(LayerIdx
));
842 /* Change LTDC peripheral state */
843 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
845 /* Configure the default color values */
846 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
&= ~(LTDC_LxCKCR_CKBLUE
| LTDC_LxCKCR_CKGREEN
| LTDC_LxCKCR_CKRED
);
847 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
= RGBValue
;
849 /* Set the Immediate Reload type */
850 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
852 /* Change the LTDC state*/
853 hltdc
->State
= HAL_LTDC_STATE_READY
;
855 /* Process unlocked */
862 * @brief Load the color lookup table.
863 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
864 * the configuration information for the LTDC.
865 * @param pCLUT pointer to the color lookup table address.
866 * @param CLUTSize the color lookup table size.
867 * @param LayerIdx LTDC Layer index.
868 * This parameter can be one of the following values:
869 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
872 HAL_StatusTypeDef
HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t *pCLUT
, uint32_t CLUTSize
, uint32_t LayerIdx
)
876 uint32_t *pcolorlut
= pCLUT
;
877 /* Check the parameters */
878 assert_param(IS_LTDC_LAYER(LayerIdx
));
883 /* Change LTDC peripheral state */
884 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
886 for (counter
= 0U; (counter
< CLUTSize
); counter
++)
888 if (hltdc
->LayerCfg
[LayerIdx
].PixelFormat
== LTDC_PIXEL_FORMAT_AL44
)
890 tmp
= (((counter
+ (16U*counter
)) << 24U) | ((uint32_t)(*pcolorlut
) & 0xFFU
) | ((uint32_t)(*pcolorlut
) & 0xFF00U
) | ((uint32_t)(*pcolorlut
) & 0xFF0000U
));
894 tmp
= ((counter
<< 24U) | ((uint32_t)(*pcolorlut
) & 0xFFU
) | ((uint32_t)(*pcolorlut
) & 0xFF00U
) | ((uint32_t)(*pcolorlut
) & 0xFF0000U
));
899 /* Specifies the C-LUT address and RGB value */
900 LTDC_LAYER(hltdc
, LayerIdx
)->CLUTWR
= tmp
;
903 /* Change the LTDC state*/
904 hltdc
->State
= HAL_LTDC_STATE_READY
;
906 /* Process unlocked */
913 * @brief Enable the color keying.
914 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
915 * the configuration information for the LTDC.
916 * @param LayerIdx LTDC Layer index.
917 * This parameter can be one of the following values:
918 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
921 HAL_StatusTypeDef
HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
923 /* Check the parameters */
924 assert_param(IS_LTDC_LAYER(LayerIdx
));
929 /* Change LTDC peripheral state */
930 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
932 /* Enable LTDC color keying by setting COLKEN bit */
933 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_COLKEN
;
935 /* Set the Immediate Reload type */
936 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
938 /* Change the LTDC state*/
939 hltdc
->State
= HAL_LTDC_STATE_READY
;
941 /* Process unlocked */
948 * @brief Disable the color keying.
949 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
950 * the configuration information for the LTDC.
951 * @param LayerIdx LTDC Layer index.
952 * This parameter can be one of the following values:
953 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
956 HAL_StatusTypeDef
HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
958 /* Check the parameters */
959 assert_param(IS_LTDC_LAYER(LayerIdx
));
964 /* Change LTDC peripheral state */
965 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
967 /* Disable LTDC color keying by setting COLKEN bit */
968 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_COLKEN
;
970 /* Set the Immediate Reload type */
971 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
973 /* Change the LTDC state*/
974 hltdc
->State
= HAL_LTDC_STATE_READY
;
976 /* Process unlocked */
983 * @brief Enable the color lookup table.
984 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
985 * the configuration information for the LTDC.
986 * @param LayerIdx LTDC Layer index.
987 * This parameter can be one of the following values:
988 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
991 HAL_StatusTypeDef
HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
993 /* Check the parameters */
994 assert_param(IS_LTDC_LAYER(LayerIdx
));
999 /* Change LTDC peripheral state */
1000 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1002 /* Enable LTDC color lookup table by setting CLUTEN bit */
1003 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_CLUTEN
;
1005 /* Set the Immediate Reload type */
1006 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1008 /* Change the LTDC state*/
1009 hltdc
->State
= HAL_LTDC_STATE_READY
;
1011 /* Process unlocked */
1012 __HAL_UNLOCK(hltdc
);
1018 * @brief Disable the color lookup table.
1019 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1020 * the configuration information for the LTDC.
1021 * @param LayerIdx LTDC Layer index.
1022 * This parameter can be one of the following values:
1023 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1024 * @retval HAL status
1026 HAL_StatusTypeDef
HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1028 /* Check the parameters */
1029 assert_param(IS_LTDC_LAYER(LayerIdx
));
1031 /* Process locked */
1034 /* Change LTDC peripheral state */
1035 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1037 /* Disable LTDC color lookup table by setting CLUTEN bit */
1038 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_CLUTEN
;
1040 /* Set the Immediate Reload type */
1041 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1043 /* Change the LTDC state*/
1044 hltdc
->State
= HAL_LTDC_STATE_READY
;
1046 /* Process unlocked */
1047 __HAL_UNLOCK(hltdc
);
1053 * @brief Enable Dither.
1054 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1055 * the configuration information for the LTDC.
1056 * @retval HAL status
1059 HAL_StatusTypeDef
HAL_LTDC_EnableDither(LTDC_HandleTypeDef
*hltdc
)
1061 /* Process locked */
1064 /* Change LTDC peripheral state */
1065 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1067 /* Enable Dither by setting DTEN bit */
1068 LTDC
->GCR
|= (uint32_t)LTDC_GCR_DEN
;
1070 /* Change the LTDC state*/
1071 hltdc
->State
= HAL_LTDC_STATE_READY
;
1073 /* Process unlocked */
1074 __HAL_UNLOCK(hltdc
);
1080 * @brief Disable Dither.
1081 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1082 * the configuration information for the LTDC.
1083 * @retval HAL status
1086 HAL_StatusTypeDef
HAL_LTDC_DisableDither(LTDC_HandleTypeDef
*hltdc
)
1088 /* Process locked */
1091 /* Change LTDC peripheral state */
1092 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1094 /* Disable Dither by setting DTEN bit */
1095 LTDC
->GCR
&= ~(uint32_t)LTDC_GCR_DEN
;
1097 /* Change the LTDC state*/
1098 hltdc
->State
= HAL_LTDC_STATE_READY
;
1100 /* Process unlocked */
1101 __HAL_UNLOCK(hltdc
);
1107 * @brief Set the LTDC window size.
1108 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1109 * the configuration information for the LTDC.
1110 * @param XSize LTDC Pixel per line
1111 * @param YSize LTDC Line number
1112 * @param LayerIdx LTDC Layer index.
1113 * This parameter can be one of the following values:
1114 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1115 * @retval HAL status
1117 HAL_StatusTypeDef
HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef
*hltdc
, uint32_t XSize
, uint32_t YSize
, uint32_t LayerIdx
)
1119 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1121 /* Check the parameters (Layers parameters)*/
1122 assert_param(IS_LTDC_LAYER(LayerIdx
));
1123 assert_param(IS_LTDC_CFBLL(XSize
));
1124 assert_param(IS_LTDC_CFBLNBR(YSize
));
1126 /* Process locked */
1129 /* Change LTDC peripheral state */
1130 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1132 /* Get layer configuration from handle structure */
1133 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1135 /* update horizontal stop */
1136 pLayerCfg
->WindowX1
= XSize
+ pLayerCfg
->WindowX0
;
1138 /* update vertical stop */
1139 pLayerCfg
->WindowY1
= YSize
+ pLayerCfg
->WindowY0
;
1141 /* Reconfigures the color frame buffer pitch in byte */
1142 pLayerCfg
->ImageWidth
= XSize
;
1144 /* Reconfigures the frame buffer line number */
1145 pLayerCfg
->ImageHeight
= YSize
;
1147 /* Set LTDC parameters */
1148 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1150 /* Set the Immediate Reload type */
1151 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1153 /* Change the LTDC state*/
1154 hltdc
->State
= HAL_LTDC_STATE_READY
;
1156 /* Process unlocked */
1157 __HAL_UNLOCK(hltdc
);
1163 * @brief Set the LTDC window position.
1164 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1165 * the configuration information for the LTDC.
1166 * @param X0 LTDC window X offset
1167 * @param Y0 LTDC window Y offset
1168 * @param LayerIdx LTDC Layer index.
1169 * This parameter can be one of the following values:
1170 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1171 * @retval HAL status
1173 HAL_StatusTypeDef
HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef
*hltdc
, uint32_t X0
, uint32_t Y0
, uint32_t LayerIdx
)
1175 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1177 /* Check the parameters */
1178 assert_param(IS_LTDC_LAYER(LayerIdx
));
1179 assert_param(IS_LTDC_CFBLL(X0
));
1180 assert_param(IS_LTDC_CFBLNBR(Y0
));
1182 /* Process locked */
1185 /* Change LTDC peripheral state */
1186 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1188 /* Get layer configuration from handle structure */
1189 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1191 /* update horizontal start/stop */
1192 pLayerCfg
->WindowX0
= X0
;
1193 pLayerCfg
->WindowX1
= X0
+ pLayerCfg
->ImageWidth
;
1195 /* update vertical start/stop */
1196 pLayerCfg
->WindowY0
= Y0
;
1197 pLayerCfg
->WindowY1
= Y0
+ pLayerCfg
->ImageHeight
;
1199 /* Set LTDC parameters */
1200 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1202 /* Set the Immediate Reload type */
1203 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1205 /* Change the LTDC state*/
1206 hltdc
->State
= HAL_LTDC_STATE_READY
;
1208 /* Process unlocked */
1209 __HAL_UNLOCK(hltdc
);
1215 * @brief Reconfigure the pixel format.
1216 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1217 * the configuration information for the LTDC.
1218 * @param Pixelformat new pixel format value.
1219 * @param LayerIdx LTDC Layer index.
1220 * This parameter can be one of the following values:
1221 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1222 * @retval HAL status
1224 HAL_StatusTypeDef
HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef
*hltdc
, uint32_t Pixelformat
, uint32_t LayerIdx
)
1226 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1228 /* Check the parameters */
1229 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat
));
1230 assert_param(IS_LTDC_LAYER(LayerIdx
));
1232 /* Process locked */
1235 /* Change LTDC peripheral state */
1236 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1238 /* Get layer configuration from handle structure */
1239 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1241 /* Reconfigure the pixel format */
1242 pLayerCfg
->PixelFormat
= Pixelformat
;
1244 /* Set LTDC parameters */
1245 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1247 /* Set the Immediate Reload type */
1248 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1250 /* Change the LTDC state*/
1251 hltdc
->State
= HAL_LTDC_STATE_READY
;
1253 /* Process unlocked */
1254 __HAL_UNLOCK(hltdc
);
1260 * @brief Reconfigure the layer alpha value.
1261 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1262 * the configuration information for the LTDC.
1263 * @param Alpha new alpha value.
1264 * @param LayerIdx LTDC Layer index.
1265 * This parameter can be one of the following values:
1266 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1267 * @retval HAL status
1269 HAL_StatusTypeDef
HAL_LTDC_SetAlpha(LTDC_HandleTypeDef
*hltdc
, uint32_t Alpha
, uint32_t LayerIdx
)
1271 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1273 /* Check the parameters */
1274 assert_param(IS_LTDC_ALPHA(Alpha
));
1275 assert_param(IS_LTDC_LAYER(LayerIdx
));
1277 /* Process locked */
1280 /* Change LTDC peripheral state */
1281 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1283 /* Get layer configuration from handle structure */
1284 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1286 /* Reconfigure the Alpha value */
1287 pLayerCfg
->Alpha
= Alpha
;
1289 /* Set LTDC parameters */
1290 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1292 /* Set the Immediate Reload type */
1293 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1295 /* Change the LTDC state*/
1296 hltdc
->State
= HAL_LTDC_STATE_READY
;
1298 /* Process unlocked */
1299 __HAL_UNLOCK(hltdc
);
1304 * @brief Reconfigure the frame buffer Address.
1305 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1306 * the configuration information for the LTDC.
1307 * @param Address new address value.
1308 * @param LayerIdx LTDC Layer index.
1309 * This parameter can be one of the following values:
1310 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1311 * @retval HAL status
1313 HAL_StatusTypeDef
HAL_LTDC_SetAddress(LTDC_HandleTypeDef
*hltdc
, uint32_t Address
, uint32_t LayerIdx
)
1315 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1317 /* Check the parameters */
1318 assert_param(IS_LTDC_LAYER(LayerIdx
));
1320 /* Process locked */
1323 /* Change LTDC peripheral state */
1324 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1326 /* Get layer configuration from handle structure */
1327 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1329 /* Reconfigure the Address */
1330 pLayerCfg
->FBStartAdress
= Address
;
1332 /* Set LTDC parameters */
1333 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1335 /* Set the Immediate Reload type */
1336 hltdc
->Instance
->SRCR
= LTDC_SRCR_IMR
;
1338 /* Change the LTDC state*/
1339 hltdc
->State
= HAL_LTDC_STATE_READY
;
1341 /* Process unlocked */
1342 __HAL_UNLOCK(hltdc
);
1348 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
1349 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
1350 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
1351 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
1352 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
1353 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1354 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1355 * the configuration information for the LTDC.
1356 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1357 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1358 * @retval HAL status
1360 HAL_StatusTypeDef
HAL_LTDC_SetPitch(LTDC_HandleTypeDef
*hltdc
, uint32_t LinePitchInPixels
, uint32_t LayerIdx
)
1363 uint32_t pitchUpdate
;
1364 uint32_t pixelFormat
;
1366 /* Check the parameters */
1367 assert_param(IS_LTDC_LAYER(LayerIdx
));
1369 /* Process locked */
1372 /* Change LTDC peripheral state */
1373 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1375 /* get LayerIdx used pixel format */
1376 pixelFormat
= hltdc
->LayerCfg
[LayerIdx
].PixelFormat
;
1378 if (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
1382 else if (pixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
1386 else if ((pixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
1387 (pixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
1388 (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
1389 (pixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
1398 pitchUpdate
= ((LinePitchInPixels
* tmp
) << 16U);
1400 /* Clear previously set standard pitch */
1401 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~LTDC_LxCFBLR_CFBP
;
1403 /* Set the Reload type as immediate update of LTDC pitch configured above */
1404 LTDC
->SRCR
|= LTDC_SRCR_IMR
;
1406 /* Set new line pitch value */
1407 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
|= pitchUpdate
;
1409 /* Set the Reload type as immediate update of LTDC pitch configured above */
1410 LTDC
->SRCR
|= LTDC_SRCR_IMR
;
1412 /* Change the LTDC state*/
1413 hltdc
->State
= HAL_LTDC_STATE_READY
;
1415 /* Process unlocked */
1416 __HAL_UNLOCK(hltdc
);
1422 * @brief Define the position of the line interrupt.
1423 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1424 * the configuration information for the LTDC.
1425 * @param Line Line Interrupt Position.
1426 * @note User application may resort to HAL_LTDC_LineEventCallback() at line interrupt generation.
1427 * @retval HAL status
1429 HAL_StatusTypeDef
HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef
*hltdc
, uint32_t Line
)
1431 /* Check the parameters */
1432 assert_param(IS_LTDC_LIPOS(Line
));
1434 /* Process locked */
1437 /* Change LTDC peripheral state */
1438 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1440 /* Disable the Line interrupt */
1441 __HAL_LTDC_DISABLE_IT(hltdc
, LTDC_IT_LI
);
1443 /* Set the Line Interrupt position */
1444 LTDC
->LIPCR
= (uint32_t)Line
;
1446 /* Enable the Line interrupt */
1447 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_LI
);
1449 /* Change the LTDC state*/
1450 hltdc
->State
= HAL_LTDC_STATE_READY
;
1452 /* Process unlocked */
1453 __HAL_UNLOCK(hltdc
);
1459 * @brief Reload LTDC Layers configuration.
1460 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1461 * the configuration information for the LTDC.
1462 * @param ReloadType This parameter can be one of the following values :
1463 * LTDC_RELOAD_IMMEDIATE : Immediate Reload
1464 * LTDC_RELOAD_VERTICAL_BLANKING : Reload in the next Vertical Blanking
1465 * @note User application may resort to HAL_LTDC_ReloadEventCallback() at reload interrupt generation.
1466 * @retval HAL status
1468 HAL_StatusTypeDef
HAL_LTDC_Reload(LTDC_HandleTypeDef
*hltdc
, uint32_t ReloadType
)
1470 /* Check the parameters */
1471 assert_param(IS_LTDC_RELOAD(ReloadType
));
1473 /* Process locked */
1476 /* Change LTDC peripheral state */
1477 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1479 /* Enable the Reload interrupt */
1480 __HAL_LTDC_ENABLE_IT(hltdc
, LTDC_IT_RR
);
1482 /* Apply Reload type */
1483 hltdc
->Instance
->SRCR
= ReloadType
;
1485 /* Change the LTDC state*/
1486 hltdc
->State
= HAL_LTDC_STATE_READY
;
1488 /* Process unlocked */
1489 __HAL_UNLOCK(hltdc
);
1495 * @brief Configure the LTDC Layer according to the specified without reloading
1496 * parameters in the LTDC_InitTypeDef and create the associated handle.
1497 * Variant of the function HAL_LTDC_ConfigLayer without immediate reload.
1498 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1499 * the configuration information for the LTDC.
1500 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
1501 * the configuration information for the Layer.
1502 * @param LayerIdx LTDC Layer index.
1503 * This parameter can be one of the following values:
1504 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1505 * @retval HAL status
1507 HAL_StatusTypeDef
HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
1509 /* Check the parameters */
1510 assert_param(IS_LTDC_LAYER(LayerIdx
));
1511 assert_param(IS_LTDC_HCONFIGST(pLayerCfg
->WindowX0
));
1512 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg
->WindowX1
));
1513 assert_param(IS_LTDC_VCONFIGST(pLayerCfg
->WindowY0
));
1514 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg
->WindowY1
));
1515 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg
->PixelFormat
));
1516 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha
));
1517 assert_param(IS_LTDC_ALPHA(pLayerCfg
->Alpha0
));
1518 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg
->BlendingFactor1
));
1519 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg
->BlendingFactor2
));
1520 assert_param(IS_LTDC_CFBLL(pLayerCfg
->ImageWidth
));
1521 assert_param(IS_LTDC_CFBLNBR(pLayerCfg
->ImageHeight
));
1523 /* Process locked */
1526 /* Change LTDC peripheral state */
1527 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1529 /* Copy new layer configuration into handle structure */
1530 hltdc
->LayerCfg
[LayerIdx
] = *pLayerCfg
;
1532 /* Configure the LTDC Layer */
1533 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1535 /* Initialize the LTDC state*/
1536 hltdc
->State
= HAL_LTDC_STATE_READY
;
1538 /* Process unlocked */
1539 __HAL_UNLOCK(hltdc
);
1545 * @brief Set the LTDC window size without reloading.
1546 * Variant of the function HAL_LTDC_SetWindowSize without immediate reload.
1547 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1548 * the configuration information for the LTDC.
1549 * @param XSize LTDC Pixel per line
1550 * @param YSize LTDC Line number
1551 * @param LayerIdx LTDC Layer index.
1552 * This parameter can be one of the following values:
1553 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1554 * @retval HAL status
1556 HAL_StatusTypeDef
HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t XSize
, uint32_t YSize
, uint32_t LayerIdx
)
1558 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1560 /* Check the parameters (Layers parameters)*/
1561 assert_param(IS_LTDC_LAYER(LayerIdx
));
1562 assert_param(IS_LTDC_CFBLL(XSize
));
1563 assert_param(IS_LTDC_CFBLNBR(YSize
));
1565 /* Process locked */
1568 /* Change LTDC peripheral state */
1569 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1571 /* Get layer configuration from handle structure */
1572 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1574 /* update horizontal stop */
1575 pLayerCfg
->WindowX1
= XSize
+ pLayerCfg
->WindowX0
;
1577 /* update vertical stop */
1578 pLayerCfg
->WindowY1
= YSize
+ pLayerCfg
->WindowY0
;
1580 /* Reconfigures the color frame buffer pitch in byte */
1581 pLayerCfg
->ImageWidth
= XSize
;
1583 /* Reconfigures the frame buffer line number */
1584 pLayerCfg
->ImageHeight
= YSize
;
1586 /* Set LTDC parameters */
1587 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1589 /* Change the LTDC state*/
1590 hltdc
->State
= HAL_LTDC_STATE_READY
;
1592 /* Process unlocked */
1593 __HAL_UNLOCK(hltdc
);
1599 * @brief Set the LTDC window position without reloading.
1600 * Variant of the function HAL_LTDC_SetWindowPosition without immediate reload.
1601 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1602 * the configuration information for the LTDC.
1603 * @param X0 LTDC window X offset
1604 * @param Y0 LTDC window Y offset
1605 * @param LayerIdx LTDC Layer index.
1606 * This parameter can be one of the following values:
1607 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1608 * @retval HAL status
1610 HAL_StatusTypeDef
HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t X0
, uint32_t Y0
, uint32_t LayerIdx
)
1612 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1614 /* Check the parameters */
1615 assert_param(IS_LTDC_LAYER(LayerIdx
));
1616 assert_param(IS_LTDC_CFBLL(X0
));
1617 assert_param(IS_LTDC_CFBLNBR(Y0
));
1619 /* Process locked */
1622 /* Change LTDC peripheral state */
1623 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1625 /* Get layer configuration from handle structure */
1626 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1628 /* update horizontal start/stop */
1629 pLayerCfg
->WindowX0
= X0
;
1630 pLayerCfg
->WindowX1
= X0
+ pLayerCfg
->ImageWidth
;
1632 /* update vertical start/stop */
1633 pLayerCfg
->WindowY0
= Y0
;
1634 pLayerCfg
->WindowY1
= Y0
+ pLayerCfg
->ImageHeight
;
1636 /* Set LTDC parameters */
1637 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1639 /* Change the LTDC state*/
1640 hltdc
->State
= HAL_LTDC_STATE_READY
;
1642 /* Process unlocked */
1643 __HAL_UNLOCK(hltdc
);
1649 * @brief Reconfigure the pixel format without reloading.
1650 * Variant of the function HAL_LTDC_SetPixelFormat without immediate reload.
1651 * @param hltdc pointer to a LTDC_HandleTypeDfef structure that contains
1652 * the configuration information for the LTDC.
1653 * @param Pixelformat new pixel format value.
1654 * @param LayerIdx LTDC Layer index.
1655 * This parameter can be one of the following values:
1656 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1657 * @retval HAL status
1659 HAL_StatusTypeDef
HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Pixelformat
, uint32_t LayerIdx
)
1661 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1663 /* Check the parameters */
1664 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat
));
1665 assert_param(IS_LTDC_LAYER(LayerIdx
));
1667 /* Process locked */
1670 /* Change LTDC peripheral state */
1671 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1673 /* Get layer configuration from handle structure */
1674 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1676 /* Reconfigure the pixel format */
1677 pLayerCfg
->PixelFormat
= Pixelformat
;
1679 /* Set LTDC parameters */
1680 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1682 /* Change the LTDC state*/
1683 hltdc
->State
= HAL_LTDC_STATE_READY
;
1685 /* Process unlocked */
1686 __HAL_UNLOCK(hltdc
);
1692 * @brief Reconfigure the layer alpha value without reloading.
1693 * Variant of the function HAL_LTDC_SetAlpha without immediate reload.
1694 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1695 * the configuration information for the LTDC.
1696 * @param Alpha new alpha value.
1697 * @param LayerIdx LTDC Layer index.
1698 * This parameter can be one of the following values:
1699 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1700 * @retval HAL status
1702 HAL_StatusTypeDef
HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Alpha
, uint32_t LayerIdx
)
1704 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1706 /* Check the parameters */
1707 assert_param(IS_LTDC_ALPHA(Alpha
));
1708 assert_param(IS_LTDC_LAYER(LayerIdx
));
1710 /* Process locked */
1713 /* Change LTDC peripheral state */
1714 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1716 /* Get layer configuration from handle structure */
1717 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1719 /* Reconfigure the Alpha value */
1720 pLayerCfg
->Alpha
= Alpha
;
1722 /* Set LTDC parameters */
1723 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1725 /* Change the LTDC state*/
1726 hltdc
->State
= HAL_LTDC_STATE_READY
;
1728 /* Process unlocked */
1729 __HAL_UNLOCK(hltdc
);
1735 * @brief Reconfigure the frame buffer Address without reloading.
1736 * Variant of the function HAL_LTDC_SetAddress without immediate reload.
1737 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1738 * the configuration information for the LTDC.
1739 * @param Address new address value.
1740 * @param LayerIdx LTDC Layer index.
1741 * This parameter can be one of the following values:
1742 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
1743 * @retval HAL status
1745 HAL_StatusTypeDef
HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t Address
, uint32_t LayerIdx
)
1747 LTDC_LayerCfgTypeDef
*pLayerCfg
;
1749 /* Check the parameters */
1750 assert_param(IS_LTDC_LAYER(LayerIdx
));
1752 /* Process locked */
1755 /* Change LTDC peripheral state */
1756 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1758 /* Get layer configuration from handle structure */
1759 pLayerCfg
= &hltdc
->LayerCfg
[LayerIdx
];
1761 /* Reconfigure the Address */
1762 pLayerCfg
->FBStartAdress
= Address
;
1764 /* Set LTDC parameters */
1765 LTDC_SetConfig(hltdc
, pLayerCfg
, LayerIdx
);
1767 /* Change the LTDC state*/
1768 hltdc
->State
= HAL_LTDC_STATE_READY
;
1770 /* Process unlocked */
1771 __HAL_UNLOCK(hltdc
);
1777 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
1778 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
1779 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
1780 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
1781 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
1782 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
1783 * Variant of the function HAL_LTDC_SetPitch without immediate reload.
1784 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1785 * the configuration information for the LTDC.
1786 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
1787 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
1788 * @retval HAL status
1790 HAL_StatusTypeDef
HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LinePitchInPixels
, uint32_t LayerIdx
)
1793 uint32_t pitchUpdate
;
1794 uint32_t pixelFormat
;
1796 /* Check the parameters */
1797 assert_param(IS_LTDC_LAYER(LayerIdx
));
1799 /* Process locked */
1802 /* Change LTDC peripheral state */
1803 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1805 /* get LayerIdx used pixel format */
1806 pixelFormat
= hltdc
->LayerCfg
[LayerIdx
].PixelFormat
;
1808 if (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
1812 else if (pixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
1816 else if ((pixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
1817 (pixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
1818 (pixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
1819 (pixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
1828 pitchUpdate
= ((LinePitchInPixels
* tmp
) << 16U);
1830 /* Clear previously set standard pitch */
1831 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~LTDC_LxCFBLR_CFBP
;
1833 /* Set new line pitch value */
1834 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
|= pitchUpdate
;
1836 /* Change the LTDC state*/
1837 hltdc
->State
= HAL_LTDC_STATE_READY
;
1839 /* Process unlocked */
1840 __HAL_UNLOCK(hltdc
);
1847 * @brief Configure the color keying without reloading.
1848 * Variant of the function HAL_LTDC_ConfigColorKeying without immediate reload.
1849 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1850 * the configuration information for the LTDC.
1851 * @param RGBValue the color key value
1852 * @param LayerIdx LTDC Layer index.
1853 * This parameter can be one of the following values:
1854 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1855 * @retval HAL status
1857 HAL_StatusTypeDef
HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t RGBValue
, uint32_t LayerIdx
)
1859 /* Check the parameters */
1860 assert_param(IS_LTDC_LAYER(LayerIdx
));
1862 /* Process locked */
1865 /* Change LTDC peripheral state */
1866 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1868 /* Configure the default color values */
1869 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
&= ~(LTDC_LxCKCR_CKBLUE
| LTDC_LxCKCR_CKGREEN
| LTDC_LxCKCR_CKRED
);
1870 LTDC_LAYER(hltdc
, LayerIdx
)->CKCR
= RGBValue
;
1872 /* Change the LTDC state*/
1873 hltdc
->State
= HAL_LTDC_STATE_READY
;
1875 /* Process unlocked */
1876 __HAL_UNLOCK(hltdc
);
1882 * @brief Enable the color keying without reloading.
1883 * Variant of the function HAL_LTDC_EnableColorKeying without immediate reload.
1884 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1885 * the configuration information for the LTDC.
1886 * @param LayerIdx LTDC Layer index.
1887 * This parameter can be one of the following values:
1888 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1889 * @retval HAL status
1891 HAL_StatusTypeDef
HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1893 /* Check the parameters */
1894 assert_param(IS_LTDC_LAYER(LayerIdx
));
1896 /* Process locked */
1899 /* Change LTDC peripheral state */
1900 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1902 /* Enable LTDC color keying by setting COLKEN bit */
1903 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_COLKEN
;
1905 /* Change the LTDC state*/
1906 hltdc
->State
= HAL_LTDC_STATE_READY
;
1908 /* Process unlocked */
1909 __HAL_UNLOCK(hltdc
);
1915 * @brief Disable the color keying without reloading.
1916 * Variant of the function HAL_LTDC_DisableColorKeying without immediate reload.
1917 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1918 * the configuration information for the LTDC.
1919 * @param LayerIdx LTDC Layer index.
1920 * This parameter can be one of the following values:
1921 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1922 * @retval HAL status
1924 HAL_StatusTypeDef
HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1926 /* Check the parameters */
1927 assert_param(IS_LTDC_LAYER(LayerIdx
));
1929 /* Process locked */
1932 /* Change LTDC peripheral state */
1933 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1935 /* Disable LTDC color keying by setting COLKEN bit */
1936 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_COLKEN
;
1938 /* Change the LTDC state*/
1939 hltdc
->State
= HAL_LTDC_STATE_READY
;
1941 /* Process unlocked */
1942 __HAL_UNLOCK(hltdc
);
1948 * @brief Enable the color lookup table without reloading.
1949 * Variant of the function HAL_LTDC_EnableCLUT without immediate reload.
1950 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1951 * the configuration information for the LTDC.
1952 * @param LayerIdx LTDC Layer index.
1953 * This parameter can be one of the following values:
1954 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1955 * @retval HAL status
1957 HAL_StatusTypeDef
HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1959 /* Check the parameters */
1960 assert_param(IS_LTDC_LAYER(LayerIdx
));
1962 /* Process locked */
1965 /* Change LTDC peripheral state */
1966 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
1968 /* Disable LTDC color lookup table by setting CLUTEN bit */
1969 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_CLUTEN
;
1971 /* Change the LTDC state*/
1972 hltdc
->State
= HAL_LTDC_STATE_READY
;
1974 /* Process unlocked */
1975 __HAL_UNLOCK(hltdc
);
1981 * @brief Disable the color lookup table without reloading.
1982 * Variant of the function HAL_LTDC_DisableCLUT without immediate reload.
1983 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
1984 * the configuration information for the LTDC.
1985 * @param LayerIdx LTDC Layer index.
1986 * This parameter can be one of the following values:
1987 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
1988 * @retval HAL status
1990 HAL_StatusTypeDef
HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef
*hltdc
, uint32_t LayerIdx
)
1992 /* Check the parameters */
1993 assert_param(IS_LTDC_LAYER(LayerIdx
));
1995 /* Process locked */
1998 /* Change LTDC peripheral state */
1999 hltdc
->State
= HAL_LTDC_STATE_BUSY
;
2001 /* Disable LTDC color lookup table by setting CLUTEN bit */
2002 LTDC_LAYER(hltdc
, LayerIdx
)->CR
&= ~(uint32_t)LTDC_LxCR_CLUTEN
;
2004 /* Change the LTDC state*/
2005 hltdc
->State
= HAL_LTDC_STATE_READY
;
2007 /* Process unlocked */
2008 __HAL_UNLOCK(hltdc
);
2017 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
2018 * @brief Peripheral State and Errors functions
2021 ===============================================================================
2022 ##### Peripheral State and Errors functions #####
2023 ===============================================================================
2025 This subsection provides functions allowing to
2026 (+) Check the LTDC handle state.
2027 (+) Get the LTDC handle error code.
2034 * @brief Return the LTDC handle state.
2035 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2036 * the configuration information for the LTDC.
2039 HAL_LTDC_StateTypeDef
HAL_LTDC_GetState(LTDC_HandleTypeDef
*hltdc
)
2041 return hltdc
->State
;
2045 * @brief Return the LTDC handle error code.
2046 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
2047 * the configuration information for the LTDC.
2048 * @retval LTDC Error Code
2050 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef
*hltdc
)
2052 return hltdc
->ErrorCode
;
2063 /** @defgroup LTDC_Private_Functions LTDC Private Functions
2068 * @brief Configure the LTDC peripheral
2069 * @param hltdc Pointer to a LTDC_HandleTypeDef structure that contains
2070 * the configuration information for the LTDC.
2071 * @param pLayerCfg Pointer LTDC Layer Configuration structure
2072 * @param LayerIdx LTDC Layer index.
2073 * This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
2076 static void LTDC_SetConfig(LTDC_HandleTypeDef
*hltdc
, LTDC_LayerCfgTypeDef
*pLayerCfg
, uint32_t LayerIdx
)
2082 /* Configure the horizontal start and stop position */
2083 tmp
= ((pLayerCfg
->WindowX1
+ ((hltdc
->Instance
->BPCR
& LTDC_BPCR_AHBP
) >> 16U)) << 16U);
2084 LTDC_LAYER(hltdc
, LayerIdx
)->WHPCR
&= ~(LTDC_LxWHPCR_WHSTPOS
| LTDC_LxWHPCR_WHSPPOS
);
2085 LTDC_LAYER(hltdc
, LayerIdx
)->WHPCR
= ((pLayerCfg
->WindowX0
+ ((hltdc
->Instance
->BPCR
& LTDC_BPCR_AHBP
) >> 16U) + 1U) | tmp
);
2087 /* Configure the vertical start and stop position */
2088 tmp
= ((pLayerCfg
->WindowY1
+ (hltdc
->Instance
->BPCR
& LTDC_BPCR_AVBP
)) << 16U);
2089 LTDC_LAYER(hltdc
, LayerIdx
)->WVPCR
&= ~(LTDC_LxWVPCR_WVSTPOS
| LTDC_LxWVPCR_WVSPPOS
);
2090 LTDC_LAYER(hltdc
, LayerIdx
)->WVPCR
= ((pLayerCfg
->WindowY0
+ (hltdc
->Instance
->BPCR
& LTDC_BPCR_AVBP
) + 1U) | tmp
);
2092 /* Specifies the pixel format */
2093 LTDC_LAYER(hltdc
, LayerIdx
)->PFCR
&= ~(LTDC_LxPFCR_PF
);
2094 LTDC_LAYER(hltdc
, LayerIdx
)->PFCR
= (pLayerCfg
->PixelFormat
);
2096 /* Configure the default color values */
2097 tmp
= ((uint32_t)(pLayerCfg
->Backcolor
.Green
) << 8U);
2098 tmp1
= ((uint32_t)(pLayerCfg
->Backcolor
.Red
) << 16U);
2099 tmp2
= (pLayerCfg
->Alpha0
<< 24U);
2100 LTDC_LAYER(hltdc
, LayerIdx
)->DCCR
&= ~(LTDC_LxDCCR_DCBLUE
| LTDC_LxDCCR_DCGREEN
| LTDC_LxDCCR_DCRED
| LTDC_LxDCCR_DCALPHA
);
2101 LTDC_LAYER(hltdc
, LayerIdx
)->DCCR
= (pLayerCfg
->Backcolor
.Blue
| tmp
| tmp1
| tmp2
);
2103 /* Specifies the constant alpha value */
2104 LTDC_LAYER(hltdc
, LayerIdx
)->CACR
&= ~(LTDC_LxCACR_CONSTA
);
2105 LTDC_LAYER(hltdc
, LayerIdx
)->CACR
= (pLayerCfg
->Alpha
);
2107 /* Specifies the blending factors */
2108 LTDC_LAYER(hltdc
, LayerIdx
)->BFCR
&= ~(LTDC_LxBFCR_BF2
| LTDC_LxBFCR_BF1
);
2109 LTDC_LAYER(hltdc
, LayerIdx
)->BFCR
= (pLayerCfg
->BlendingFactor1
| pLayerCfg
->BlendingFactor2
);
2111 /* Configure the color frame buffer start address */
2112 LTDC_LAYER(hltdc
, LayerIdx
)->CFBAR
&= ~(LTDC_LxCFBAR_CFBADD
);
2113 LTDC_LAYER(hltdc
, LayerIdx
)->CFBAR
= (pLayerCfg
->FBStartAdress
);
2115 if (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB8888
)
2119 else if (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_RGB888
)
2123 else if ((pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB4444
) || \
2124 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_RGB565
) || \
2125 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_ARGB1555
) || \
2126 (pLayerCfg
->PixelFormat
== LTDC_PIXEL_FORMAT_AL88
))
2135 /* Configure the color frame buffer pitch in byte */
2136 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
&= ~(LTDC_LxCFBLR_CFBLL
| LTDC_LxCFBLR_CFBP
);
2137 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLR
= (((pLayerCfg
->ImageWidth
* tmp
) << 16U) | (((pLayerCfg
->WindowX1
- pLayerCfg
->WindowX0
) * tmp
) + 7U));
2138 /* Configure the frame buffer line number */
2139 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLNR
&= ~(LTDC_LxCFBLNR_CFBLNBR
);
2140 LTDC_LAYER(hltdc
, LayerIdx
)->CFBLNR
= (pLayerCfg
->ImageHeight
);
2142 /* Enable LTDC_Layer by setting LEN bit */
2143 LTDC_LAYER(hltdc
, LayerIdx
)->CR
|= (uint32_t)LTDC_LxCR_LEN
;
2157 #endif /* HAL_LTDC_MODULE_ENABLED */
2163 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/