STM32L443xx HAL User Manual
stm32l4xx_hal_lcd.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_lcd.c
00004   * @author  MCD Application Team
00005   * @brief   LCD Controller HAL module driver.
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the LCD Controller (LCD) peripheral:
00008   *           + Initialization/de-initialization methods
00009   *           + I/O operation methods
00010   *           + Peripheral State methods
00011   *
00012   ******************************************************************************
00013   * @attention
00014   *
00015   * Copyright (c) 2017 STMicroelectronics.
00016   * All rights reserved.
00017   *
00018   * This software is licensed under terms that can be found in the LICENSE file in
00019   * the root directory of this software component.
00020   * If no LICENSE file comes with this software, it is provided AS-IS.
00021   ******************************************************************************
00022   @verbatim
00023   ==============================================================================
00024                         ##### How to use this driver #####
00025   ==============================================================================
00026       [..] The LCD HAL driver can be used as follows:
00027 
00028       (#) Declare a LCD_HandleTypeDef handle structure.
00029 
00030       -@- The frequency generator allows you to achieve various LCD frame rates
00031           starting from an LCD input clock frequency (LCDCLK) which can vary
00032           from 32 kHz up to 1 MHz.
00033 
00034       (#) Initialize the LCD low level resources by implementing the HAL_LCD_MspInit() API:
00035 
00036           (++) Enable the LCDCLK (same as RTCCLK): to configure the RTCCLK/LCDCLK, proceed as follows:
00037                (+++) Use RCC function HAL_RCCEx_PeriphCLKConfig in indicating RCC_PERIPHCLK_LCD and
00038                   selected clock source (HSE, LSI or LSE)
00039 
00040           (++) LCD pins configuration:
00041               (+++) Enable the clock for the LCD GPIOs.
00042               (+++) Configure these LCD pins as alternate function no-pull.
00043           (++) Enable the LCD interface clock.
00044 
00045 
00046       (#) Program the Prescaler, Divider, Blink mode, Blink Frequency Duty, Bias,
00047           Voltage Source, Dead Time, Pulse On Duration, Contrast, High drive and Multiplexer
00048           Segment in the Init structure of the LCD handle.
00049 
00050       (#) Initialize the LCD registers by calling the HAL_LCD_Init() API.
00051 
00052       -@- The HAL_LCD_Init() API configures also the low level Hardware GPIO, CLOCK, ...etc)
00053           by calling the customized HAL_LCD_MspInit() API.
00054       -@- After calling the HAL_LCD_Init() the LCD RAM memory is cleared
00055 
00056       (#) Optionally you can update the LCD configuration using these macros:
00057               (++) LCD High Drive using the __HAL_LCD_HIGHDRIVER_ENABLE() and __HAL_LCD_HIGHDRIVER_DISABLE() macros
00058               (++) Voltage output buffer using __HAL_LCD_VOLTAGE_BUFFER_ENABLE() and __HAL_LCD_VOLTAGE_BUFFER_DISABLE() macros
00059               (++) LCD Pulse ON Duration using the __HAL_LCD_PULSEONDURATION_CONFIG() macro
00060               (++) LCD Dead Time using the __HAL_LCD_DEADTIME_CONFIG() macro
00061               (++) The LCD Blink mode and frequency using the __HAL_LCD_BLINK_CONFIG() macro
00062               (++) The LCD Contrast using the __HAL_LCD_CONTRAST_CONFIG() macro
00063 
00064       (#) Write to the LCD RAM memory using the HAL_LCD_Write() API, this API can be called
00065           more time to update the different LCD RAM registers before calling
00066           HAL_LCD_UpdateDisplayRequest() API.
00067 
00068       (#) The HAL_LCD_Clear() API can be used to clear the LCD RAM memory.
00069 
00070       (#) When LCD RAM memory is updated enable the update display request using
00071           the HAL_LCD_UpdateDisplayRequest() API.
00072 
00073       [..] LCD and low power modes:
00074            (#) The LCD remain active during Sleep, Low Power run, Low Power Sleep and
00075                STOP modes.
00076 
00077   @endverbatim
00078   ******************************************************************************
00079   */
00080 
00081 /* Includes ------------------------------------------------------------------*/
00082 #include "stm32l4xx_hal.h"
00083 
00084 #if defined(STM32L433xx) || defined(STM32L443xx) || defined(STM32L476xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
00085 
00086 /** @addtogroup STM32L4xx_HAL_Driver
00087   * @{
00088   */
00089 
00090 #ifdef HAL_LCD_MODULE_ENABLED
00091 
00092 /** @defgroup LCD LCD
00093   * @brief LCD HAL module driver
00094   * @{
00095   */
00096 
00097 /* Private typedef -----------------------------------------------------------*/
00098 /* Private define ------------------------------------------------------------*/
00099 /** @defgroup LCD_Private_Defines LCD Private Defines
00100   * @{
00101   */
00102 
00103 #define LCD_TIMEOUT_VALUE             1000U
00104 
00105 /**
00106   * @}
00107   */
00108 
00109 /* Private macro -------------------------------------------------------------*/
00110 /* Private variables ---------------------------------------------------------*/
00111 /* Private function prototypes -----------------------------------------------*/
00112 /* Exported functions --------------------------------------------------------*/
00113 
00114 /** @defgroup LCD_Exported_Functions LCD Exported Functions
00115   * @{
00116   */
00117 
00118 /** @defgroup LCD_Exported_Functions_Group1 Initialization/de-initialization methods
00119   *  @brief    Initialization and Configuration functions
00120   *
00121 @verbatim
00122 ===============================================================================
00123             ##### Initialization and Configuration functions #####
00124  ===============================================================================
00125     [..]
00126 
00127 @endverbatim
00128   * @{
00129   */
00130 
00131 /**
00132   * @brief  Initialize the LCD peripheral according to the specified parameters
00133   *         in the LCD_InitStruct and initialize the associated handle.
00134   * @note   This function can be used only when the LCD is disabled.
00135   * @param hlcd LCD handle
00136   * @retval None
00137   */
00138 HAL_StatusTypeDef HAL_LCD_Init(LCD_HandleTypeDef *hlcd)
00139 {
00140   uint32_t tickstart;
00141   uint32_t counter;
00142   HAL_StatusTypeDef status;
00143 
00144   /* Check the LCD handle allocation */
00145   if (hlcd == NULL)
00146   {
00147     return HAL_ERROR;
00148   }
00149 
00150   /* Check function parameters */
00151   assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
00152   assert_param(IS_LCD_PRESCALER(hlcd->Init.Prescaler));
00153   assert_param(IS_LCD_DIVIDER(hlcd->Init.Divider));
00154   assert_param(IS_LCD_DUTY(hlcd->Init.Duty));
00155   assert_param(IS_LCD_BIAS(hlcd->Init.Bias));
00156   assert_param(IS_LCD_VOLTAGE_SOURCE(hlcd->Init.VoltageSource));
00157   assert_param(IS_LCD_PULSE_ON_DURATION(hlcd->Init.PulseOnDuration));
00158   assert_param(IS_LCD_HIGH_DRIVE(hlcd->Init.HighDrive));
00159   assert_param(IS_LCD_DEAD_TIME(hlcd->Init.DeadTime));
00160   assert_param(IS_LCD_CONTRAST(hlcd->Init.Contrast));
00161   assert_param(IS_LCD_BLINK_FREQUENCY(hlcd->Init.BlinkFrequency));
00162   assert_param(IS_LCD_BLINK_MODE(hlcd->Init.BlinkMode));
00163   assert_param(IS_LCD_MUX_SEGMENT(hlcd->Init.MuxSegment));
00164 
00165   if (hlcd->State == HAL_LCD_STATE_RESET)
00166   {
00167     /* Allocate lock resource and initialize it */
00168     hlcd->Lock = HAL_UNLOCKED;
00169 
00170     /* Initialize the low level hardware (MSP) */
00171     HAL_LCD_MspInit(hlcd);
00172   }
00173 
00174   hlcd->State = HAL_LCD_STATE_BUSY;
00175 
00176   /* Disable the peripheral */
00177   __HAL_LCD_DISABLE(hlcd);
00178 
00179   /* Clear the LCD_RAM registers and enable the display request by setting the UDR bit
00180      in the LCD_SR register */
00181   for (counter = LCD_RAM_REGISTER0; counter <= LCD_RAM_REGISTER15; counter++)
00182   {
00183     hlcd->Instance->RAM[counter] = 0;
00184   }
00185   /* Enable the display request */
00186   hlcd->Instance->SR |= LCD_SR_UDR;
00187   /* Configure the LCD Prescaler, Divider, Blink mode and Blink Frequency:
00188      Set PS[3:0] bits according to hlcd->Init.Prescaler value
00189      Set DIV[3:0] bits according to hlcd->Init.Divider value
00190      Set BLINK[1:0] bits according to hlcd->Init.BlinkMode value
00191      Set BLINKF[2:0] bits according to hlcd->Init.BlinkFrequency value
00192      Set DEAD[2:0] bits according to hlcd->Init.DeadTime value
00193      Set PON[2:0] bits according to hlcd->Init.PulseOnDuration value
00194      Set CC[2:0] bits according to hlcd->Init.Contrast value
00195      Set HD bit according to hlcd->Init.HighDrive value */
00196   MODIFY_REG(hlcd->Instance->FCR, \
00197              (LCD_FCR_PS | LCD_FCR_DIV | LCD_FCR_BLINK | LCD_FCR_BLINKF | \
00198               LCD_FCR_DEAD | LCD_FCR_PON | LCD_FCR_CC | LCD_FCR_HD), \
00199              (hlcd->Init.Prescaler | hlcd->Init.Divider | hlcd->Init.BlinkMode | hlcd->Init.BlinkFrequency | \
00200               hlcd->Init.DeadTime | hlcd->Init.PulseOnDuration | hlcd->Init.Contrast | hlcd->Init.HighDrive));
00201 
00202   /* Wait until LCD Frame Control Register Synchronization flag (FCRSF) is set in the LCD_SR register
00203      This bit is set by hardware each time the LCD_FCR register is updated in the LCDCLK
00204      domain. It is cleared by hardware when writing to the LCD_FCR register.*/
00205   status = LCD_WaitForSynchro(hlcd);
00206   if (status != HAL_OK)
00207   {
00208     return status;
00209   }
00210 
00211   /* Configure the LCD Duty, Bias, Voltage Source, Dead Time, Pulse On Duration and Contrast:
00212      Set DUTY[2:0] bits according to hlcd->Init.Duty value
00213      Set BIAS[1:0] bits according to hlcd->Init.Bias value
00214      Set VSEL bit according to hlcd->Init.VoltageSource value
00215      Set MUX_SEG bit according to hlcd->Init.MuxSegment value */
00216   MODIFY_REG(hlcd->Instance->CR, \
00217              (LCD_CR_DUTY | LCD_CR_BIAS | LCD_CR_VSEL | LCD_CR_MUX_SEG), \
00218              (hlcd->Init.Duty | hlcd->Init.Bias | hlcd->Init.VoltageSource | hlcd->Init.MuxSegment));
00219 
00220   /* Enable the peripheral */
00221   __HAL_LCD_ENABLE(hlcd);
00222 
00223   /* Get timeout */
00224   tickstart = HAL_GetTick();
00225 
00226   /* Wait Until the LCD is enabled */
00227   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_ENS) == RESET)
00228   {
00229     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00230     {
00231       hlcd->ErrorCode = HAL_LCD_ERROR_ENS;
00232       return HAL_TIMEOUT;
00233     }
00234   }
00235 
00236   /* Get timeout */
00237   tickstart = HAL_GetTick();
00238 
00239   /*!< Wait Until the LCD Booster is ready */
00240   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_RDY) == RESET)
00241   {
00242     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00243     {
00244       hlcd->ErrorCode = HAL_LCD_ERROR_RDY;
00245       return HAL_TIMEOUT;
00246     }
00247   }
00248 
00249   /* Initialize the LCD state */
00250   hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
00251   hlcd->State = HAL_LCD_STATE_READY;
00252 
00253   return status;
00254 }
00255 
00256 /**
00257   * @brief  DeInitialize the LCD peripheral.
00258   * @param hlcd LCD handle
00259   * @retval HAL status
00260   */
00261 HAL_StatusTypeDef HAL_LCD_DeInit(LCD_HandleTypeDef *hlcd)
00262 {
00263   /* Check the LCD handle allocation */
00264   if (hlcd == NULL)
00265   {
00266     return HAL_ERROR;
00267   }
00268 
00269   /* Check the parameters */
00270   assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
00271 
00272   hlcd->State = HAL_LCD_STATE_BUSY;
00273 
00274   /* DeInit the low level hardware */
00275   HAL_LCD_MspDeInit(hlcd);
00276 
00277   hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
00278   hlcd->State = HAL_LCD_STATE_RESET;
00279 
00280   /* Release Lock */
00281   __HAL_UNLOCK(hlcd);
00282 
00283   return HAL_OK;
00284 }
00285 
00286 /**
00287   * @brief  DeInitialize the LCD MSP.
00288   * @param hlcd LCD handle
00289   * @retval None
00290   */
00291 __weak void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd)
00292 {
00293   /* Prevent unused argument(s) compilation warning */
00294   UNUSED(hlcd);
00295 
00296   /* NOTE: This function should not be modified, when the callback is needed,
00297            the HAL_LCD_MspDeInit it to be implemented in the user file
00298    */
00299 }
00300 
00301 /**
00302   * @brief  Initialize the LCD MSP.
00303   * @param hlcd LCD handle
00304   * @retval None
00305   */
00306 __weak void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd)
00307 {
00308   /* Prevent unused argument(s) compilation warning */
00309   UNUSED(hlcd);
00310 
00311   /* NOTE: This function should not be modified, when the callback is needed,
00312            the HAL_LCD_MspInit is to be implemented in the user file
00313    */
00314 }
00315 
00316 /**
00317   * @}
00318   */
00319 
00320 /** @defgroup LCD_Exported_Functions_Group2 IO operation methods
00321   *  @brief LCD RAM functions
00322   *
00323 @verbatim
00324  ===============================================================================
00325                       ##### IO operation functions #####
00326  ===============================================================================
00327  [..] Using its double buffer memory the LCD controller ensures the coherency of the
00328  displayed information without having to use interrupts to control LCD_RAM
00329  modification.
00330  The application software can access the first buffer level (LCD_RAM) through
00331  the APB interface. Once it has modified the LCD_RAM using the HAL_LCD_Write() API,
00332  it sets the UDR flag in the LCD_SR register using the HAL_LCD_UpdateDisplayRequest() API.
00333  This UDR flag (update display request) requests the updated information to be
00334  moved into the second buffer level (LCD_DISPLAY).
00335  This operation is done synchronously with the frame (at the beginning of the
00336  next frame), until the update is completed, the LCD_RAM is write protected and
00337  the UDR flag stays high.
00338  Once the update is completed another flag (UDD - Update Display Done) is set and
00339  generates an interrupt if the UDDIE bit in the LCD_FCR register is set.
00340  The time it takes to update LCD_DISPLAY is, in the worst case, one odd and one
00341  even frame.
00342  The update will not occur (UDR = 1 and UDD = 0) until the display is
00343  enabled (LCDEN = 1).
00344 
00345 @endverbatim
00346   * @{
00347   */
00348 
00349 /**
00350   * @brief  Write a word in the specific LCD RAM.
00351   * @param hlcd LCD handle
00352   * @param RAMRegisterIndex specifies the LCD RAM Register.
00353   *   This parameter can be one of the following values:
00354   *     @arg LCD_RAM_REGISTER0: LCD RAM Register 0
00355   *     @arg LCD_RAM_REGISTER1: LCD RAM Register 1
00356   *     @arg LCD_RAM_REGISTER2: LCD RAM Register 2
00357   *     @arg LCD_RAM_REGISTER3: LCD RAM Register 3
00358   *     @arg LCD_RAM_REGISTER4: LCD RAM Register 4
00359   *     @arg LCD_RAM_REGISTER5: LCD RAM Register 5
00360   *     @arg LCD_RAM_REGISTER6: LCD RAM Register 6
00361   *     @arg LCD_RAM_REGISTER7: LCD RAM Register 7
00362   *     @arg LCD_RAM_REGISTER8: LCD RAM Register 8
00363   *     @arg LCD_RAM_REGISTER9: LCD RAM Register 9
00364   *     @arg LCD_RAM_REGISTER10: LCD RAM Register 10
00365   *     @arg LCD_RAM_REGISTER11: LCD RAM Register 11
00366   *     @arg LCD_RAM_REGISTER12: LCD RAM Register 12
00367   *     @arg LCD_RAM_REGISTER13: LCD RAM Register 13
00368   *     @arg LCD_RAM_REGISTER14: LCD RAM Register 14
00369   *     @arg LCD_RAM_REGISTER15: LCD RAM Register 15
00370   * @param RAMRegisterMask specifies the LCD RAM Register Data Mask.
00371   * @param Data specifies LCD Data Value to be written.
00372   * @retval None
00373   */
00374 HAL_StatusTypeDef HAL_LCD_Write(LCD_HandleTypeDef *hlcd, uint32_t RAMRegisterIndex, uint32_t RAMRegisterMask, uint32_t Data)
00375 {
00376   uint32_t tickstart;
00377   HAL_LCD_StateTypeDef state = hlcd->State;
00378   
00379   if ((state == HAL_LCD_STATE_READY) || (state == HAL_LCD_STATE_BUSY))
00380   {
00381     /* Check the parameters */
00382     assert_param(IS_LCD_RAM_REGISTER(RAMRegisterIndex));
00383 
00384     if (hlcd->State == HAL_LCD_STATE_READY)
00385     {
00386       /* Process Locked */
00387       __HAL_LOCK(hlcd);
00388       hlcd->State = HAL_LCD_STATE_BUSY;
00389 
00390       /* Get timeout */
00391       tickstart = HAL_GetTick();
00392 
00393       /*!< Wait Until the LCD is ready */
00394       while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDR) != RESET)
00395       {
00396         if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00397         {
00398           hlcd->ErrorCode = HAL_LCD_ERROR_UDR;
00399 
00400           /* Process Unlocked */
00401           __HAL_UNLOCK(hlcd);
00402 
00403           return HAL_TIMEOUT;
00404         }
00405       }
00406     }
00407 
00408     /* Copy the new Data bytes to LCD RAM register */
00409     MODIFY_REG(hlcd->Instance->RAM[RAMRegisterIndex], ~(RAMRegisterMask), Data);
00410 
00411     return HAL_OK;
00412   }
00413   else
00414   {
00415     return HAL_ERROR;
00416   }
00417 }
00418 
00419 /**
00420   * @brief Clear the LCD RAM registers.
00421   * @param hlcd LCD handle
00422   * @retval None
00423   */
00424 HAL_StatusTypeDef HAL_LCD_Clear(LCD_HandleTypeDef *hlcd)
00425 {
00426   uint32_t tickstart;
00427   uint32_t counter;
00428   HAL_StatusTypeDef status = HAL_ERROR;
00429   HAL_LCD_StateTypeDef state = hlcd->State;
00430   
00431   if ((state == HAL_LCD_STATE_READY) || (state == HAL_LCD_STATE_BUSY))
00432   {
00433     /* Process Locked */
00434     __HAL_LOCK(hlcd);
00435 
00436     hlcd->State = HAL_LCD_STATE_BUSY;
00437 
00438     /* Get timeout */
00439     tickstart = HAL_GetTick();
00440 
00441     /*!< Wait Until the LCD is ready */
00442     while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDR) != RESET)
00443     {
00444       if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00445       {
00446         hlcd->ErrorCode = HAL_LCD_ERROR_UDR;
00447 
00448         /* Process Unlocked */
00449         __HAL_UNLOCK(hlcd);
00450 
00451         return HAL_TIMEOUT;
00452       }
00453     }
00454     /* Clear the LCD_RAM registers */
00455     for (counter = LCD_RAM_REGISTER0; counter <= LCD_RAM_REGISTER15; counter++)
00456     {
00457       hlcd->Instance->RAM[counter] = 0;
00458     }
00459 
00460     /* Update the LCD display */
00461     status = HAL_LCD_UpdateDisplayRequest(hlcd);
00462   }
00463   return status;
00464 }
00465 
00466 /**
00467   * @brief  Enable the Update Display Request.
00468   * @param hlcd LCD handle
00469   * @note   Each time software modifies the LCD_RAM it must set the UDR bit to
00470   *         transfer the updated data to the second level buffer.
00471   *         The UDR bit stays set until the end of the update and during this
00472   *         time the LCD_RAM is write protected.
00473   * @note   When the display is disabled, the update is performed for all
00474   *         LCD_DISPLAY locations.
00475   *         When the display is enabled, the update is performed only for locations
00476   *         for which commons are active (depending on DUTY). For example if
00477   *         DUTY = 1/2, only the LCD_DISPLAY of COM0 and COM1 will be updated.
00478   * @retval None
00479   */
00480 HAL_StatusTypeDef HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef *hlcd)
00481 {
00482   uint32_t tickstart;
00483 
00484   /* Clear the Update Display Done flag before starting the update display request */
00485   __HAL_LCD_CLEAR_FLAG(hlcd, LCD_FLAG_UDD);
00486 
00487   /* Enable the display request */
00488   hlcd->Instance->SR |= LCD_SR_UDR;
00489 
00490   /* Get timeout */
00491   tickstart = HAL_GetTick();
00492 
00493   /*!< Wait Until the LCD display is done */
00494   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDD) == RESET)
00495   {
00496     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00497     {
00498       hlcd->ErrorCode = HAL_LCD_ERROR_UDD;
00499 
00500       /* Process Unlocked */
00501       __HAL_UNLOCK(hlcd);
00502 
00503       return HAL_TIMEOUT;
00504     }
00505   }
00506 
00507   hlcd->State = HAL_LCD_STATE_READY;
00508 
00509   /* Process Unlocked */
00510   __HAL_UNLOCK(hlcd);
00511 
00512   return HAL_OK;
00513 }
00514 
00515 /**
00516   * @}
00517   */
00518 
00519 /** @defgroup LCD_Exported_Functions_Group3 Peripheral State methods
00520   *  @brief   LCD State functions
00521   *
00522 @verbatim
00523  ===============================================================================
00524                       ##### Peripheral State functions #####
00525  ===============================================================================
00526     [..]
00527      This subsection provides a set of functions allowing to control the LCD:
00528       (+) HAL_LCD_GetState() API can be helpful to check in run-time the state of the LCD peripheral State.
00529       (+) HAL_LCD_GetError() API to return the LCD error code.
00530 @endverbatim
00531   * @{
00532   */
00533 
00534 /**
00535   * @brief Return the LCD handle state.
00536   * @param hlcd LCD handle
00537   * @retval HAL state
00538   */
00539 HAL_LCD_StateTypeDef HAL_LCD_GetState(LCD_HandleTypeDef *hlcd)
00540 {
00541   /* Return LCD handle state */
00542   return hlcd->State;
00543 }
00544 
00545 /**
00546   * @brief Return the LCD error code.
00547   * @param hlcd LCD handle
00548   * @retval LCD Error Code
00549   */
00550 uint32_t HAL_LCD_GetError(LCD_HandleTypeDef *hlcd)
00551 {
00552   return hlcd->ErrorCode;
00553 }
00554 
00555 /**
00556   * @}
00557   */
00558 
00559 /**
00560   * @}
00561   */
00562 
00563 /** @defgroup LCD_Private_Functions LCD Private Functions
00564   * @{
00565   */
00566 
00567 /**
00568   * @brief  Wait until the LCD FCR register is synchronized in the LCDCLK domain.
00569   *   This function must be called after any write operation to LCD_FCR register.
00570   * @retval None
00571   */
00572 HAL_StatusTypeDef LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd)
00573 {
00574   uint32_t tickstart;
00575 
00576   /* Get timeout */
00577   tickstart = HAL_GetTick();
00578 
00579   /* Loop until FCRSF flag is set */
00580   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_FCRSF) == RESET)
00581   {
00582     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
00583     {
00584       hlcd->ErrorCode = HAL_LCD_ERROR_FCRSF;
00585       return HAL_TIMEOUT;
00586     }
00587   }
00588 
00589   return HAL_OK;
00590 }
00591 
00592 /**
00593   * @}
00594   */
00595 
00596 /**
00597   * @}
00598   */
00599 
00600 #endif /* HAL_LCD_MODULE_ENABLED */
00601 
00602 /**
00603   * @}
00604   */
00605 
00606 #endif /* STM32L433xx || STM32L443xx || STM32L476xx || STM32L486xx || STM32L496xx || STM32L4A6xx */