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