]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_ltdc.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F4 / stm32f4xx_hal_ltdc.c
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_ltdc.c
4 * @author MCD Application Team
5 * @version V1.1.0
6 * @date 19-June-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_ProgramLineInterrupt()
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
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_Private_Functions
123 * @{
124 */
125
126 /** @defgroup LTDC_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 == HAL_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 /* Initialise 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 /* Initialise 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_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_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 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
506 __HAL_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 tmp = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
549 pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);
550 pCLUT = (uint32_t *)pcounter;
551
552 /* Specifies the C-LUT address and RGB value */
553 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
554 }
555
556 /* Change the LTDC state*/
557 hltdc->State = HAL_LTDC_STATE_READY;
558
559 /* Process unlocked */
560 __HAL_UNLOCK(hltdc);
561
562 return HAL_OK;
563 }
564
565 /**
566 * @brief Enable the color keying.
567 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
568 * the configuration information for the LTDC.
569 * @param LayerIdx: LTDC Layer index.
570 * This parameter can be one of the following values:
571 * 0 or 1
572 * @retval HAL status
573 */
574 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
575 {
576 /* Process locked */
577 __HAL_LOCK(hltdc);
578
579 /* Change LTDC peripheral state */
580 hltdc->State = HAL_LTDC_STATE_BUSY;
581
582 /* Check the parameters */
583 assert_param(IS_LTDC_LAYER(LayerIdx));
584
585 /* Enable LTDC color keying by setting COLKEN bit */
586 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
587
588 /* Sets the Reload type */
589 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
590
591 /* Change the LTDC state*/
592 hltdc->State = HAL_LTDC_STATE_READY;
593
594 /* Process unlocked */
595 __HAL_UNLOCK(hltdc);
596
597 return HAL_OK;
598 }
599
600 /**
601 * @brief Disable the color keying.
602 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
603 * the configuration information for the LTDC.
604 * @param LayerIdx: LTDC Layer index.
605 * This parameter can be one of the following values:
606 * 0 or 1
607 * @retval HAL status
608 */
609 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
610 {
611 /* Process locked */
612 __HAL_LOCK(hltdc);
613
614 /* Change LTDC peripheral state */
615 hltdc->State = HAL_LTDC_STATE_BUSY;
616
617 /* Check the parameters */
618 assert_param(IS_LTDC_LAYER(LayerIdx));
619
620 /* Disable LTDC color keying by setting COLKEN bit */
621 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
622
623 /* Sets the Reload type */
624 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
625
626 /* Change the LTDC state*/
627 hltdc->State = HAL_LTDC_STATE_READY;
628
629 /* Process unlocked */
630 __HAL_UNLOCK(hltdc);
631
632 return HAL_OK;
633 }
634
635 /**
636 * @brief Enable the color lookup table.
637 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
638 * the configuration information for the LTDC.
639 * @param LayerIdx: LTDC Layer index.
640 * This parameter can be one of the following values:
641 * 0 or 1
642 * @retval HAL status
643 */
644 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
645 {
646
647 /* Process locked */
648 __HAL_LOCK(hltdc);
649
650 /* Change LTDC peripheral state */
651 hltdc->State = HAL_LTDC_STATE_BUSY;
652
653 /* Check the parameters */
654 assert_param(IS_LTDC_LAYER(LayerIdx));
655
656 /* Disable LTDC color lookup table by setting CLUTEN bit */
657 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
658
659 /* Sets the Reload type */
660 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
661
662 /* Change the LTDC state*/
663 hltdc->State = HAL_LTDC_STATE_READY;
664
665 /* Process unlocked */
666 __HAL_UNLOCK(hltdc);
667
668 return HAL_OK;
669 }
670
671 /**
672 * @brief Disable the color lookup table.
673 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
674 * the configuration information for the LTDC.
675 * @param LayerIdx: LTDC Layer index.
676 * This parameter can be one of the following values:
677 * 0 or 1
678 * @retval HAL status
679 */
680 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
681 {
682
683 /* Process locked */
684 __HAL_LOCK(hltdc);
685
686 /* Change LTDC peripheral state */
687 hltdc->State = HAL_LTDC_STATE_BUSY;
688
689 /* Check the parameters */
690 assert_param(IS_LTDC_LAYER(LayerIdx));
691
692 /* Disable LTDC color lookup table by setting CLUTEN bit */
693 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
694
695 /* Sets the Reload type */
696 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
697
698 /* Change the LTDC state*/
699 hltdc->State = HAL_LTDC_STATE_READY;
700
701 /* Process unlocked */
702 __HAL_UNLOCK(hltdc);
703
704 return HAL_OK;
705 }
706
707 /**
708 * @brief Enables Dither.
709 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
710 * the configuration information for the LTDC.
711 * @retval HAL status
712 */
713
714 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
715 {
716 /* Process locked */
717 __HAL_LOCK(hltdc);
718
719 /* Change LTDC peripheral state */
720 hltdc->State = HAL_LTDC_STATE_BUSY;
721
722 /* Enable Dither by setting DTEN bit */
723 LTDC->GCR |= (uint32_t)LTDC_GCR_DTEN;
724
725 /* Change the LTDC state*/
726 hltdc->State = HAL_LTDC_STATE_READY;
727
728 /* Process unlocked */
729 __HAL_UNLOCK(hltdc);
730
731 return HAL_OK;
732 }
733
734 /**
735 * @brief Disables Dither.
736 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
737 * the configuration information for the LTDC.
738 * @retval HAL status
739 */
740
741 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
742 {
743 /* Process locked */
744 __HAL_LOCK(hltdc);
745
746 /* Change LTDC peripheral state */
747 hltdc->State = HAL_LTDC_STATE_BUSY;
748
749 /* Disable Dither by setting DTEN bit */
750 LTDC->GCR &= ~(uint32_t)LTDC_GCR_DTEN;
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 Set the LTDC window size.
763 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
764 * the configuration information for the LTDC.
765 * @param XSize: LTDC Pixel per line
766 * @param YSize: LTDC Line number
767 * @param LayerIdx: LTDC Layer index.
768 * This parameter can be one of the following values:
769 * 0 or 1
770 * @retval HAL status
771 */
772 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
773 {
774 LTDC_LayerCfgTypeDef *pLayerCfg;
775
776 /* Process locked */
777 __HAL_LOCK(hltdc);
778
779 /* Change LTDC peripheral state */
780 hltdc->State = HAL_LTDC_STATE_BUSY;
781
782 /* Get layer configuration from handle structure */
783 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
784
785 /* Check the parameters (Layers parameters)*/
786 assert_param(IS_LTDC_LAYER(LayerIdx));
787 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
788 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
789 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
790 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
791 assert_param(IS_LTDC_CFBLL(XSize));
792 assert_param(IS_LTDC_CFBLNBR(YSize));
793
794 /* update horizontal start/stop */
795 pLayerCfg->WindowX0 = 0;
796 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
797
798 /* update vertical start/stop */
799 pLayerCfg->WindowY0 = 0;
800 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
801
802 /* Reconfigures the color frame buffer pitch in byte */
803 pLayerCfg->ImageWidth = XSize;
804
805 /* Reconfigures the frame buffer line number */
806 pLayerCfg->ImageHeight = YSize;
807
808 /* Set LTDC parameters */
809 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
810
811 /* Sets the Reload type */
812 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
813
814 /* Change the LTDC state*/
815 hltdc->State = HAL_LTDC_STATE_READY;
816
817 /* Process unlocked */
818 __HAL_UNLOCK(hltdc);
819
820 return HAL_OK;
821 }
822
823 /**
824 * @brief Set the LTDC window position.
825 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
826 * the configuration information for the LTDC.
827 * @param X0: LTDC window X offset
828 * @param Y0: LTDC window Y offset
829 * @param LayerIdx: LTDC Layer index.
830 * This parameter can be one of the following values:
831 * 0 or 1
832 * @retval HAL status
833 */
834 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
835 {
836 LTDC_LayerCfgTypeDef *pLayerCfg;
837
838 /* Process locked */
839 __HAL_LOCK(hltdc);
840
841 /* Change LTDC peripheral state */
842 hltdc->State = HAL_LTDC_STATE_BUSY;
843
844 /* Get layer configuration from handle structure */
845 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
846
847 /* Check the parameters */
848 assert_param(IS_LTDC_LAYER(LayerIdx));
849 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
850 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
851 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
852 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
853
854 /* update horizontal start/stop */
855 pLayerCfg->WindowX0 = X0;
856 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
857
858 /* update vertical start/stop */
859 pLayerCfg->WindowY0 = Y0;
860 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
861
862 /* Set LTDC parameters */
863 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
864
865 /* Sets the Reload type */
866 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
867
868 /* Change the LTDC state*/
869 hltdc->State = HAL_LTDC_STATE_READY;
870
871 /* Process unlocked */
872 __HAL_UNLOCK(hltdc);
873
874 return HAL_OK;
875 }
876
877 /**
878 * @brief Reconfigure the pixel format.
879 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
880 * the configuration information for the LTDC.
881 * @param Pixelformat: new pixel format value.
882 * @param LayerIdx: LTDC Layer index.
883 * This parameter can be one of the following values:
884 * 0 or 1.
885 * @retval HAL status
886 */
887 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
888 {
889 LTDC_LayerCfgTypeDef *pLayerCfg;
890
891 /* Process locked */
892 __HAL_LOCK(hltdc);
893
894 /* Change LTDC peripheral state */
895 hltdc->State = HAL_LTDC_STATE_BUSY;
896
897 /* Check the parameters */
898 assert_param(IS_LTDC_LAYER(LayerIdx));
899 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
900
901 /* Get layer configuration from handle structure */
902 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
903
904 /* Reconfigure the pixel format */
905 pLayerCfg->PixelFormat = Pixelformat;
906
907 /* Set LTDC parameters */
908 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
909
910 /* Sets the Reload type */
911 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
912
913 /* Change the LTDC state*/
914 hltdc->State = HAL_LTDC_STATE_READY;
915
916 /* Process unlocked */
917 __HAL_UNLOCK(hltdc);
918
919 return HAL_OK;
920 }
921
922 /**
923 * @brief Reconfigure the layer alpha value.
924 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
925 * the configuration information for the LTDC.
926 * @param Alpha: new alpha value.
927 * @param LayerIdx: LTDC Layer index.
928 * This parameter can be one of the following values:
929 * 0 or 1
930 * @retval HAL status
931 */
932 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
933 {
934 LTDC_LayerCfgTypeDef *pLayerCfg;
935
936 /* Process locked */
937 __HAL_LOCK(hltdc);
938
939 /* Change LTDC peripheral state */
940 hltdc->State = HAL_LTDC_STATE_BUSY;
941
942 /* Check the parameters */
943 assert_param(IS_LTDC_ALPHA(Alpha));
944 assert_param(IS_LTDC_LAYER(LayerIdx));
945
946 /* Get layer configuration from handle structure */
947 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
948
949 /* Reconfigure the Alpha value */
950 pLayerCfg->Alpha = Alpha;
951
952 /* Set LTDC parameters */
953 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
954
955 /* Sets the Reload type */
956 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
957
958 /* Change the LTDC state*/
959 hltdc->State = HAL_LTDC_STATE_READY;
960
961 /* Process unlocked */
962 __HAL_UNLOCK(hltdc);
963
964 return HAL_OK;
965 }
966 /**
967 * @brief Reconfigure the frame buffer Address.
968 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
969 * the configuration information for the LTDC.
970 * @param Address: new address value.
971 * @param LayerIdx: LTDC Layer index.
972 * This parameter can be one of the following values:
973 * 0 or 1.
974 * @retval HAL status
975 */
976 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
977 {
978 LTDC_LayerCfgTypeDef *pLayerCfg;
979
980 /* Process locked */
981 __HAL_LOCK(hltdc);
982
983 /* Change LTDC peripheral state */
984 hltdc->State = HAL_LTDC_STATE_BUSY;
985
986 /* Check the parameters */
987 assert_param(IS_LTDC_LAYER(LayerIdx));
988
989 /* Get layer configuration from handle structure */
990 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
991
992 /* Reconfigure the Address */
993 pLayerCfg->FBStartAdress = Address;
994
995 /* Set LTDC parameters */
996 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
997
998 /* Sets the Reload type */
999 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
1000
1001 /* Change the LTDC state*/
1002 hltdc->State = HAL_LTDC_STATE_READY;
1003
1004 /* Process unlocked */
1005 __HAL_UNLOCK(hltdc);
1006
1007 return HAL_OK;
1008 }
1009
1010 /**
1011 * @brief Define the position of the line interrupt .
1012 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
1013 * the configuration information for the LTDC.
1014 * @param Line: Line Interrupt Position.
1015 * @retval HAL status
1016 */
1017 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
1018 {
1019 /* Process locked */
1020 __HAL_LOCK(hltdc);
1021
1022 /* Change LTDC peripheral state */
1023 hltdc->State = HAL_LTDC_STATE_BUSY;
1024
1025 /* Check the parameters */
1026 assert_param(IS_LTDC_LIPOS(Line));
1027
1028 /* Enable the Line interrupt */
1029 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
1030
1031 /* Sets the Line Interrupt position */
1032 LTDC->LIPCR = (uint32_t)Line;
1033
1034 /* Change the LTDC state*/
1035 hltdc->State = HAL_LTDC_STATE_READY;
1036
1037 /* Process unlocked */
1038 __HAL_UNLOCK(hltdc);
1039
1040 return HAL_OK;
1041 }
1042
1043 /**
1044 * @}
1045 */
1046
1047 /** @defgroup LTDC_Group4 Peripheral State and Errors functions
1048 * @brief Peripheral State and Errors functions
1049 *
1050 @verbatim
1051 ===============================================================================
1052 ##### Peripheral State and Errors functions #####
1053 ===============================================================================
1054 [..]
1055 This subsection provides functions allowing to
1056 (+) Check the LTDC state.
1057 (+) Get error code.
1058
1059 @endverbatim
1060 * @{
1061 */
1062
1063 /**
1064 * @brief Return the LTDC state
1065 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
1066 * the configuration information for the LTDC.
1067 * @retval HAL state
1068 */
1069 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
1070 {
1071 return hltdc->State;
1072 }
1073
1074 /**
1075 * @brief Return the LTDC error code
1076 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
1077 * the configuration information for the LTDC.
1078 * @retval LTDC Error Code
1079 */
1080 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
1081 {
1082 return hltdc->ErrorCode;
1083 }
1084
1085 /**
1086 * @}
1087 */
1088
1089 /**
1090 * @brief Configures the LTDC peripheral
1091 * @param hltdc : Pointer to a LTDC_HandleTypeDef structure that contains
1092 * the configuration information for the LTDC.
1093 * @param pLayerCfg: Pointer LTDC Layer Configuration strusture
1094 * @param LayerIdx: LTDC Layer index.
1095 * This parameter can be one of the following values: 0 or 1
1096 * @retval None
1097 */
1098 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
1099 {
1100 uint32_t tmp = 0;
1101 uint32_t tmp1 = 0;
1102 uint32_t tmp2 = 0;
1103
1104 /* Configures the horizontal start and stop position */
1105 tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16)) << 16);
1106 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
1107 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16) + 1) | tmp);
1108
1109 /* Configures the vertical start and stop position */
1110 tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16);
1111 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
1112 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1) | tmp);
1113
1114 /* Specifies the pixel format */
1115 __HAL_LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
1116 __HAL_LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
1117
1118 /* Configures the default color values */
1119 tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8);
1120 tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16);
1121 tmp2 = (pLayerCfg->Alpha0 << 24);
1122 __HAL_LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
1123 __HAL_LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
1124
1125 /* Specifies the constant alpha value */
1126 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
1127 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
1128
1129 /* Specifies the blending factors */
1130 __HAL_LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
1131 __HAL_LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
1132
1133 /* Configures the color frame buffer start address */
1134 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
1135 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
1136
1137 if(pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
1138 {
1139 tmp = 4;
1140 }
1141 else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
1142 {
1143 tmp = 3;
1144 }
1145 else if((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
1146 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
1147 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
1148 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
1149 {
1150 tmp = 2;
1151 }
1152 else
1153 {
1154 tmp = 1;
1155 }
1156
1157 /* Configures the color frame buffer pitch in byte */
1158 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
1159 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16) | ((pLayerCfg->ImageWidth * tmp) + 3));
1160
1161 /* Configures the frame buffer line number */
1162 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
1163 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
1164
1165 /* Enable LTDC_Layer by setting LEN bit */
1166 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
1167 }
1168
1169 /**
1170 * @}
1171 */
1172 #endif /* STM32F429xx || STM32F439xx */
1173 #endif /* HAL_LTDC_MODULE_ENABLED */
1174 /**
1175 * @}
1176 */
1177
1178 /**
1179 * @}
1180 */
1181
1182 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Imprint / Impressum