comparison Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c @ 128:c78bcbd5deda FlipDisplay

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