comparison Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_ltdc.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_ltdc.c
4 * @author MCD Application Team
5 * @version V1.2.0
6 * @date 26-December-2014
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 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
48
49 *** LTDC HAL driver macros list ***
50 =============================================
51 [..]
52 Below the list of most used macros in LTDC HAL driver.
53
54 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
55 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
56 (+) __HAL_LTDC_LAYER_ENABLE: Enable the LTDC Layer.
57 (+) __HAL_LTDC_LAYER_DISABLE: Disable the LTDC Layer.
58 (+) __HAL_LTDC_RELOAD_CONFIG: Reload Layer Configuration.
59 (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
60 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
61 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
62 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
63 (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
64
65 [..]
66 (@) You can refer to the LTDC HAL driver header file for more useful macros
67
68 @endverbatim
69 ******************************************************************************
70 * @attention
71 *
72 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
73 *
74 * Redistribution and use in source and binary forms, with or without modification,
75 * are permitted provided that the following conditions are met:
76 * 1. Redistributions of source code must retain the above copyright notice,
77 * this list of conditions and the following disclaimer.
78 * 2. Redistributions in binary form must reproduce the above copyright notice,
79 * this list of conditions and the following disclaimer in the documentation
80 * and/or other materials provided with the distribution.
81 * 3. Neither the name of STMicroelectronics nor the names of its contributors
82 * may be used to endorse or promote products derived from this software
83 * without specific prior written permission.
84 *
85 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
86 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
88 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
89 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
91 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
92 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
93 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95 *
96 ******************************************************************************
97 */
98
99 /* Includes ------------------------------------------------------------------*/
100 #include "stm32f4xx_hal.h"
101
102 /** @addtogroup STM32F4xx_HAL_Driver
103 * @{
104 */
105 /** @defgroup LTDC LTDC
106 * @brief LTDC HAL module driver
107 * @{
108 */
109
110 #ifdef HAL_LTDC_MODULE_ENABLED
111
112 #if defined(STM32F429xx) || defined(STM32F439xx)
113
114 /* Private typedef -----------------------------------------------------------*/
115 /* Private define ------------------------------------------------------------*/
116 /* Private macro -------------------------------------------------------------*/
117 /* Private variables ---------------------------------------------------------*/
118 /* Private function prototypes -----------------------------------------------*/
119 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
120 /* Private functions ---------------------------------------------------------*/
121
122 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
123 * @{
124 */
125
126 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
127 * @brief Initialization and Configuration functions
128 *
129 @verbatim
130 ===============================================================================
131 ##### Initialization and Configuration functions #####
132 ===============================================================================
133 [..] This section provides functions allowing to:
134 (+) Initialize and configure the LTDC
135 (+) De-initialize the LTDC
136
137 @endverbatim
138 * @{
139 */
140
141 /**
142 * @brief Initializes the LTDC according to the specified
143 * parameters in the LTDC_InitTypeDef and create the associated handle.
144 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
145 * the configuration information for the LTDC.
146 * @retval HAL status
147 */
148 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
149 {
150 uint32_t tmp = 0, tmp1 = 0;
151
152 /* Check the LTDC peripheral state */
153 if(hltdc == NULL)
154 {
155 return HAL_ERROR;
156 }
157
158 /* Check function parameters */
159 assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
160 assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
161 assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
162 assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
163 assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
164 assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
165 assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
166 assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
167 assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
168 assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
169 assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
170 assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
171 assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
172
173 if(hltdc->State == HAL_LTDC_STATE_RESET)
174 {
175 /* Init the low level hardware */
176 HAL_LTDC_MspInit(hltdc);
177 }
178
179 /* Change LTDC peripheral state */
180 hltdc->State = HAL_LTDC_STATE_BUSY;
181
182 /* Configures the HS, VS, DE and PC polarity */
183 hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
184 hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
185 hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
186
187 /* Sets Synchronization size */
188 hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
189 tmp = (hltdc->Init.HorizontalSync << 16);
190 hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
191
192 /* Sets Accumulated Back porch */
193 hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
194 tmp = (hltdc->Init.AccumulatedHBP << 16);
195 hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
196
197 /* Sets Accumulated Active Width */
198 hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
199 tmp = (hltdc->Init.AccumulatedActiveW << 16);
200 hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
201
202 /* Sets Total Width */
203 hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
204 tmp = (hltdc->Init.TotalWidth << 16);
205 hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
206
207 /* Sets the background color value */
208 tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8);
209 tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16);
210 hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
211 hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
212
213 /* Enable the transfer Error interrupt */
214 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE);
215
216 /* Enable the FIFO underrun interrupt */
217 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_FU);
218
219 /* Enable LTDC by setting LTDCEN bit */
220 __HAL_LTDC_ENABLE(hltdc);
221
222 /* Initialize the error code */
223 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
224
225 /* Initialize the LTDC state*/
226 hltdc->State = HAL_LTDC_STATE_READY;
227
228 return HAL_OK;
229 }
230
231 /**
232 * @brief Deinitializes the LTDC peripheral registers to their default reset
233 * values.
234 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
235 * the configuration information for the LTDC.
236 * @retval None
237 */
238
239 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
240 {
241 /* DeInit the low level hardware */
242 HAL_LTDC_MspDeInit(hltdc);
243
244 /* Initialize the error code */
245 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
246
247 /* Initialize the LTDC state*/
248 hltdc->State = HAL_LTDC_STATE_RESET;
249
250 /* Release Lock */
251 __HAL_UNLOCK(hltdc);
252
253 return HAL_OK;
254 }
255
256 /**
257 * @brief Initializes the LTDC MSP.
258 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
259 * the configuration information for the LTDC.
260 * @retval None
261 */
262 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
263 {
264 /* NOTE : This function Should not be modified, when the callback is needed,
265 the HAL_LTDC_MspInit could be implemented in the user file
266 */
267 }
268
269 /**
270 * @brief DeInitializes the LTDC MSP.
271 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
272 * the configuration information for the LTDC.
273 * @retval None
274 */
275 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
276 {
277 /* NOTE : This function Should not be modified, when the callback is needed,
278 the HAL_LTDC_MspDeInit could be implemented in the user file
279 */
280 }
281
282 /**
283 * @}
284 */
285
286 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
287 * @brief IO operation functions
288 *
289 @verbatim
290 ===============================================================================
291 ##### IO operation functions #####
292 ===============================================================================
293 [..] This section provides function allowing to:
294 (+) Handle LTDC interrupt request
295
296 @endverbatim
297 * @{
298 */
299 /**
300 * @brief Handles LTDC interrupt request.
301 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
302 * the configuration information for the LTDC.
303 * @retval HAL status
304 */
305 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
306 {
307 /* Transfer Error Interrupt management ***************************************/
308 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_TE) != RESET)
309 {
310 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_TE) != RESET)
311 {
312 /* Disable the transfer Error interrupt */
313 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
314
315 /* Clear the transfer error flag */
316 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
317
318 /* Update error code */
319 hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
320
321 /* Change LTDC state */
322 hltdc->State = HAL_LTDC_STATE_ERROR;
323
324 /* Process unlocked */
325 __HAL_UNLOCK(hltdc);
326
327 /* Transfer error Callback */
328 HAL_LTDC_ErrorCallback(hltdc);
329 }
330 }
331 /* FIFO underrun Interrupt management ***************************************/
332 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_FU) != RESET)
333 {
334 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_FU) != RESET)
335 {
336 /* Disable the FIFO underrun interrupt */
337 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
338
339 /* Clear the FIFO underrun flag */
340 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
341
342 /* Update error code */
343 hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
344
345 /* Change LTDC state */
346 hltdc->State = HAL_LTDC_STATE_ERROR;
347
348 /* Process unlocked */
349 __HAL_UNLOCK(hltdc);
350
351 /* Transfer error Callback */
352 HAL_LTDC_ErrorCallback(hltdc);
353 }
354 }
355 /* Line Interrupt management ************************************************/
356 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_LI) != RESET)
357 {
358 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_LI) != RESET)
359 {
360 /* Disable the Line interrupt */
361 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
362
363 /* Clear the Line interrupt flag */
364 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
365
366 /* Change LTDC state */
367 hltdc->State = HAL_LTDC_STATE_READY;
368
369 /* Process unlocked */
370 __HAL_UNLOCK(hltdc);
371
372 /* Line interrupt Callback */
373 HAL_LTDC_LineEvenCallback(hltdc);
374 }
375 }
376 }
377
378 /**
379 * @brief Error LTDC callback.
380 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
381 * the configuration information for the LTDC.
382 * @retval None
383 */
384 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
385 {
386 /* NOTE : This function Should not be modified, when the callback is needed,
387 the HAL_LTDC_ErrorCallback could be implemented in the user file
388 */
389 }
390
391 /**
392 * @brief Line Event callback.
393 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
394 * the configuration information for the LTDC.
395 * @retval None
396 */
397 __weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc)
398 {
399 /* NOTE : This function Should not be modified, when the callback is needed,
400 the HAL_LTDC_LineEvenCallback could be implemented in the user file
401 */
402 }
403
404 /**
405 * @}
406 */
407
408 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
409 * @brief Peripheral Control functions
410 *
411 @verbatim
412 ===============================================================================
413 ##### Peripheral Control functions #####
414 ===============================================================================
415 [..] This section provides functions allowing to:
416 (+) Configure the LTDC foreground or/and background parameters.
417 (+) Set the active layer.
418 (+) Configure the color keying.
419 (+) Configure the C-LUT.
420 (+) Enable / Disable the color keying.
421 (+) Enable / Disable the C-LUT.
422 (+) Update the layer position.
423 (+) Update the layer size.
424 (+) Update pixel format on the fly.
425 (+) Update transparency on the fly.
426 (+) Update address on the fly.
427
428 @endverbatim
429 * @{
430 */
431
432 /**
433 * @brief Configure the LTDC Layer according to the specified
434 * parameters in the LTDC_InitTypeDef and create the associated handle.
435 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
436 * the configuration information for the LTDC.
437 * @param pLayerCfg: pointer to a LTDC_LayerCfgTypeDef structure that contains
438 * the configuration information for the Layer.
439 * @param LayerIdx: LTDC Layer index.
440 * This parameter can be one of the following values:
441 * 0 or 1
442 * @retval HAL status
443 */
444 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
445 {
446 /* Process locked */
447 __HAL_LOCK(hltdc);
448
449 /* Change LTDC peripheral state */
450 hltdc->State = HAL_LTDC_STATE_BUSY;
451
452 /* Check the parameters */
453 assert_param(IS_LTDC_LAYER(LayerIdx));
454 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
455 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
456 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
457 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
458 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
459 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
460 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
461 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
462 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
463 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
464
465 /* Copy new layer configuration into handle structure */
466 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
467
468 /* Configure the LTDC Layer */
469 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
470
471 /* Sets the Reload type */
472 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
473
474 /* Initialize the LTDC state*/
475 hltdc->State = HAL_LTDC_STATE_READY;
476
477 /* Process unlocked */
478 __HAL_UNLOCK(hltdc);
479
480 return HAL_OK;
481 }
482
483 /**
484 * @brief Configure the color keying.
485 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
486 * the configuration information for the LTDC.
487 * @param RGBValue: the color key value
488 * @param LayerIdx: LTDC Layer index.
489 * This parameter can be one of the following values:
490 * 0 or 1
491 * @retval HAL status
492 */
493 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
494 {
495 /* Process locked */
496 __HAL_LOCK(hltdc);
497
498 /* Change LTDC peripheral state */
499 hltdc->State = HAL_LTDC_STATE_BUSY;
500
501 /* Check the parameters */
502 assert_param(IS_LTDC_LAYER(LayerIdx));
503
504 /* Configures the default color values */
505 LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
506 LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
507
508 /* Sets the Reload type */
509 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
510
511 /* Change the LTDC state*/
512 hltdc->State = HAL_LTDC_STATE_READY;
513
514 /* Process unlocked */
515 __HAL_UNLOCK(hltdc);
516
517 return HAL_OK;
518 }
519
520 /**
521 * @brief Load the color lookup table.
522 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
523 * the configuration information for the LTDC.
524 * @param pCLUT: pointer to the color lookup table address.
525 * @param CLUTSize: the color lookup table size.
526 * @param LayerIdx: LTDC Layer index.
527 * This parameter can be one of the following values:
528 * 0 or 1
529 * @retval HAL status
530 */
531 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
532 {
533 uint32_t tmp = 0;
534 uint32_t counter = 0;
535 uint32_t pcounter = 0;
536
537 /* Process locked */
538 __HAL_LOCK(hltdc);
539
540 /* Change LTDC peripheral state */
541 hltdc->State = HAL_LTDC_STATE_BUSY;
542
543 /* Check the parameters */
544 assert_param(IS_LTDC_LAYER(LayerIdx));
545
546 for(counter = 0; (counter < CLUTSize); counter++)
547 {
548 if(hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
549 {
550 tmp = (((counter + 16*counter) << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
551 }
552 else
553 {
554 tmp = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
555 }
556 pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);
557 pCLUT = (uint32_t *)pcounter;
558
559 /* Specifies the C-LUT address and RGB value */
560 LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
561 }
562
563 /* Change the LTDC state*/
564 hltdc->State = HAL_LTDC_STATE_READY;
565
566 /* Process unlocked */
567 __HAL_UNLOCK(hltdc);
568
569 return HAL_OK;
570 }
571
572 /**
573 * @brief Enable the color keying.
574 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
575 * the configuration information for the LTDC.
576 * @param LayerIdx: LTDC Layer index.
577 * This parameter can be one of the following values:
578 * 0 or 1
579 * @retval HAL status
580 */
581 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
582 {
583 /* Process locked */
584 __HAL_LOCK(hltdc);
585
586 /* Change LTDC peripheral state */
587 hltdc->State = HAL_LTDC_STATE_BUSY;
588
589 /* Check the parameters */
590 assert_param(IS_LTDC_LAYER(LayerIdx));
591
592 /* Enable LTDC color keying by setting COLKEN bit */
593 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
594
595 /* Sets the Reload type */
596 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
597
598 /* Change the LTDC state*/
599 hltdc->State = HAL_LTDC_STATE_READY;
600
601 /* Process unlocked */
602 __HAL_UNLOCK(hltdc);
603
604 return HAL_OK;
605 }
606
607 /**
608 * @brief Disable the color keying.
609 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
610 * the configuration information for the LTDC.
611 * @param LayerIdx: LTDC Layer index.
612 * This parameter can be one of the following values:
613 * 0 or 1
614 * @retval HAL status
615 */
616 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
617 {
618 /* Process locked */
619 __HAL_LOCK(hltdc);
620
621 /* Change LTDC peripheral state */
622 hltdc->State = HAL_LTDC_STATE_BUSY;
623
624 /* Check the parameters */
625 assert_param(IS_LTDC_LAYER(LayerIdx));
626
627 /* Disable LTDC color keying by setting COLKEN bit */
628 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
629
630 /* Sets the Reload type */
631 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
632
633 /* Change the LTDC state*/
634 hltdc->State = HAL_LTDC_STATE_READY;
635
636 /* Process unlocked */
637 __HAL_UNLOCK(hltdc);
638
639 return HAL_OK;
640 }
641
642 /**
643 * @brief Enable the color lookup table.
644 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
645 * the configuration information for the LTDC.
646 * @param LayerIdx: LTDC Layer index.
647 * This parameter can be one of the following values:
648 * 0 or 1
649 * @retval HAL status
650 */
651 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
652 {
653
654 /* Process locked */
655 __HAL_LOCK(hltdc);
656
657 /* Change LTDC peripheral state */
658 hltdc->State = HAL_LTDC_STATE_BUSY;
659
660 /* Check the parameters */
661 assert_param(IS_LTDC_LAYER(LayerIdx));
662
663 /* Disable LTDC color lookup table by setting CLUTEN bit */
664 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
665
666 /* Sets the Reload type */
667 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
668
669 /* Change the LTDC state*/
670 hltdc->State = HAL_LTDC_STATE_READY;
671
672 /* Process unlocked */
673 __HAL_UNLOCK(hltdc);
674
675 return HAL_OK;
676 }
677
678 /**
679 * @brief Disable the color lookup table.
680 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
681 * the configuration information for the LTDC.
682 * @param LayerIdx: LTDC Layer index.
683 * This parameter can be one of the following values:
684 * 0 or 1
685 * @retval HAL status
686 */
687 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
688 {
689
690 /* Process locked */
691 __HAL_LOCK(hltdc);
692
693 /* Change LTDC peripheral state */
694 hltdc->State = HAL_LTDC_STATE_BUSY;
695
696 /* Check the parameters */
697 assert_param(IS_LTDC_LAYER(LayerIdx));
698
699 /* Disable LTDC color lookup table by setting CLUTEN bit */
700 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
701
702 /* Sets the Reload type */
703 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
704
705 /* Change the LTDC state*/
706 hltdc->State = HAL_LTDC_STATE_READY;
707
708 /* Process unlocked */
709 __HAL_UNLOCK(hltdc);
710
711 return HAL_OK;
712 }
713
714 /**
715 * @brief Enables Dither.
716 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
717 * the configuration information for the LTDC.
718 * @retval HAL status
719 */
720
721 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
722 {
723 /* Process locked */
724 __HAL_LOCK(hltdc);
725
726 /* Change LTDC peripheral state */
727 hltdc->State = HAL_LTDC_STATE_BUSY;
728
729 /* Enable Dither by setting DTEN bit */
730 LTDC->GCR |= (uint32_t)LTDC_GCR_DTEN;
731
732 /* Change the LTDC state*/
733 hltdc->State = HAL_LTDC_STATE_READY;
734
735 /* Process unlocked */
736 __HAL_UNLOCK(hltdc);
737
738 return HAL_OK;
739 }
740
741 /**
742 * @brief Disables Dither.
743 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
744 * the configuration information for the LTDC.
745 * @retval HAL status
746 */
747
748 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
749 {
750 /* Process locked */
751 __HAL_LOCK(hltdc);
752
753 /* Change LTDC peripheral state */
754 hltdc->State = HAL_LTDC_STATE_BUSY;
755
756 /* Disable Dither by setting DTEN bit */
757 LTDC->GCR &= ~(uint32_t)LTDC_GCR_DTEN;
758
759 /* Change the LTDC state*/
760 hltdc->State = HAL_LTDC_STATE_READY;
761
762 /* Process unlocked */
763 __HAL_UNLOCK(hltdc);
764
765 return HAL_OK;
766 }
767
768 /**
769 * @brief Set the LTDC window size.
770 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
771 * the configuration information for the LTDC.
772 * @param XSize: LTDC Pixel per line
773 * @param YSize: LTDC Line number
774 * @param LayerIdx: LTDC Layer index.
775 * This parameter can be one of the following values:
776 * 0 or 1
777 * @retval HAL status
778 */
779 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
780 {
781 LTDC_LayerCfgTypeDef *pLayerCfg;
782
783 /* Process locked */
784 __HAL_LOCK(hltdc);
785
786 /* Change LTDC peripheral state */
787 hltdc->State = HAL_LTDC_STATE_BUSY;
788
789 /* Get layer configuration from handle structure */
790 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
791
792 /* Check the parameters (Layers parameters)*/
793 assert_param(IS_LTDC_LAYER(LayerIdx));
794 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
795 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
796 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
797 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
798 assert_param(IS_LTDC_CFBLL(XSize));
799 assert_param(IS_LTDC_CFBLNBR(YSize));
800
801 /* update horizontal start/stop */
802 pLayerCfg->WindowX0 = 0;
803 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
804
805 /* update vertical start/stop */
806 pLayerCfg->WindowY0 = 0;
807 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
808
809 /* Reconfigures the color frame buffer pitch in byte */
810 pLayerCfg->ImageWidth = XSize;
811
812 /* Reconfigures the frame buffer line number */
813 pLayerCfg->ImageHeight = YSize;
814
815 /* Set LTDC parameters */
816 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
817
818 /* Sets the Reload type */
819 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
820
821 /* Change the LTDC state*/
822 hltdc->State = HAL_LTDC_STATE_READY;
823
824 /* Process unlocked */
825 __HAL_UNLOCK(hltdc);
826
827 return HAL_OK;
828 }
829
830 /**
831 * @brief Set the LTDC window position.
832 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
833 * the configuration information for the LTDC.
834 * @param X0: LTDC window X offset
835 * @param Y0: LTDC window Y offset
836 * @param LayerIdx: LTDC Layer index.
837 * This parameter can be one of the following values:
838 * 0 or 1
839 * @retval HAL status
840 */
841 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
842 {
843 LTDC_LayerCfgTypeDef *pLayerCfg;
844
845 /* Process locked */
846 __HAL_LOCK(hltdc);
847
848 /* Change LTDC peripheral state */
849 hltdc->State = HAL_LTDC_STATE_BUSY;
850
851 /* Get layer configuration from handle structure */
852 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
853
854 /* Check the parameters */
855 assert_param(IS_LTDC_LAYER(LayerIdx));
856 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
857 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
858 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
859 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
860
861 /* update horizontal start/stop */
862 pLayerCfg->WindowX0 = X0;
863 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
864
865 /* update vertical start/stop */
866 pLayerCfg->WindowY0 = Y0;
867 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
868
869 /* Set LTDC parameters */
870 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
871
872 /* Sets the Reload type */
873 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
874
875 /* Change the LTDC state*/
876 hltdc->State = HAL_LTDC_STATE_READY;
877
878 /* Process unlocked */
879 __HAL_UNLOCK(hltdc);
880
881 return HAL_OK;
882 }
883
884 /**
885 * @brief Reconfigure the pixel format.
886 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
887 * the configuration information for the LTDC.
888 * @param Pixelformat: new pixel format value.
889 * @param LayerIdx: LTDC Layer index.
890 * This parameter can be one of the following values:
891 * 0 or 1.
892 * @retval HAL status
893 */
894 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
895 {
896 LTDC_LayerCfgTypeDef *pLayerCfg;
897
898 /* Process locked */
899 __HAL_LOCK(hltdc);
900
901 /* Change LTDC peripheral state */
902 hltdc->State = HAL_LTDC_STATE_BUSY;
903
904 /* Check the parameters */
905 assert_param(IS_LTDC_LAYER(LayerIdx));
906 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
907
908 /* Get layer configuration from handle structure */
909 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
910
911 /* Reconfigure the pixel format */
912 pLayerCfg->PixelFormat = Pixelformat;
913
914 /* Set LTDC parameters */
915 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
916
917 /* Sets the Reload type */
918 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
919
920 /* Change the LTDC state*/
921 hltdc->State = HAL_LTDC_STATE_READY;
922
923 /* Process unlocked */
924 __HAL_UNLOCK(hltdc);
925
926 return HAL_OK;
927 }
928
929 /**
930 * @brief Reconfigure the layer alpha value.
931 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
932 * the configuration information for the LTDC.
933 * @param Alpha: new alpha value.
934 * @param LayerIdx: LTDC Layer index.
935 * This parameter can be one of the following values:
936 * 0 or 1
937 * @retval HAL status
938 */
939 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
940 {
941 LTDC_LayerCfgTypeDef *pLayerCfg;
942
943 /* Process locked */
944 __HAL_LOCK(hltdc);
945
946 /* Change LTDC peripheral state */
947 hltdc->State = HAL_LTDC_STATE_BUSY;
948
949 /* Check the parameters */
950 assert_param(IS_LTDC_ALPHA(Alpha));
951 assert_param(IS_LTDC_LAYER(LayerIdx));
952
953 /* Get layer configuration from handle structure */
954 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
955
956 /* Reconfigure the Alpha value */
957 pLayerCfg->Alpha = Alpha;
958
959 /* Set LTDC parameters */
960 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
961
962 /* Sets the Reload type */
963 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
964
965 /* Change the LTDC state*/
966 hltdc->State = HAL_LTDC_STATE_READY;
967
968 /* Process unlocked */
969 __HAL_UNLOCK(hltdc);
970
971 return HAL_OK;
972 }
973 /**
974 * @brief Reconfigure the frame buffer Address.
975 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
976 * the configuration information for the LTDC.
977 * @param Address: new address value.
978 * @param LayerIdx: LTDC Layer index.
979 * This parameter can be one of the following values:
980 * 0 or 1.
981 * @retval HAL status
982 */
983 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
984 {
985 LTDC_LayerCfgTypeDef *pLayerCfg;
986
987 /* Process locked */
988 __HAL_LOCK(hltdc);
989
990 /* Change LTDC peripheral state */
991 hltdc->State = HAL_LTDC_STATE_BUSY;
992
993 /* Check the parameters */
994 assert_param(IS_LTDC_LAYER(LayerIdx));
995
996 /* Get layer configuration from handle structure */
997 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
998
999 /* Reconfigure the Address */
1000 pLayerCfg->FBStartAdress = Address;
1001
1002 /* Set LTDC parameters */
1003 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
1004
1005 /* Sets the Reload type */
1006 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1007
1008 /* Change the LTDC state*/
1009 hltdc->State = HAL_LTDC_STATE_READY;
1010
1011 /* Process unlocked */
1012 __HAL_UNLOCK(hltdc);
1013
1014 return HAL_OK;
1015 }
1016
1017 /**
1018 * @brief Define the position of the line interrupt .
1019 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
1020 * the configuration information for the LTDC.
1021 * @param Line: Line Interrupt Position.
1022 * @retval HAL status
1023 */
1024 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
1025 {
1026 /* Process locked */
1027 __HAL_LOCK(hltdc);
1028
1029 /* Change LTDC peripheral state */
1030 hltdc->State = HAL_LTDC_STATE_BUSY;
1031
1032 /* Check the parameters */
1033 assert_param(IS_LTDC_LIPOS(Line));
1034
1035 /* Enable the Line interrupt */
1036 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
1037
1038 /* Sets the Line Interrupt position */
1039 LTDC->LIPCR = (uint32_t)Line;
1040
1041 /* Change the LTDC state*/
1042 hltdc->State = HAL_LTDC_STATE_READY;
1043
1044 /* Process unlocked */
1045 __HAL_UNLOCK(hltdc);
1046
1047 return HAL_OK;
1048 }
1049
1050 /**
1051 * @}
1052 */
1053
1054 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
1055 * @brief Peripheral State and Errors functions
1056 *
1057 @verbatim
1058 ===============================================================================
1059 ##### Peripheral State and Errors functions #####
1060 ===============================================================================
1061 [..]
1062 This subsection provides functions allowing to
1063 (+) Check the LTDC state.
1064 (+) Get error code.
1065
1066 @endverbatim
1067 * @{
1068 */
1069
1070 /**
1071 * @brief Return the LTDC state
1072 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
1073 * the configuration information for the LTDC.
1074 * @retval HAL state
1075 */
1076 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
1077 {
1078 return hltdc->State;
1079 }
1080
1081 /**
1082 * @brief Return the LTDC error code
1083 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
1084 * the configuration information for the LTDC.
1085 * @retval LTDC Error Code
1086 */
1087 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
1088 {
1089 return hltdc->ErrorCode;
1090 }
1091
1092 /**
1093 * @}
1094 */
1095
1096 /**
1097 * @brief Configures the LTDC peripheral
1098 * @param hltdc : Pointer to a LTDC_HandleTypeDef structure that contains
1099 * the configuration information for the LTDC.
1100 * @param pLayerCfg: Pointer LTDC Layer Configuration structure
1101 * @param LayerIdx: LTDC Layer index.
1102 * This parameter can be one of the following values: 0 or 1
1103 * @retval None
1104 */
1105 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
1106 {
1107 uint32_t tmp = 0;
1108 uint32_t tmp1 = 0;
1109 uint32_t tmp2 = 0;
1110
1111 /* Configures the horizontal start and stop position */
1112 tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16)) << 16);
1113 LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
1114 LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16) + 1) | tmp);
1115
1116 /* Configures the vertical start and stop position */
1117 tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16);
1118 LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
1119 LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1) | tmp);
1120
1121 /* Specifies the pixel format */
1122 LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
1123 LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
1124
1125 /* Configures the default color values */
1126 tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8);
1127 tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16);
1128 tmp2 = (pLayerCfg->Alpha0 << 24);
1129 LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
1130 LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
1131
1132 /* Specifies the constant alpha value */
1133 LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
1134 LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
1135
1136 /* Specifies the blending factors */
1137 LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
1138 LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
1139
1140 /* Configures the color frame buffer start address */
1141 LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
1142 LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
1143
1144 if(pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1145 {
1146 tmp = 4;
1147 }
1148 else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1149 {
1150 tmp = 3;
1151 }
1152 else if((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1153 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1154 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1155 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
1156 {
1157 tmp = 2;
1158 }
1159 else
1160 {
1161 tmp = 1;
1162 }
1163
1164 /* Configures the color frame buffer pitch in byte */
1165 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
1166 LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16) | ((pLayerCfg->ImageWidth * tmp) + 3));
1167
1168 /* Configures the frame buffer line number */
1169 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
1170 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
1171
1172 /* Enable LTDC_Layer by setting LEN bit */
1173 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
1174 }
1175
1176 /**
1177 * @}
1178 */
1179 #endif /* STM32F429xx || STM32F439xx */
1180 #endif /* HAL_LTDC_MODULE_ENABLED */
1181 /**
1182 * @}
1183 */
1184
1185 /**
1186 * @}
1187 */
1188
1189 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/