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