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