STM32L443xx HAL User Manual
stm32l4xx_hal_ltdc.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_ltdc.c
00004   * @author  MCD Application Team
00005   * @brief   LTDC HAL module driver.
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the LTDC peripheral:
00008   *           + Initialization and de-initialization functions
00009   *           + IO operation functions
00010   *           + Peripheral Control functions
00011   *           + Peripheral State and Errors functions
00012   *
00013   ******************************************************************************
00014   * @attention
00015   *
00016   * Copyright (c) 2017 STMicroelectronics.
00017   * All rights reserved.
00018   *
00019   * This software is licensed under terms that can be found in the LICENSE file
00020   * in the root directory of this software component.
00021   * If no LICENSE file comes with this software, it is provided AS-IS.
00022   *
00023   ******************************************************************************
00024   @verbatim
00025   ==============================================================================
00026                         ##### How to use this driver #####
00027   ==============================================================================
00028      [..]
00029      The LTDC HAL driver can be used as follows:
00030 
00031      (#) Declare a LTDC_HandleTypeDef handle structure, for example: LTDC_HandleTypeDef  hltdc;
00032 
00033      (#) Initialize the LTDC low level resources by implementing the HAL_LTDC_MspInit() API:
00034          (##) Enable the LTDC interface clock
00035          (##) NVIC configuration if you need to use interrupt process
00036              (+++) Configure the LTDC interrupt priority
00037              (+++) Enable the NVIC LTDC IRQ Channel
00038 
00039      (#) Initialize the required configuration through the following parameters:
00040          the LTDC timing, the horizontal and vertical polarity, the pixel clock polarity,
00041          Data Enable polarity and the LTDC background color value using HAL_LTDC_Init() function
00042 
00043      *** Configuration ***
00044      =========================
00045      [..]
00046      (#) Program the required configuration through the following parameters:
00047          the pixel format, the blending factors, input alpha value, the window size
00048          and the image size using HAL_LTDC_ConfigLayer() function for foreground
00049          or/and background layer.
00050 
00051      (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
00052          HAL_LTDC_EnableCLUT functions.
00053 
00054      (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
00055 
00056      (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
00057          and HAL_LTDC_EnableColorKeying functions.
00058 
00059      (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineEvent()
00060          function
00061 
00062      (#) If needed, reconfigure and change the pixel format value, the alpha value
00063          value, the window size, the window position and the layer start address
00064          for foreground or/and background layer using respectively the following
00065          functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
00066          HAL_LTDC_SetWindowPosition() and HAL_LTDC_SetAddress().
00067 
00068      (#) Variant functions with _NoReload suffix allows to set the LTDC configuration/settings without immediate reload.
00069          This is useful in case when the program requires to modify serval LTDC settings (on one or both layers)
00070          then applying(reload) these settings in one shot by calling the function HAL_LTDC_Reload().
00071 
00072          After calling the _NoReload functions to set different color/format/layer settings,
00073          the program shall call the function HAL_LTDC_Reload() to apply(reload) these settings.
00074          Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_IMMEDIATE if
00075          an immediate reload is required.
00076          Function HAL_LTDC_Reload() can be called with the parameter ReloadType set to LTDC_RELOAD_VERTICAL_BLANKING if
00077          the reload should be done in the next vertical blanking period,
00078          this option allows to avoid display flicker by applying the new settings during the vertical blanking period.
00079 
00080 
00081      (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
00082 
00083      *** LTDC HAL driver macros list ***
00084      =============================================
00085      [..]
00086        Below the list of most used macros in LTDC HAL driver.
00087 
00088       (+) __HAL_LTDC_ENABLE: Enable the LTDC.
00089       (+) __HAL_LTDC_DISABLE: Disable the LTDC.
00090       (+) __HAL_LTDC_LAYER_ENABLE: Enable an LTDC Layer.
00091       (+) __HAL_LTDC_LAYER_DISABLE: Disable an LTDC Layer.
00092       (+) __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG: Reload  Layer Configuration.
00093       (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
00094       (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
00095       (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
00096       (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
00097       (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
00098 
00099      [..]
00100        (@) You can refer to the LTDC HAL driver header file for more useful macros
00101 
00102 
00103      *** Callback registration ***
00104      =============================================
00105      [..]
00106      The compilation define  USE_HAL_LTDC_REGISTER_CALLBACKS when set to 1
00107      allows the user to configure dynamically the driver callbacks.
00108      Use function HAL_LTDC_RegisterCallback() to register a callback.
00109 
00110     [..]
00111     Function HAL_LTDC_RegisterCallback() allows to register following callbacks:
00112       (+) LineEventCallback   : LTDC Line Event Callback.
00113       (+) ReloadEventCallback : LTDC Reload Event Callback.
00114       (+) ErrorCallback       : LTDC Error Callback
00115       (+) MspInitCallback     : LTDC MspInit.
00116       (+) MspDeInitCallback   : LTDC MspDeInit.
00117     [..]
00118     This function takes as parameters the HAL peripheral handle, the callback ID
00119     and a pointer to the user callback function.
00120 
00121     [..]
00122     Use function HAL_LTDC_UnRegisterCallback() to reset a callback to the default
00123     weak function.
00124     HAL_LTDC_UnRegisterCallback() takes as parameters the HAL peripheral handle
00125     and the callback ID.
00126     [..]
00127     This function allows to reset following callbacks:
00128       (+) LineEventCallback   : LTDC Line Event Callback
00129       (+) ReloadEventCallback : LTDC Reload Event Callback
00130       (+) ErrorCallback       : LTDC Error Callback
00131       (+) MspInitCallback     : LTDC MspInit
00132       (+) MspDeInitCallback   : LTDC MspDeInit.
00133 
00134     [..]
00135     By default, after the HAL_LTDC_Init and when the state is HAL_LTDC_STATE_RESET
00136     all callbacks are set to the corresponding weak functions:
00137     examples HAL_LTDC_LineEventCallback(), HAL_LTDC_ErrorCallback().
00138     Exception done for MspInit and MspDeInit functions that are
00139     reset to the legacy weak (surcharged) functions in the HAL_LTDC_Init() and HAL_LTDC_DeInit()
00140     only when these callbacks are null (not registered beforehand).
00141     If not, MspInit or MspDeInit are not null, the HAL_LTDC_Init() and HAL_LTDC_DeInit()
00142     keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
00143 
00144     [..]
00145     Callbacks can be registered/unregistered in HAL_LTDC_STATE_READY state only.
00146     Exception done MspInit/MspDeInit that can be registered/unregistered
00147     in HAL_LTDC_STATE_READY or HAL_LTDC_STATE_RESET state,
00148     thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
00149     In that case first register the MspInit/MspDeInit user callbacks
00150     using HAL_LTDC_RegisterCallback() before calling HAL_LTDC_DeInit()
00151     or HAL_LTDC_Init() function.
00152 
00153     [..]
00154     When the compilation define USE_HAL_LTDC_REGISTER_CALLBACKS is set to 0 or
00155     not defined, the callback registration feature is not available and all callbacks
00156     are set to the corresponding weak functions.
00157 
00158   @endverbatim
00159   ******************************************************************************
00160   */
00161 
00162 /* Includes ------------------------------------------------------------------*/
00163 #include "stm32l4xx_hal.h"
00164 
00165 /** @addtogroup STM32L4xx_HAL_Driver
00166   * @{
00167   */
00168 
00169 #ifdef HAL_LTDC_MODULE_ENABLED
00170 
00171 #if defined (LTDC)
00172 
00173 /** @defgroup LTDC LTDC
00174   * @brief LTDC HAL module driver
00175   * @{
00176   */
00177 
00178 
00179 /* Private typedef -----------------------------------------------------------*/
00180 /* Private define ------------------------------------------------------------*/
00181 /* Private macro -------------------------------------------------------------*/
00182 /* Private variables ---------------------------------------------------------*/
00183 /* Private function prototypes -----------------------------------------------*/
00184 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
00185 /* Private functions ---------------------------------------------------------*/
00186 
00187 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
00188   * @{
00189   */
00190 
00191 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
00192   *  @brief   Initialization and Configuration functions
00193   *
00194 @verbatim
00195  ===============================================================================
00196                 ##### Initialization and Configuration functions #####
00197  ===============================================================================
00198     [..]  This section provides functions allowing to:
00199       (+) Initialize and configure the LTDC
00200       (+) De-initialize the LTDC
00201 
00202 @endverbatim
00203   * @{
00204   */
00205 
00206 /**
00207   * @brief  Initialize the LTDC according to the specified parameters in the LTDC_InitTypeDef.
00208   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00209   *                the configuration information for the LTDC.
00210   * @retval HAL status
00211   */
00212 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
00213 {
00214   uint32_t tmp, tmp1;
00215 
00216   /* Check the LTDC peripheral state */
00217   if (hltdc == NULL)
00218   {
00219     return HAL_ERROR;
00220   }
00221 
00222   /* Check function parameters */
00223   assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
00224   assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
00225   assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
00226   assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
00227   assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
00228   assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
00229   assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
00230   assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
00231   assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
00232   assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
00233   assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
00234   assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
00235   assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
00236 
00237 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00238   if (hltdc->State == HAL_LTDC_STATE_RESET)
00239   {
00240     /* Allocate lock resource and initialize it */
00241     hltdc->Lock = HAL_UNLOCKED;
00242 
00243     /* Reset the LTDC callback to the legacy weak callbacks */
00244     hltdc->LineEventCallback   = HAL_LTDC_LineEventCallback;    /* Legacy weak LineEventCallback    */
00245     hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback;  /* Legacy weak ReloadEventCallback  */
00246     hltdc->ErrorCallback       = HAL_LTDC_ErrorCallback;        /* Legacy weak ErrorCallback        */
00247 
00248     if (hltdc->MspInitCallback == NULL)
00249     {
00250       hltdc->MspInitCallback = HAL_LTDC_MspInit;
00251     }
00252     /* Init the low level hardware */
00253     hltdc->MspInitCallback(hltdc);
00254   }
00255 #else
00256   if (hltdc->State == HAL_LTDC_STATE_RESET)
00257   {
00258     /* Allocate lock resource and initialize it */
00259     hltdc->Lock = HAL_UNLOCKED;
00260     /* Init the low level hardware */
00261     HAL_LTDC_MspInit(hltdc);
00262   }
00263 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00264 
00265   /* Change LTDC peripheral state */
00266   hltdc->State = HAL_LTDC_STATE_BUSY;
00267 
00268   /* Configure the HS, VS, DE and PC polarity */
00269   hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
00270   hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
00271                                      hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
00272 
00273   /* Set Synchronization size */
00274   hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
00275   tmp = (hltdc->Init.HorizontalSync << 16U);
00276   hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
00277 
00278   /* Set Accumulated Back porch */
00279   hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
00280   tmp = (hltdc->Init.AccumulatedHBP << 16U);
00281   hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
00282 
00283   /* Set Accumulated Active Width */
00284   hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
00285   tmp = (hltdc->Init.AccumulatedActiveW << 16U);
00286   hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
00287 
00288   /* Set Total Width */
00289   hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
00290   tmp = (hltdc->Init.TotalWidth << 16U);
00291   hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
00292 
00293   /* Set the background color value */
00294   tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8U);
00295   tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16U);
00296   hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
00297   hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
00298 
00299   /* Enable the Transfer Error and FIFO underrun interrupts */
00300   __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE | LTDC_IT_FU);
00301 
00302   /* Enable LTDC by setting LTDCEN bit */
00303   __HAL_LTDC_ENABLE(hltdc);
00304 
00305   /* Initialize the error code */
00306   hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
00307 
00308   /* Initialize the LTDC state*/
00309   hltdc->State = HAL_LTDC_STATE_READY;
00310 
00311   return HAL_OK;
00312 }
00313 
00314 /**
00315   * @brief  De-initialize the LTDC peripheral.
00316   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00317   *                the configuration information for the LTDC.
00318   * @retval None
00319   */
00320 
00321 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
00322 {
00323 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00324   if (hltdc->MspDeInitCallback == NULL)
00325   {
00326     hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit;
00327   }
00328   /* DeInit the low level hardware */
00329   hltdc->MspDeInitCallback(hltdc);
00330 #else
00331   /* DeInit the low level hardware */
00332   HAL_LTDC_MspDeInit(hltdc);
00333 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00334 
00335   /* Initialize the error code */
00336   hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
00337 
00338   /* Initialize the LTDC state*/
00339   hltdc->State = HAL_LTDC_STATE_RESET;
00340 
00341   /* Release Lock */
00342   __HAL_UNLOCK(hltdc);
00343 
00344   return HAL_OK;
00345 }
00346 
00347 /**
00348   * @brief  Initialize the LTDC MSP.
00349   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00350   *                the configuration information for the LTDC.
00351   * @retval None
00352   */
00353 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
00354 {
00355   /* Prevent unused argument(s) compilation warning */
00356   UNUSED(hltdc);
00357 
00358   /* NOTE : This function should not be modified, when the callback is needed,
00359             the HAL_LTDC_MspInit could be implemented in the user file
00360    */
00361 }
00362 
00363 /**
00364   * @brief  De-initialize the LTDC MSP.
00365   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00366   *                the configuration information for the LTDC.
00367   * @retval None
00368   */
00369 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc)
00370 {
00371   /* Prevent unused argument(s) compilation warning */
00372   UNUSED(hltdc);
00373 
00374   /* NOTE : This function should not be modified, when the callback is needed,
00375             the HAL_LTDC_MspDeInit could be implemented in the user file
00376    */
00377 }
00378 
00379 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00380 /**
00381   * @brief  Register a User LTDC Callback
00382   *         To be used instead of the weak predefined callback
00383   * @param hltdc ltdc handle
00384   * @param CallbackID ID of the callback to be registered
00385   *        This parameter can be one of the following values:
00386   *          @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
00387   *          @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
00388   *          @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
00389   *          @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
00390   *          @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
00391   * @param pCallback pointer to the Callback function
00392   * @retval status
00393   */
00394 HAL_StatusTypeDef HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID, pLTDC_CallbackTypeDef pCallback)
00395 {
00396   HAL_StatusTypeDef status = HAL_OK;
00397 
00398   if (pCallback == NULL)
00399   {
00400     /* Update the error code */
00401     hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00402 
00403     return HAL_ERROR;
00404   }
00405   /* Process locked */
00406   __HAL_LOCK(hltdc);
00407 
00408   if (hltdc->State == HAL_LTDC_STATE_READY)
00409   {
00410     switch (CallbackID)
00411     {
00412       case HAL_LTDC_LINE_EVENT_CB_ID :
00413         hltdc->LineEventCallback = pCallback;
00414         break;
00415 
00416       case HAL_LTDC_RELOAD_EVENT_CB_ID :
00417         hltdc->ReloadEventCallback = pCallback;
00418         break;
00419 
00420       case HAL_LTDC_ERROR_CB_ID :
00421         hltdc->ErrorCallback = pCallback;
00422         break;
00423 
00424       case HAL_LTDC_MSPINIT_CB_ID :
00425         hltdc->MspInitCallback = pCallback;
00426         break;
00427 
00428       case HAL_LTDC_MSPDEINIT_CB_ID :
00429         hltdc->MspDeInitCallback = pCallback;
00430         break;
00431 
00432       default :
00433         /* Update the error code */
00434         hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00435         /* Return error status */
00436         status =  HAL_ERROR;
00437         break;
00438     }
00439   }
00440   else if (hltdc->State == HAL_LTDC_STATE_RESET)
00441   {
00442     switch (CallbackID)
00443     {
00444       case HAL_LTDC_MSPINIT_CB_ID :
00445         hltdc->MspInitCallback = pCallback;
00446         break;
00447 
00448       case HAL_LTDC_MSPDEINIT_CB_ID :
00449         hltdc->MspDeInitCallback = pCallback;
00450         break;
00451 
00452       default :
00453         /* Update the error code */
00454         hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00455         /* Return error status */
00456         status =  HAL_ERROR;
00457         break;
00458     }
00459   }
00460   else
00461   {
00462     /* Update the error code */
00463     hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00464     /* Return error status */
00465     status =  HAL_ERROR;
00466   }
00467 
00468   /* Release Lock */
00469   __HAL_UNLOCK(hltdc);
00470 
00471   return status;
00472 }
00473 
00474 /**
00475   * @brief  Unregister an LTDC Callback
00476   *         LTDC callabck is redirected to the weak predefined callback
00477   * @param hltdc ltdc handle
00478   * @param CallbackID ID of the callback to be unregistered
00479   *        This parameter can be one of the following values:
00480   *          @arg @ref HAL_LTDC_LINE_EVENT_CB_ID Line Event Callback ID
00481   *          @arg @ref HAL_LTDC_RELOAD_EVENT_CB_ID Reload Event Callback ID
00482   *          @arg @ref HAL_LTDC_ERROR_CB_ID Error Callback ID
00483   *          @arg @ref HAL_LTDC_MSPINIT_CB_ID MspInit callback ID
00484   *          @arg @ref HAL_LTDC_MSPDEINIT_CB_ID MspDeInit callback ID
00485   * @retval status
00486   */
00487 HAL_StatusTypeDef HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID)
00488 {
00489   HAL_StatusTypeDef status = HAL_OK;
00490 
00491   /* Process locked */
00492   __HAL_LOCK(hltdc);
00493 
00494   if (hltdc->State == HAL_LTDC_STATE_READY)
00495   {
00496     switch (CallbackID)
00497     {
00498       case HAL_LTDC_LINE_EVENT_CB_ID :
00499         hltdc->LineEventCallback = HAL_LTDC_LineEventCallback;      /* Legacy weak LineEventCallback    */
00500         break;
00501 
00502       case HAL_LTDC_RELOAD_EVENT_CB_ID :
00503         hltdc->ReloadEventCallback = HAL_LTDC_ReloadEventCallback;  /* Legacy weak ReloadEventCallback  */
00504         break;
00505 
00506       case HAL_LTDC_ERROR_CB_ID :
00507         hltdc->ErrorCallback       = HAL_LTDC_ErrorCallback;        /* Legacy weak ErrorCallback        */
00508         break;
00509 
00510       case HAL_LTDC_MSPINIT_CB_ID :
00511         hltdc->MspInitCallback = HAL_LTDC_MspInit;                  /* Legcay weak MspInit Callback     */
00512         break;
00513 
00514       case HAL_LTDC_MSPDEINIT_CB_ID :
00515         hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit;              /* Legcay weak MspDeInit Callback     */
00516         break;
00517 
00518       default :
00519         /* Update the error code */
00520         hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00521         /* Return error status */
00522         status =  HAL_ERROR;
00523         break;
00524     }
00525   }
00526   else if (hltdc->State == HAL_LTDC_STATE_RESET)
00527   {
00528     switch (CallbackID)
00529     {
00530       case HAL_LTDC_MSPINIT_CB_ID :
00531         hltdc->MspInitCallback = HAL_LTDC_MspInit;                  /* Legcay weak MspInit Callback     */
00532         break;
00533 
00534       case HAL_LTDC_MSPDEINIT_CB_ID :
00535         hltdc->MspDeInitCallback = HAL_LTDC_MspDeInit;              /* Legcay weak MspDeInit Callback     */
00536         break;
00537 
00538       default :
00539         /* Update the error code */
00540         hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00541         /* Return error status */
00542         status =  HAL_ERROR;
00543         break;
00544     }
00545   }
00546   else
00547   {
00548     /* Update the error code */
00549     hltdc->ErrorCode |= HAL_LTDC_ERROR_INVALID_CALLBACK;
00550     /* Return error status */
00551     status =  HAL_ERROR;
00552   }
00553 
00554   /* Release Lock */
00555   __HAL_UNLOCK(hltdc);
00556 
00557   return status;
00558 }
00559 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00560 
00561 /**
00562   * @}
00563   */
00564 
00565 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
00566   *  @brief   IO operation functions
00567   *
00568 @verbatim
00569  ===============================================================================
00570                       #####  IO operation functions  #####
00571  ===============================================================================
00572     [..]  This section provides function allowing to:
00573       (+) Handle LTDC interrupt request
00574 
00575 @endverbatim
00576   * @{
00577   */
00578 /**
00579   * @brief  Handle LTDC interrupt request.
00580   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00581   *                the configuration information for the LTDC.
00582   * @retval HAL status
00583   */
00584 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
00585 {
00586   uint32_t isrflags  = READ_REG(hltdc->Instance->ISR);
00587   uint32_t itsources = READ_REG(hltdc->Instance->IER);
00588 
00589   /* Transfer Error Interrupt management ***************************************/
00590   if (((isrflags & LTDC_ISR_TERRIF) != 0U) && ((itsources & LTDC_IER_TERRIE) != 0U))
00591   {
00592     /* Disable the transfer Error interrupt */
00593     __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
00594 
00595     /* Clear the transfer error flag */
00596     __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
00597 
00598     /* Update error code */
00599     hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
00600 
00601     /* Change LTDC state */
00602     hltdc->State = HAL_LTDC_STATE_ERROR;
00603 
00604     /* Process unlocked */
00605     __HAL_UNLOCK(hltdc);
00606 
00607     /* Transfer error Callback */
00608 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00609     /*Call registered error callback*/
00610     hltdc->ErrorCallback(hltdc);
00611 #else
00612     /* Call legacy error callback*/
00613     HAL_LTDC_ErrorCallback(hltdc);
00614 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00615   }
00616 
00617   /* FIFO underrun Interrupt management ***************************************/
00618   if (((isrflags & LTDC_ISR_FUIF) != 0U) && ((itsources & LTDC_IER_FUIE) != 0U))
00619   {
00620     /* Disable the FIFO underrun interrupt */
00621     __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
00622 
00623     /* Clear the FIFO underrun flag */
00624     __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
00625 
00626     /* Update error code */
00627     hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
00628 
00629     /* Change LTDC state */
00630     hltdc->State = HAL_LTDC_STATE_ERROR;
00631 
00632     /* Process unlocked */
00633     __HAL_UNLOCK(hltdc);
00634 
00635     /* Transfer error Callback */
00636 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00637     /*Call registered error callback*/
00638     hltdc->ErrorCallback(hltdc);
00639 #else
00640     /* Call legacy error callback*/
00641     HAL_LTDC_ErrorCallback(hltdc);
00642 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00643   }
00644 
00645   /* Line Interrupt management ************************************************/
00646   if (((isrflags & LTDC_ISR_LIF) != 0U) && ((itsources & LTDC_IER_LIE) != 0U))
00647   {
00648     /* Disable the Line interrupt */
00649     __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
00650 
00651     /* Clear the Line interrupt flag */
00652     __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
00653 
00654     /* Change LTDC state */
00655     hltdc->State = HAL_LTDC_STATE_READY;
00656 
00657     /* Process unlocked */
00658     __HAL_UNLOCK(hltdc);
00659 
00660     /* Line interrupt Callback */
00661 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00662     /*Call registered Line Event callback */
00663     hltdc->LineEventCallback(hltdc);
00664 #else
00665     /*Call Legacy Line Event callback */
00666     HAL_LTDC_LineEventCallback(hltdc);
00667 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00668   }
00669 
00670   /* Register reload Interrupt management ***************************************/
00671   if (((isrflags & LTDC_ISR_RRIF) != 0U) && ((itsources & LTDC_IER_RRIE) != 0U))
00672   {
00673     /* Disable the register reload interrupt */
00674     __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_RR);
00675 
00676     /* Clear the register reload flag */
00677     __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_RR);
00678 
00679     /* Change LTDC state */
00680     hltdc->State = HAL_LTDC_STATE_READY;
00681 
00682     /* Process unlocked */
00683     __HAL_UNLOCK(hltdc);
00684 
00685     /* Reload interrupt Callback */
00686 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
00687     /*Call registered reload Event callback */
00688     hltdc->ReloadEventCallback(hltdc);
00689 #else
00690     /*Call Legacy Reload Event callback */
00691     HAL_LTDC_ReloadEventCallback(hltdc);
00692 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */
00693   }
00694 }
00695 
00696 /**
00697   * @brief  Error LTDC callback.
00698   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00699   *                the configuration information for the LTDC.
00700   * @retval None
00701   */
00702 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
00703 {
00704   /* Prevent unused argument(s) compilation warning */
00705   UNUSED(hltdc);
00706 
00707   /* NOTE : This function should not be modified, when the callback is needed,
00708             the HAL_LTDC_ErrorCallback could be implemented in the user file
00709    */
00710 }
00711 
00712 /**
00713   * @brief  Line Event callback.
00714   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00715   *                the configuration information for the LTDC.
00716   * @retval None
00717   */
00718 __weak void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
00719 {
00720   /* Prevent unused argument(s) compilation warning */
00721   UNUSED(hltdc);
00722 
00723   /* NOTE : This function should not be modified, when the callback is needed,
00724             the HAL_LTDC_LineEventCallback could be implemented in the user file
00725    */
00726 }
00727 
00728 /**
00729   * @brief  Reload Event callback.
00730   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
00731   *                the configuration information for the LTDC.
00732   * @retval None
00733   */
00734 __weak void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc)
00735 {
00736   /* Prevent unused argument(s) compilation warning */
00737   UNUSED(hltdc);
00738 
00739   /* NOTE : This function should not be modified, when the callback is needed,
00740             the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
00741    */
00742 }
00743 
00744 /**
00745   * @}
00746   */
00747 
00748 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
00749   *  @brief    Peripheral Control functions
00750   *
00751 @verbatim
00752  ===============================================================================
00753                     ##### Peripheral Control functions #####
00754  ===============================================================================
00755     [..]  This section provides functions allowing to:
00756       (+) Configure the LTDC foreground or/and background parameters.
00757       (+) Set the active layer.
00758       (+) Configure the color keying.
00759       (+) Configure the C-LUT.
00760       (+) Enable / Disable the color keying.
00761       (+) Enable / Disable the C-LUT.
00762       (+) Update the layer position.
00763       (+) Update the layer size.
00764       (+) Update pixel format on the fly.
00765       (+) Update transparency on the fly.
00766       (+) Update address on the fly.
00767 
00768 @endverbatim
00769   * @{
00770   */
00771 
00772 /**
00773   * @brief  Configure the LTDC Layer according to the specified
00774   *         parameters in the LTDC_InitTypeDef and create the associated handle.
00775   * @param  hltdc      pointer to a LTDC_HandleTypeDef structure that contains
00776   *                    the configuration information for the LTDC.
00777   * @param  pLayerCfg  pointer to a LTDC_LayerCfgTypeDef structure that contains
00778   *                    the configuration information for the Layer.
00779   * @param  LayerIdx  LTDC Layer index.
00780   *                    This parameter can be one of the following values:
00781   *                    LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00782   * @retval HAL status
00783   */
00784 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
00785 {
00786   /* Check the parameters */
00787   assert_param(IS_LTDC_LAYER(LayerIdx));
00788   assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
00789   assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
00790   assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
00791   assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
00792   assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
00793   assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
00794   assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
00795   assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
00796   assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
00797   assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
00798   assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
00799 
00800   /* Process locked */
00801   __HAL_LOCK(hltdc);
00802 
00803   /* Change LTDC peripheral state */
00804   hltdc->State = HAL_LTDC_STATE_BUSY;
00805 
00806   /* Copy new layer configuration into handle structure */
00807   hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
00808 
00809   /* Configure the LTDC Layer */
00810   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
00811 
00812   /* Set the Immediate Reload type */
00813   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
00814 
00815   /* Initialize the LTDC state*/
00816   hltdc->State  = HAL_LTDC_STATE_READY;
00817 
00818   /* Process unlocked */
00819   __HAL_UNLOCK(hltdc);
00820 
00821   return HAL_OK;
00822 }
00823 
00824 /**
00825   * @brief  Configure the color keying.
00826   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
00827   *                   the configuration information for the LTDC.
00828   * @param  RGBValue  the color key value
00829   * @param  LayerIdx  LTDC Layer index.
00830   *                   This parameter can be one of the following values:
00831   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00832   * @retval HAL status
00833   */
00834 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
00835 {
00836   /* Check the parameters */
00837   assert_param(IS_LTDC_LAYER(LayerIdx));
00838 
00839   /* Process locked */
00840   __HAL_LOCK(hltdc);
00841 
00842   /* Change LTDC peripheral state */
00843   hltdc->State = HAL_LTDC_STATE_BUSY;
00844 
00845   /* Configure the default color values */
00846   LTDC_LAYER(hltdc, LayerIdx)->CKCR &=  ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
00847   LTDC_LAYER(hltdc, LayerIdx)->CKCR  = RGBValue;
00848 
00849   /* Set the Immediate Reload type */
00850   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
00851 
00852   /* Change the LTDC state*/
00853   hltdc->State = HAL_LTDC_STATE_READY;
00854 
00855   /* Process unlocked */
00856   __HAL_UNLOCK(hltdc);
00857 
00858   return HAL_OK;
00859 }
00860 
00861 /**
00862   * @brief  Load the color lookup table.
00863   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
00864   *                   the configuration information for the LTDC.
00865   * @param  pCLUT     pointer to the color lookup table address.
00866   * @param  CLUTSize  the color lookup table size.
00867   * @param  LayerIdx  LTDC Layer index.
00868   *                   This parameter can be one of the following values:
00869   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00870   * @retval HAL status
00871   */
00872 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
00873 {
00874   uint32_t tmp;
00875   uint32_t counter;
00876   uint32_t *pcolorlut = pCLUT;
00877   /* Check the parameters */
00878   assert_param(IS_LTDC_LAYER(LayerIdx));
00879 
00880   /* Process locked */
00881   __HAL_LOCK(hltdc);
00882 
00883   /* Change LTDC peripheral state */
00884   hltdc->State = HAL_LTDC_STATE_BUSY;
00885 
00886   for (counter = 0U; (counter < CLUTSize); counter++)
00887   {
00888     if (hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
00889     {
00890       tmp  = (((counter + (16U*counter)) << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
00891     }
00892     else
00893     {
00894       tmp  = ((counter << 24U) | ((uint32_t)(*pcolorlut) & 0xFFU) | ((uint32_t)(*pcolorlut) & 0xFF00U) | ((uint32_t)(*pcolorlut) & 0xFF0000U));
00895     }
00896 
00897     pcolorlut++;
00898 
00899     /* Specifies the C-LUT address and RGB value */
00900     LTDC_LAYER(hltdc, LayerIdx)->CLUTWR  = tmp;
00901   }
00902 
00903   /* Change the LTDC state*/
00904   hltdc->State = HAL_LTDC_STATE_READY;
00905 
00906   /* Process unlocked */
00907   __HAL_UNLOCK(hltdc);
00908 
00909   return HAL_OK;
00910 }
00911 
00912 /**
00913   * @brief  Enable the color keying.
00914   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
00915   *                   the configuration information for the LTDC.
00916   * @param  LayerIdx  LTDC Layer index.
00917   *                   This parameter can be one of the following values:
00918   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00919   * @retval  HAL status
00920   */
00921 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
00922 {
00923   /* Check the parameters */
00924   assert_param(IS_LTDC_LAYER(LayerIdx));
00925 
00926   /* Process locked */
00927   __HAL_LOCK(hltdc);
00928 
00929   /* Change LTDC peripheral state */
00930   hltdc->State = HAL_LTDC_STATE_BUSY;
00931 
00932   /* Enable LTDC color keying by setting COLKEN bit */
00933   LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
00934 
00935   /* Set the Immediate Reload type */
00936   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
00937 
00938   /* Change the LTDC state*/
00939   hltdc->State = HAL_LTDC_STATE_READY;
00940 
00941   /* Process unlocked */
00942   __HAL_UNLOCK(hltdc);
00943 
00944   return HAL_OK;
00945 }
00946 
00947 /**
00948   * @brief  Disable the color keying.
00949   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
00950   *                   the configuration information for the LTDC.
00951   * @param  LayerIdx  LTDC Layer index.
00952   *                   This parameter can be one of the following values:
00953   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00954   * @retval  HAL status
00955   */
00956 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
00957 {
00958   /* Check the parameters */
00959   assert_param(IS_LTDC_LAYER(LayerIdx));
00960 
00961   /* Process locked */
00962   __HAL_LOCK(hltdc);
00963 
00964   /* Change LTDC peripheral state */
00965   hltdc->State = HAL_LTDC_STATE_BUSY;
00966 
00967   /* Disable LTDC color keying by setting COLKEN bit */
00968   LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
00969 
00970   /* Set the Immediate Reload type */
00971   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
00972 
00973   /* Change the LTDC state*/
00974   hltdc->State = HAL_LTDC_STATE_READY;
00975 
00976   /* Process unlocked */
00977   __HAL_UNLOCK(hltdc);
00978 
00979   return HAL_OK;
00980 }
00981 
00982 /**
00983   * @brief  Enable the color lookup table.
00984   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
00985   *                   the configuration information for the LTDC.
00986   * @param  LayerIdx  LTDC Layer index.
00987   *                   This parameter can be one of the following values:
00988   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
00989   * @retval  HAL status
00990   */
00991 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
00992 {
00993   /* Check the parameters */
00994   assert_param(IS_LTDC_LAYER(LayerIdx));
00995 
00996   /* Process locked */
00997   __HAL_LOCK(hltdc);
00998 
00999   /* Change LTDC peripheral state */
01000   hltdc->State = HAL_LTDC_STATE_BUSY;
01001 
01002   /* Enable LTDC color lookup table by setting CLUTEN bit */
01003   LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
01004 
01005   /* Set the Immediate Reload type */
01006   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01007 
01008   /* Change the LTDC state*/
01009   hltdc->State = HAL_LTDC_STATE_READY;
01010 
01011   /* Process unlocked */
01012   __HAL_UNLOCK(hltdc);
01013 
01014   return HAL_OK;
01015 }
01016 
01017 /**
01018   * @brief  Disable the color lookup table.
01019   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01020   *                   the configuration information for the LTDC.
01021   * @param  LayerIdx  LTDC Layer index.
01022   *                   This parameter can be one of the following values:
01023   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01024   * @retval  HAL status
01025   */
01026 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
01027 {
01028   /* Check the parameters */
01029   assert_param(IS_LTDC_LAYER(LayerIdx));
01030 
01031   /* Process locked */
01032   __HAL_LOCK(hltdc);
01033 
01034   /* Change LTDC peripheral state */
01035   hltdc->State = HAL_LTDC_STATE_BUSY;
01036 
01037   /* Disable LTDC color lookup table by setting CLUTEN bit */
01038   LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
01039 
01040   /* Set the Immediate Reload type */
01041   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01042 
01043   /* Change the LTDC state*/
01044   hltdc->State = HAL_LTDC_STATE_READY;
01045 
01046   /* Process unlocked */
01047   __HAL_UNLOCK(hltdc);
01048 
01049   return HAL_OK;
01050 }
01051 
01052 /**
01053   * @brief  Enable Dither.
01054   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
01055   *                the configuration information for the LTDC.
01056   * @retval  HAL status
01057   */
01058 
01059 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
01060 {
01061   /* Process locked */
01062   __HAL_LOCK(hltdc);
01063 
01064   /* Change LTDC peripheral state */
01065   hltdc->State = HAL_LTDC_STATE_BUSY;
01066 
01067   /* Enable Dither by setting DTEN bit */
01068   LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
01069 
01070   /* Change the LTDC state*/
01071   hltdc->State = HAL_LTDC_STATE_READY;
01072 
01073   /* Process unlocked */
01074   __HAL_UNLOCK(hltdc);
01075 
01076   return HAL_OK;
01077 }
01078 
01079 /**
01080   * @brief  Disable Dither.
01081   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
01082   *                the configuration information for the LTDC.
01083   * @retval  HAL status
01084   */
01085 
01086 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
01087 {
01088   /* Process locked */
01089   __HAL_LOCK(hltdc);
01090 
01091   /* Change LTDC peripheral state */
01092   hltdc->State = HAL_LTDC_STATE_BUSY;
01093 
01094   /* Disable Dither by setting DTEN bit */
01095   LTDC->GCR &= ~(uint32_t)LTDC_GCR_DEN;
01096 
01097   /* Change the LTDC state*/
01098   hltdc->State = HAL_LTDC_STATE_READY;
01099 
01100   /* Process unlocked */
01101   __HAL_UNLOCK(hltdc);
01102 
01103   return HAL_OK;
01104 }
01105 
01106 /**
01107   * @brief  Set the LTDC window size.
01108   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01109   *                   the configuration information for the LTDC.
01110   * @param  XSize     LTDC Pixel per line
01111   * @param  YSize     LTDC Line number
01112   * @param  LayerIdx  LTDC Layer index.
01113   *                   This parameter can be one of the following values:
01114   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01115   * @retval  HAL status
01116   */
01117 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
01118 {
01119   LTDC_LayerCfgTypeDef *pLayerCfg;
01120 
01121   /* Check the parameters (Layers parameters)*/
01122   assert_param(IS_LTDC_LAYER(LayerIdx));
01123   assert_param(IS_LTDC_CFBLL(XSize));
01124   assert_param(IS_LTDC_CFBLNBR(YSize));
01125 
01126   /* Process locked */
01127   __HAL_LOCK(hltdc);
01128 
01129   /* Change LTDC peripheral state */
01130   hltdc->State = HAL_LTDC_STATE_BUSY;
01131 
01132   /* Get layer configuration from handle structure */
01133   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01134 
01135   /* update horizontal stop */
01136   pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
01137 
01138   /* update vertical stop */
01139   pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
01140 
01141   /* Reconfigures the color frame buffer pitch in byte */
01142   pLayerCfg->ImageWidth = XSize;
01143 
01144   /* Reconfigures the frame buffer line number */
01145   pLayerCfg->ImageHeight = YSize;
01146 
01147   /* Set LTDC parameters */
01148   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01149 
01150   /* Set the Immediate Reload type */
01151   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01152 
01153   /* Change the LTDC state*/
01154   hltdc->State = HAL_LTDC_STATE_READY;
01155 
01156   /* Process unlocked */
01157   __HAL_UNLOCK(hltdc);
01158 
01159   return HAL_OK;
01160 }
01161 
01162 /**
01163   * @brief  Set the LTDC window position.
01164   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01165   *                   the configuration information for the LTDC.
01166   * @param  X0        LTDC window X offset
01167   * @param  Y0        LTDC window Y offset
01168   * @param  LayerIdx  LTDC Layer index.
01169   *                         This parameter can be one of the following values:
01170   *                         LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01171   * @retval  HAL status
01172   */
01173 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
01174 {
01175   LTDC_LayerCfgTypeDef *pLayerCfg;
01176 
01177   /* Check the parameters */
01178   assert_param(IS_LTDC_LAYER(LayerIdx));
01179   assert_param(IS_LTDC_CFBLL(X0));
01180   assert_param(IS_LTDC_CFBLNBR(Y0));
01181 
01182   /* Process locked */
01183   __HAL_LOCK(hltdc);
01184 
01185   /* Change LTDC peripheral state */
01186   hltdc->State = HAL_LTDC_STATE_BUSY;
01187 
01188   /* Get layer configuration from handle structure */
01189   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01190 
01191   /* update horizontal start/stop */
01192   pLayerCfg->WindowX0 = X0;
01193   pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
01194 
01195   /* update vertical start/stop */
01196   pLayerCfg->WindowY0 = Y0;
01197   pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
01198 
01199   /* Set LTDC parameters */
01200   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01201 
01202   /* Set the Immediate Reload type */
01203   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01204 
01205   /* Change the LTDC state*/
01206   hltdc->State = HAL_LTDC_STATE_READY;
01207 
01208   /* Process unlocked */
01209   __HAL_UNLOCK(hltdc);
01210 
01211   return HAL_OK;
01212 }
01213 
01214 /**
01215   * @brief  Reconfigure the pixel format.
01216   * @param  hltdc        pointer to a LTDC_HandleTypeDef structure that contains
01217   *                      the configuration information for the LTDC.
01218   * @param  Pixelformat  new pixel format value.
01219   * @param  LayerIdx     LTDC Layer index.
01220   *                      This parameter can be one of the following values:
01221   *                      LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
01222   * @retval  HAL status
01223   */
01224 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
01225 {
01226   LTDC_LayerCfgTypeDef *pLayerCfg;
01227 
01228   /* Check the parameters */
01229   assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
01230   assert_param(IS_LTDC_LAYER(LayerIdx));
01231 
01232   /* Process locked */
01233   __HAL_LOCK(hltdc);
01234 
01235   /* Change LTDC peripheral state */
01236   hltdc->State = HAL_LTDC_STATE_BUSY;
01237 
01238   /* Get layer configuration from handle structure */
01239   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01240 
01241   /* Reconfigure the pixel format */
01242   pLayerCfg->PixelFormat = Pixelformat;
01243 
01244   /* Set LTDC parameters */
01245   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01246 
01247   /* Set the Immediate Reload type */
01248   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01249 
01250   /* Change the LTDC state*/
01251   hltdc->State = HAL_LTDC_STATE_READY;
01252 
01253   /* Process unlocked */
01254   __HAL_UNLOCK(hltdc);
01255 
01256   return HAL_OK;
01257 }
01258 
01259 /**
01260   * @brief  Reconfigure the layer alpha value.
01261   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01262   *                   the configuration information for the LTDC.
01263   * @param  Alpha     new alpha value.
01264   * @param  LayerIdx  LTDC Layer index.
01265   *                   This parameter can be one of the following values:
01266   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01267   * @retval  HAL status
01268   */
01269 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
01270 {
01271   LTDC_LayerCfgTypeDef *pLayerCfg;
01272 
01273   /* Check the parameters */
01274   assert_param(IS_LTDC_ALPHA(Alpha));
01275   assert_param(IS_LTDC_LAYER(LayerIdx));
01276 
01277   /* Process locked */
01278   __HAL_LOCK(hltdc);
01279 
01280   /* Change LTDC peripheral state */
01281   hltdc->State = HAL_LTDC_STATE_BUSY;
01282 
01283   /* Get layer configuration from handle structure */
01284   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01285 
01286   /* Reconfigure the Alpha value */
01287   pLayerCfg->Alpha = Alpha;
01288 
01289   /* Set LTDC parameters */
01290   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01291 
01292   /* Set the Immediate Reload type */
01293   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01294 
01295   /* Change the LTDC state*/
01296   hltdc->State = HAL_LTDC_STATE_READY;
01297 
01298   /* Process unlocked */
01299   __HAL_UNLOCK(hltdc);
01300 
01301   return HAL_OK;
01302 }
01303 /**
01304   * @brief  Reconfigure the frame buffer Address.
01305   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01306   *                   the configuration information for the LTDC.
01307   * @param  Address   new address value.
01308   * @param  LayerIdx  LTDC Layer index.
01309   *                   This parameter can be one of the following values:
01310   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
01311   * @retval  HAL status
01312   */
01313 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
01314 {
01315   LTDC_LayerCfgTypeDef *pLayerCfg;
01316 
01317   /* Check the parameters */
01318   assert_param(IS_LTDC_LAYER(LayerIdx));
01319 
01320   /* Process locked */
01321   __HAL_LOCK(hltdc);
01322 
01323   /* Change LTDC peripheral state */
01324   hltdc->State = HAL_LTDC_STATE_BUSY;
01325 
01326   /* Get layer configuration from handle structure */
01327   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01328 
01329   /* Reconfigure the Address */
01330   pLayerCfg->FBStartAdress = Address;
01331 
01332   /* Set LTDC parameters */
01333   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01334 
01335   /* Set the Immediate Reload type */
01336   hltdc->Instance->SRCR = LTDC_SRCR_IMR;
01337 
01338   /* Change the LTDC state*/
01339   hltdc->State = HAL_LTDC_STATE_READY;
01340 
01341   /* Process unlocked */
01342   __HAL_UNLOCK(hltdc);
01343 
01344   return HAL_OK;
01345 }
01346 
01347 /**
01348   * @brief  Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
01349   *         larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
01350   *         want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
01351   *         will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
01352   * @note   This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
01353   *         configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
01354   * @param  hltdc              pointer to a LTDC_HandleTypeDef structure that contains
01355   *                            the configuration information for the LTDC.
01356   * @param  LinePitchInPixels  New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
01357   * @param  LayerIdx           LTDC layer index concerned by the modification of line pitch.
01358   * @retval HAL status
01359   */
01360 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
01361 {
01362   uint32_t tmp;
01363   uint32_t pitchUpdate;
01364   uint32_t pixelFormat;
01365 
01366   /* Check the parameters */
01367   assert_param(IS_LTDC_LAYER(LayerIdx));
01368 
01369   /* Process locked */
01370   __HAL_LOCK(hltdc);
01371 
01372   /* Change LTDC peripheral state */
01373   hltdc->State = HAL_LTDC_STATE_BUSY;
01374 
01375   /* get LayerIdx used pixel format */
01376   pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
01377 
01378   if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
01379   {
01380     tmp = 4U;
01381   }
01382   else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
01383   {
01384     tmp = 3U;
01385   }
01386   else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
01387            (pixelFormat == LTDC_PIXEL_FORMAT_RGB565)   || \
01388            (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
01389            (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
01390   {
01391     tmp = 2U;
01392   }
01393   else
01394   {
01395     tmp = 1U;
01396   }
01397 
01398   pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
01399 
01400   /* Clear previously set standard pitch */
01401   LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
01402 
01403   /* Set the Reload type as immediate update of LTDC pitch configured above */
01404   LTDC->SRCR |= LTDC_SRCR_IMR;
01405 
01406   /* Set new line pitch value */
01407   LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
01408 
01409   /* Set the Reload type as immediate update of LTDC pitch configured above */
01410   LTDC->SRCR |= LTDC_SRCR_IMR;
01411 
01412   /* Change the LTDC state*/
01413   hltdc->State = HAL_LTDC_STATE_READY;
01414 
01415   /* Process unlocked */
01416   __HAL_UNLOCK(hltdc);
01417 
01418   return HAL_OK;
01419 }
01420 
01421 /**
01422   * @brief  Define the position of the line interrupt.
01423   * @param  hltdc   pointer to a LTDC_HandleTypeDef structure that contains
01424   *                 the configuration information for the LTDC.
01425   * @param  Line    Line Interrupt Position.
01426   * @note   User application may resort to HAL_LTDC_LineEventCallback() at line interrupt generation.
01427   * @retval  HAL status
01428   */
01429 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
01430 {
01431   /* Check the parameters */
01432   assert_param(IS_LTDC_LIPOS(Line));
01433 
01434   /* Process locked */
01435   __HAL_LOCK(hltdc);
01436 
01437   /* Change LTDC peripheral state */
01438   hltdc->State = HAL_LTDC_STATE_BUSY;
01439 
01440   /* Disable the Line interrupt */
01441   __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
01442 
01443   /* Set the Line Interrupt position */
01444   LTDC->LIPCR = (uint32_t)Line;
01445 
01446   /* Enable the Line interrupt */
01447   __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
01448 
01449   /* Change the LTDC state*/
01450   hltdc->State = HAL_LTDC_STATE_READY;
01451 
01452   /* Process unlocked */
01453   __HAL_UNLOCK(hltdc);
01454 
01455   return HAL_OK;
01456 }
01457 
01458 /**
01459   * @brief  Reload LTDC Layers configuration.
01460   * @param  hltdc      pointer to a LTDC_HandleTypeDef structure that contains
01461   *                    the configuration information for the LTDC.
01462   * @param  ReloadType This parameter can be one of the following values :
01463   *                      LTDC_RELOAD_IMMEDIATE : Immediate Reload
01464   *                      LTDC_RELOAD_VERTICAL_BLANKING  : Reload in the next Vertical Blanking
01465   * @note   User application may resort to HAL_LTDC_ReloadEventCallback() at reload interrupt generation.
01466   * @retval  HAL status
01467   */
01468 HAL_StatusTypeDef  HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType)
01469 {
01470   /* Check the parameters */
01471   assert_param(IS_LTDC_RELOAD(ReloadType));
01472 
01473   /* Process locked */
01474   __HAL_LOCK(hltdc);
01475 
01476   /* Change LTDC peripheral state */
01477   hltdc->State = HAL_LTDC_STATE_BUSY;
01478 
01479   /* Enable the Reload interrupt */
01480   __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_RR);
01481 
01482   /* Apply Reload type */
01483   hltdc->Instance->SRCR = ReloadType;
01484 
01485   /* Change the LTDC state*/
01486   hltdc->State = HAL_LTDC_STATE_READY;
01487 
01488   /* Process unlocked */
01489   __HAL_UNLOCK(hltdc);
01490 
01491   return HAL_OK;
01492 }
01493 
01494 /**
01495   * @brief  Configure the LTDC Layer according to the specified without reloading
01496   *         parameters in the LTDC_InitTypeDef and create the associated handle.
01497   *         Variant of the function HAL_LTDC_ConfigLayer without immediate reload.
01498   * @param  hltdc      pointer to a LTDC_HandleTypeDef structure that contains
01499   *                    the configuration information for the LTDC.
01500   * @param  pLayerCfg  pointer to a LTDC_LayerCfgTypeDef structure that contains
01501   *                    the configuration information for the Layer.
01502   * @param  LayerIdx   LTDC Layer index.
01503   *                    This parameter can be one of the following values:
01504   *                    LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01505   * @retval HAL status
01506   */
01507 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
01508 {
01509   /* Check the parameters */
01510   assert_param(IS_LTDC_LAYER(LayerIdx));
01511   assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
01512   assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
01513   assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
01514   assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
01515   assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
01516   assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
01517   assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
01518   assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
01519   assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
01520   assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
01521   assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
01522 
01523   /* Process locked */
01524   __HAL_LOCK(hltdc);
01525 
01526   /* Change LTDC peripheral state */
01527   hltdc->State = HAL_LTDC_STATE_BUSY;
01528 
01529   /* Copy new layer configuration into handle structure */
01530   hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
01531 
01532   /* Configure the LTDC Layer */
01533   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01534 
01535   /* Initialize the LTDC state*/
01536   hltdc->State  = HAL_LTDC_STATE_READY;
01537 
01538   /* Process unlocked */
01539   __HAL_UNLOCK(hltdc);
01540 
01541   return HAL_OK;
01542 }
01543 
01544 /**
01545   * @brief  Set the LTDC window size without reloading.
01546   *         Variant of the function HAL_LTDC_SetWindowSize without immediate reload.
01547   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01548   *                   the configuration information for the LTDC.
01549   * @param  XSize     LTDC Pixel per line
01550   * @param  YSize     LTDC Line number
01551   * @param  LayerIdx  LTDC Layer index.
01552   *                   This parameter can be one of the following values:
01553   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01554   * @retval  HAL status
01555   */
01556 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
01557 {
01558   LTDC_LayerCfgTypeDef *pLayerCfg;
01559 
01560   /* Check the parameters (Layers parameters)*/
01561   assert_param(IS_LTDC_LAYER(LayerIdx));
01562   assert_param(IS_LTDC_CFBLL(XSize));
01563   assert_param(IS_LTDC_CFBLNBR(YSize));
01564 
01565   /* Process locked */
01566   __HAL_LOCK(hltdc);
01567 
01568   /* Change LTDC peripheral state */
01569   hltdc->State = HAL_LTDC_STATE_BUSY;
01570 
01571   /* Get layer configuration from handle structure */
01572   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01573 
01574   /* update horizontal stop */
01575   pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
01576 
01577   /* update vertical stop */
01578   pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
01579 
01580   /* Reconfigures the color frame buffer pitch in byte */
01581   pLayerCfg->ImageWidth = XSize;
01582 
01583   /* Reconfigures the frame buffer line number */
01584   pLayerCfg->ImageHeight = YSize;
01585 
01586   /* Set LTDC parameters */
01587   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01588 
01589   /* Change the LTDC state*/
01590   hltdc->State = HAL_LTDC_STATE_READY;
01591 
01592   /* Process unlocked */
01593   __HAL_UNLOCK(hltdc);
01594 
01595   return HAL_OK;
01596 }
01597 
01598 /**
01599   * @brief  Set the LTDC window position without reloading.
01600   *         Variant of the function HAL_LTDC_SetWindowPosition without immediate reload.
01601   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01602   *                   the configuration information for the LTDC.
01603   * @param  X0        LTDC window X offset
01604   * @param  Y0        LTDC window Y offset
01605   * @param  LayerIdx  LTDC Layer index.
01606   *                         This parameter can be one of the following values:
01607   *                         LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01608   * @retval  HAL status
01609   */
01610 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
01611 {
01612   LTDC_LayerCfgTypeDef *pLayerCfg;
01613 
01614   /* Check the parameters */
01615   assert_param(IS_LTDC_LAYER(LayerIdx));
01616   assert_param(IS_LTDC_CFBLL(X0));
01617   assert_param(IS_LTDC_CFBLNBR(Y0));
01618 
01619   /* Process locked */
01620   __HAL_LOCK(hltdc);
01621 
01622   /* Change LTDC peripheral state */
01623   hltdc->State = HAL_LTDC_STATE_BUSY;
01624 
01625   /* Get layer configuration from handle structure */
01626   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01627 
01628   /* update horizontal start/stop */
01629   pLayerCfg->WindowX0 = X0;
01630   pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
01631 
01632   /* update vertical start/stop */
01633   pLayerCfg->WindowY0 = Y0;
01634   pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
01635 
01636   /* Set LTDC parameters */
01637   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01638 
01639   /* Change the LTDC state*/
01640   hltdc->State = HAL_LTDC_STATE_READY;
01641 
01642   /* Process unlocked */
01643   __HAL_UNLOCK(hltdc);
01644 
01645   return HAL_OK;
01646 }
01647 
01648 /**
01649   * @brief  Reconfigure the pixel format without reloading.
01650   *         Variant of the function HAL_LTDC_SetPixelFormat without immediate reload.
01651   * @param  hltdc        pointer to a LTDC_HandleTypeDfef structure that contains
01652   *                      the configuration information for the LTDC.
01653   * @param  Pixelformat  new pixel format value.
01654   * @param  LayerIdx     LTDC Layer index.
01655   *                      This parameter can be one of the following values:
01656   *                      LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
01657   * @retval  HAL status
01658   */
01659 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
01660 {
01661   LTDC_LayerCfgTypeDef *pLayerCfg;
01662 
01663   /* Check the parameters */
01664   assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
01665   assert_param(IS_LTDC_LAYER(LayerIdx));
01666 
01667   /* Process locked */
01668   __HAL_LOCK(hltdc);
01669 
01670   /* Change LTDC peripheral state */
01671   hltdc->State = HAL_LTDC_STATE_BUSY;
01672 
01673   /* Get layer configuration from handle structure */
01674   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01675 
01676   /* Reconfigure the pixel format */
01677   pLayerCfg->PixelFormat = Pixelformat;
01678 
01679   /* Set LTDC parameters */
01680   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01681 
01682   /* Change the LTDC state*/
01683   hltdc->State = HAL_LTDC_STATE_READY;
01684 
01685   /* Process unlocked */
01686   __HAL_UNLOCK(hltdc);
01687 
01688   return HAL_OK;
01689 }
01690 
01691 /**
01692   * @brief  Reconfigure the layer alpha value without reloading.
01693   *         Variant of the function HAL_LTDC_SetAlpha without immediate reload.
01694   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01695   *                   the configuration information for the LTDC.
01696   * @param  Alpha     new alpha value.
01697   * @param  LayerIdx  LTDC Layer index.
01698   *                   This parameter can be one of the following values:
01699   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01700   * @retval  HAL status
01701   */
01702 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
01703 {
01704   LTDC_LayerCfgTypeDef *pLayerCfg;
01705 
01706   /* Check the parameters */
01707   assert_param(IS_LTDC_ALPHA(Alpha));
01708   assert_param(IS_LTDC_LAYER(LayerIdx));
01709 
01710   /* Process locked */
01711   __HAL_LOCK(hltdc);
01712 
01713   /* Change LTDC peripheral state */
01714   hltdc->State = HAL_LTDC_STATE_BUSY;
01715 
01716   /* Get layer configuration from handle structure */
01717   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01718 
01719   /* Reconfigure the Alpha value */
01720   pLayerCfg->Alpha = Alpha;
01721 
01722   /* Set LTDC parameters */
01723   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01724 
01725   /* Change the LTDC state*/
01726   hltdc->State = HAL_LTDC_STATE_READY;
01727 
01728   /* Process unlocked */
01729   __HAL_UNLOCK(hltdc);
01730 
01731   return HAL_OK;
01732 }
01733 
01734 /**
01735   * @brief  Reconfigure the frame buffer Address without reloading.
01736   *         Variant of the function HAL_LTDC_SetAddress without immediate reload.
01737   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01738   *                   the configuration information for the LTDC.
01739   * @param  Address   new address value.
01740   * @param  LayerIdx  LTDC Layer index.
01741   *                   This parameter can be one of the following values:
01742   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
01743   * @retval  HAL status
01744   */
01745 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
01746 {
01747   LTDC_LayerCfgTypeDef *pLayerCfg;
01748 
01749   /* Check the parameters */
01750   assert_param(IS_LTDC_LAYER(LayerIdx));
01751 
01752   /* Process locked */
01753   __HAL_LOCK(hltdc);
01754 
01755   /* Change LTDC peripheral state */
01756   hltdc->State = HAL_LTDC_STATE_BUSY;
01757 
01758   /* Get layer configuration from handle structure */
01759   pLayerCfg = &hltdc->LayerCfg[LayerIdx];
01760 
01761   /* Reconfigure the Address */
01762   pLayerCfg->FBStartAdress = Address;
01763 
01764   /* Set LTDC parameters */
01765   LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
01766 
01767   /* Change the LTDC state*/
01768   hltdc->State = HAL_LTDC_STATE_READY;
01769 
01770   /* Process unlocked */
01771   __HAL_UNLOCK(hltdc);
01772 
01773   return HAL_OK;
01774 }
01775 
01776 /**
01777   * @brief  Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
01778   *         larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
01779   *         want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
01780   *         will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
01781   * @note   This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
01782   *         configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
01783   *         Variant of the function HAL_LTDC_SetPitch without immediate reload.
01784   * @param  hltdc              pointer to a LTDC_HandleTypeDef structure that contains
01785   *                            the configuration information for the LTDC.
01786   * @param  LinePitchInPixels  New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
01787   * @param  LayerIdx           LTDC layer index concerned by the modification of line pitch.
01788   * @retval HAL status
01789   */
01790 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
01791 {
01792   uint32_t tmp;
01793   uint32_t pitchUpdate;
01794   uint32_t pixelFormat;
01795 
01796   /* Check the parameters */
01797   assert_param(IS_LTDC_LAYER(LayerIdx));
01798 
01799   /* Process locked */
01800   __HAL_LOCK(hltdc);
01801 
01802   /* Change LTDC peripheral state */
01803   hltdc->State = HAL_LTDC_STATE_BUSY;
01804 
01805   /* get LayerIdx used pixel format */
01806   pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
01807 
01808   if (pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
01809   {
01810     tmp = 4U;
01811   }
01812   else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
01813   {
01814     tmp = 3U;
01815   }
01816   else if ((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
01817            (pixelFormat == LTDC_PIXEL_FORMAT_RGB565)   || \
01818            (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
01819            (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
01820   {
01821     tmp = 2U;
01822   }
01823   else
01824   {
01825     tmp = 1U;
01826   }
01827 
01828   pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
01829 
01830   /* Clear previously set standard pitch */
01831   LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
01832 
01833   /* Set new line pitch value */
01834   LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
01835 
01836   /* Change the LTDC state*/
01837   hltdc->State = HAL_LTDC_STATE_READY;
01838 
01839   /* Process unlocked */
01840   __HAL_UNLOCK(hltdc);
01841 
01842   return HAL_OK;
01843 }
01844 
01845 
01846 /**
01847   * @brief  Configure the color keying without reloading.
01848   *         Variant of the function HAL_LTDC_ConfigColorKeying without immediate reload.
01849   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01850   *                   the configuration information for the LTDC.
01851   * @param  RGBValue the color key value
01852   * @param  LayerIdx  LTDC Layer index.
01853   *                   This parameter can be one of the following values:
01854   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01855   * @retval HAL status
01856   */
01857 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
01858 {
01859   /* Check the parameters */
01860   assert_param(IS_LTDC_LAYER(LayerIdx));
01861 
01862   /* Process locked */
01863   __HAL_LOCK(hltdc);
01864 
01865   /* Change LTDC peripheral state */
01866   hltdc->State = HAL_LTDC_STATE_BUSY;
01867 
01868   /* Configure the default color values */
01869   LTDC_LAYER(hltdc, LayerIdx)->CKCR &=  ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
01870   LTDC_LAYER(hltdc, LayerIdx)->CKCR  = RGBValue;
01871 
01872   /* Change the LTDC state*/
01873   hltdc->State = HAL_LTDC_STATE_READY;
01874 
01875   /* Process unlocked */
01876   __HAL_UNLOCK(hltdc);
01877 
01878   return HAL_OK;
01879 }
01880 
01881 /**
01882   * @brief  Enable the color keying without reloading.
01883   *         Variant of the function HAL_LTDC_EnableColorKeying without immediate reload.
01884   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01885   *                   the configuration information for the LTDC.
01886   * @param  LayerIdx  LTDC Layer index.
01887   *                   This parameter can be one of the following values:
01888   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01889   * @retval  HAL status
01890   */
01891 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
01892 {
01893   /* Check the parameters */
01894   assert_param(IS_LTDC_LAYER(LayerIdx));
01895 
01896   /* Process locked */
01897   __HAL_LOCK(hltdc);
01898 
01899   /* Change LTDC peripheral state */
01900   hltdc->State = HAL_LTDC_STATE_BUSY;
01901 
01902   /* Enable LTDC color keying by setting COLKEN bit */
01903   LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
01904 
01905   /* Change the LTDC state*/
01906   hltdc->State = HAL_LTDC_STATE_READY;
01907 
01908   /* Process unlocked */
01909   __HAL_UNLOCK(hltdc);
01910 
01911   return HAL_OK;
01912 }
01913 
01914 /**
01915   * @brief  Disable the color keying without reloading.
01916   *         Variant of the function HAL_LTDC_DisableColorKeying without immediate reload.
01917   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01918   *                   the configuration information for the LTDC.
01919   * @param  LayerIdx  LTDC Layer index.
01920   *                   This parameter can be one of the following values:
01921   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01922   * @retval  HAL status
01923   */
01924 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
01925 {
01926   /* Check the parameters */
01927   assert_param(IS_LTDC_LAYER(LayerIdx));
01928 
01929   /* Process locked */
01930   __HAL_LOCK(hltdc);
01931 
01932   /* Change LTDC peripheral state */
01933   hltdc->State = HAL_LTDC_STATE_BUSY;
01934 
01935   /* Disable LTDC color keying by setting COLKEN bit */
01936   LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
01937 
01938   /* Change the LTDC state*/
01939   hltdc->State = HAL_LTDC_STATE_READY;
01940 
01941   /* Process unlocked */
01942   __HAL_UNLOCK(hltdc);
01943 
01944   return HAL_OK;
01945 }
01946 
01947 /**
01948   * @brief  Enable the color lookup table without reloading.
01949   *         Variant of the function HAL_LTDC_EnableCLUT without immediate reload.
01950   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01951   *                   the configuration information for the LTDC.
01952   * @param  LayerIdx  LTDC Layer index.
01953   *                   This parameter can be one of the following values:
01954   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01955   * @retval  HAL status
01956   */
01957 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
01958 {
01959   /* Check the parameters */
01960   assert_param(IS_LTDC_LAYER(LayerIdx));
01961 
01962   /* Process locked */
01963   __HAL_LOCK(hltdc);
01964 
01965   /* Change LTDC peripheral state */
01966   hltdc->State = HAL_LTDC_STATE_BUSY;
01967 
01968   /* Disable LTDC color lookup table by setting CLUTEN bit */
01969   LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
01970 
01971   /* Change the LTDC state*/
01972   hltdc->State = HAL_LTDC_STATE_READY;
01973 
01974   /* Process unlocked */
01975   __HAL_UNLOCK(hltdc);
01976 
01977   return HAL_OK;
01978 }
01979 
01980 /**
01981   * @brief  Disable the color lookup table without reloading.
01982   *         Variant of the function HAL_LTDC_DisableCLUT without immediate reload.
01983   * @param  hltdc     pointer to a LTDC_HandleTypeDef structure that contains
01984   *                   the configuration information for the LTDC.
01985   * @param  LayerIdx  LTDC Layer index.
01986   *                   This parameter can be one of the following values:
01987   *                   LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
01988   * @retval  HAL status
01989   */
01990 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
01991 {
01992   /* Check the parameters */
01993   assert_param(IS_LTDC_LAYER(LayerIdx));
01994 
01995   /* Process locked */
01996   __HAL_LOCK(hltdc);
01997 
01998   /* Change LTDC peripheral state */
01999   hltdc->State = HAL_LTDC_STATE_BUSY;
02000 
02001   /* Disable LTDC color lookup table by setting CLUTEN bit */
02002   LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
02003 
02004   /* Change the LTDC state*/
02005   hltdc->State = HAL_LTDC_STATE_READY;
02006 
02007   /* Process unlocked */
02008   __HAL_UNLOCK(hltdc);
02009 
02010   return HAL_OK;
02011 }
02012 
02013 /**
02014   * @}
02015   */
02016 
02017 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
02018   *  @brief    Peripheral State and Errors functions
02019   *
02020 @verbatim
02021  ===============================================================================
02022                   ##### Peripheral State and Errors functions #####
02023  ===============================================================================
02024     [..]
02025     This subsection provides functions allowing to
02026       (+) Check the LTDC handle state.
02027       (+) Get the LTDC handle error code.
02028 
02029 @endverbatim
02030   * @{
02031   */
02032 
02033 /**
02034   * @brief  Return the LTDC handle state.
02035   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
02036   *                the configuration information for the LTDC.
02037   * @retval HAL state
02038   */
02039 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
02040 {
02041   return hltdc->State;
02042 }
02043 
02044 /**
02045   * @brief  Return the LTDC handle error code.
02046   * @param  hltdc  pointer to a LTDC_HandleTypeDef structure that contains
02047   *               the configuration information for the LTDC.
02048   * @retval LTDC Error Code
02049   */
02050 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
02051 {
02052   return hltdc->ErrorCode;
02053 }
02054 
02055 /**
02056   * @}
02057   */
02058 
02059 /**
02060   * @}
02061   */
02062 
02063 /** @defgroup LTDC_Private_Functions LTDC Private Functions
02064   * @{
02065   */
02066 
02067 /**
02068   * @brief  Configure the LTDC peripheral
02069   * @param  hltdc     Pointer to a LTDC_HandleTypeDef structure that contains
02070   *                   the configuration information for the LTDC.
02071   * @param  pLayerCfg Pointer LTDC Layer Configuration structure
02072   * @param  LayerIdx  LTDC Layer index.
02073   *                   This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
02074   * @retval None
02075   */
02076 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
02077 {
02078   uint32_t tmp;
02079   uint32_t tmp1;
02080   uint32_t tmp2;
02081 
02082   /* Configure the horizontal start and stop position */
02083   tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U)) << 16U);
02084   LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
02085   LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U) + 1U) | tmp);
02086 
02087   /* Configure the vertical start and stop position */
02088   tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16U);
02089   LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
02090   LTDC_LAYER(hltdc, LayerIdx)->WVPCR  = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1U) | tmp);
02091 
02092   /* Specifies the pixel format */
02093   LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
02094   LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
02095 
02096   /* Configure the default color values */
02097   tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8U);
02098   tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16U);
02099   tmp2 = (pLayerCfg->Alpha0 << 24U);
02100   LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
02101   LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
02102 
02103   /* Specifies the constant alpha value */
02104   LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
02105   LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
02106 
02107   /* Specifies the blending factors */
02108   LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
02109   LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
02110 
02111   /* Configure the color frame buffer start address */
02112   LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
02113   LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
02114 
02115   if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
02116   {
02117     tmp = 4U;
02118   }
02119   else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
02120   {
02121     tmp = 3U;
02122   }
02123   else if ((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
02124            (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565)   || \
02125            (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
02126            (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
02127   {
02128     tmp = 2U;
02129   }
02130   else
02131   {
02132     tmp = 1U;
02133   }
02134 
02135   /* Configure the color frame buffer pitch in byte */
02136   LTDC_LAYER(hltdc, LayerIdx)->CFBLR  &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
02137   LTDC_LAYER(hltdc, LayerIdx)->CFBLR  = (((pLayerCfg->ImageWidth * tmp) << 16U) | (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp)  + 3U));
02138   /* Configure the frame buffer line number */
02139   LTDC_LAYER(hltdc, LayerIdx)->CFBLNR  &= ~(LTDC_LxCFBLNR_CFBLNBR);
02140   LTDC_LAYER(hltdc, LayerIdx)->CFBLNR  = (pLayerCfg->ImageHeight);
02141 
02142   /* Enable LTDC_Layer by setting LEN bit */
02143   LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
02144 }
02145 
02146 /**
02147   * @}
02148   */
02149 
02150 
02151 /**
02152   * @}
02153   */
02154 
02155 #endif /* LTDC */
02156 
02157 #endif /* HAL_LTDC_MODULE_ENABLED */
02158 
02159 /**
02160   * @}
02161   */