xref: /btstack/port/stm32-l451-miromico-sx1280/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_lcd.c (revision 2fd737d36a1de5d778cacc671d4b4d8c4f3fed82)
1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_hal_lcd.c
4   * @author  MCD Application Team
5   * @brief   LCD Controller HAL module driver.
6   *          This file provides firmware functions to manage the following
7   *          functionalities of the LCD Controller (LCD) peripheral:
8   *           + Initialization/de-initialization methods
9   *           + I/O operation methods
10   *           + Peripheral State methods
11   *
12   @verbatim
13   ==============================================================================
14                         ##### How to use this driver #####
15   ==============================================================================
16       [..] The LCD HAL driver can be used as follows:
17 
18       (#) Declare a LCD_HandleTypeDef handle structure.
19 
20       -@- The frequency generator allows you to achieve various LCD frame rates
21           starting from an LCD input clock frequency (LCDCLK) which can vary
22           from 32 kHz up to 1 MHz.
23 
24       (#) Initialize the LCD low level resources by implementing the HAL_LCD_MspInit() API:
25 
26           (++) Enable the LCDCLK (same as RTCCLK): to configure the RTCCLK/LCDCLK, proceed as follows:
27                (+++) Use RCC function HAL_RCCEx_PeriphCLKConfig in indicating RCC_PERIPHCLK_LCD and
28                   selected clock source (HSE, LSI or LSE)
29 
30           (++) LCD pins configuration:
31               (+++) Enable the clock for the LCD GPIOs.
32               (+++) Configure these LCD pins as alternate function no-pull.
33           (++) Enable the LCD interface clock.
34 
35 
36       (#) Program the Prescaler, Divider, Blink mode, Blink Frequency Duty, Bias,
37           Voltage Source, Dead Time, Pulse On Duration, Contrast, High drive and Multiplexer
38           Segment in the Init structure of the LCD handle.
39 
40       (#) Initialize the LCD registers by calling the HAL_LCD_Init() API.
41 
42       -@- The HAL_LCD_Init() API configures also the low level Hardware GPIO, CLOCK, ...etc)
43           by calling the customized HAL_LCD_MspInit() API.
44       -@- After calling the HAL_LCD_Init() the LCD RAM memory is cleared
45 
46       (#) Optionally you can update the LCD configuration using these macros:
47               (++) LCD High Drive using the __HAL_LCD_HIGHDRIVER_ENABLE() and __HAL_LCD_HIGHDRIVER_DISABLE() macros
48               (++) Voltage output buffer using __HAL_LCD_VOLTAGE_BUFFER_ENABLE() and __HAL_LCD_VOLTAGE_BUFFER_DISABLE() macros
49               (++) LCD Pulse ON Duration using the __HAL_LCD_PULSEONDURATION_CONFIG() macro
50               (++) LCD Dead Time using the __HAL_LCD_DEADTIME_CONFIG() macro
51               (++) The LCD Blink mode and frequency using the __HAL_LCD_BLINK_CONFIG() macro
52               (++) The LCD Contrast using the __HAL_LCD_CONTRAST_CONFIG() macro
53 
54       (#) Write to the LCD RAM memory using the HAL_LCD_Write() API, this API can be called
55           more time to update the different LCD RAM registers before calling
56           HAL_LCD_UpdateDisplayRequest() API.
57 
58       (#) The HAL_LCD_Clear() API can be used to clear the LCD RAM memory.
59 
60       (#) When LCD RAM memory is updated enable the update display request using
61           the HAL_LCD_UpdateDisplayRequest() API.
62 
63       [..] LCD and low power modes:
64            (#) The LCD remain active during Sleep, Low Power run, Low Power Sleep and
65                STOP modes.
66 
67   @endverbatim
68   ******************************************************************************
69   * @attention
70   *
71   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
72   * All rights reserved.</center></h2>
73   *
74   * This software component is licensed by ST under BSD 3-Clause license,
75   * the "License"; You may not use this file except in compliance with the
76   * License. You may obtain a copy of the License at:
77   *                        opensource.org/licenses/BSD-3-Clause
78   *
79   ******************************************************************************
80   */
81 
82 /* Includes ------------------------------------------------------------------*/
83 #include "stm32l4xx_hal.h"
84 
85 #if defined(STM32L433xx) || defined(STM32L443xx) || defined(STM32L476xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
86 
87 /** @addtogroup STM32L4xx_HAL_Driver
88   * @{
89   */
90 
91 #ifdef HAL_LCD_MODULE_ENABLED
92 
93 /** @defgroup LCD LCD
94   * @brief LCD HAL module driver
95   * @{
96   */
97 
98 /* Private typedef -----------------------------------------------------------*/
99 /* Private define ------------------------------------------------------------*/
100 /** @defgroup LCD_Private_Defines LCD Private Defines
101   * @{
102   */
103 
104 #define LCD_TIMEOUT_VALUE             1000U
105 
106 /**
107   * @}
108   */
109 
110 /* Private macro -------------------------------------------------------------*/
111 /* Private variables ---------------------------------------------------------*/
112 /* Private function prototypes -----------------------------------------------*/
113 /* Exported functions --------------------------------------------------------*/
114 
115 /** @defgroup LCD_Exported_Functions LCD Exported Functions
116   * @{
117   */
118 
119 /** @defgroup LCD_Exported_Functions_Group1 Initialization/de-initialization methods
120   *  @brief    Initialization and Configuration functions
121   *
122 @verbatim
123 ===============================================================================
124             ##### Initialization and Configuration functions #####
125  ===============================================================================
126     [..]
127 
128 @endverbatim
129   * @{
130   */
131 
132 /**
133   * @brief  Initialize the LCD peripheral according to the specified parameters
134   *         in the LCD_InitStruct and initialize the associated handle.
135   * @note   This function can be used only when the LCD is disabled.
136   * @param hlcd LCD handle
137   * @retval None
138   */
HAL_LCD_Init(LCD_HandleTypeDef * hlcd)139 HAL_StatusTypeDef HAL_LCD_Init(LCD_HandleTypeDef *hlcd)
140 {
141   uint32_t tickstart;
142   uint32_t counter;
143   HAL_StatusTypeDef status;
144 
145   /* Check the LCD handle allocation */
146   if (hlcd == NULL)
147   {
148     return HAL_ERROR;
149   }
150 
151   /* Check function parameters */
152   assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
153   assert_param(IS_LCD_PRESCALER(hlcd->Init.Prescaler));
154   assert_param(IS_LCD_DIVIDER(hlcd->Init.Divider));
155   assert_param(IS_LCD_DUTY(hlcd->Init.Duty));
156   assert_param(IS_LCD_BIAS(hlcd->Init.Bias));
157   assert_param(IS_LCD_VOLTAGE_SOURCE(hlcd->Init.VoltageSource));
158   assert_param(IS_LCD_PULSE_ON_DURATION(hlcd->Init.PulseOnDuration));
159   assert_param(IS_LCD_HIGH_DRIVE(hlcd->Init.HighDrive));
160   assert_param(IS_LCD_DEAD_TIME(hlcd->Init.DeadTime));
161   assert_param(IS_LCD_CONTRAST(hlcd->Init.Contrast));
162   assert_param(IS_LCD_BLINK_FREQUENCY(hlcd->Init.BlinkFrequency));
163   assert_param(IS_LCD_BLINK_MODE(hlcd->Init.BlinkMode));
164   assert_param(IS_LCD_MUX_SEGMENT(hlcd->Init.MuxSegment));
165 
166   if (hlcd->State == HAL_LCD_STATE_RESET)
167   {
168     /* Allocate lock resource and initialize it */
169     hlcd->Lock = HAL_UNLOCKED;
170 
171     /* Initialize the low level hardware (MSP) */
172     HAL_LCD_MspInit(hlcd);
173   }
174 
175   hlcd->State = HAL_LCD_STATE_BUSY;
176 
177   /* Disable the peripheral */
178   __HAL_LCD_DISABLE(hlcd);
179 
180   /* Clear the LCD_RAM registers and enable the display request by setting the UDR bit
181      in the LCD_SR register */
182   for (counter = LCD_RAM_REGISTER0; counter <= LCD_RAM_REGISTER15; counter++)
183   {
184     hlcd->Instance->RAM[counter] = 0;
185   }
186   /* Enable the display request */
187   hlcd->Instance->SR |= LCD_SR_UDR;
188   /* Configure the LCD Prescaler, Divider, Blink mode and Blink Frequency:
189      Set PS[3:0] bits according to hlcd->Init.Prescaler value
190      Set DIV[3:0] bits according to hlcd->Init.Divider value
191      Set BLINK[1:0] bits according to hlcd->Init.BlinkMode value
192      Set BLINKF[2:0] bits according to hlcd->Init.BlinkFrequency value
193      Set DEAD[2:0] bits according to hlcd->Init.DeadTime value
194      Set PON[2:0] bits according to hlcd->Init.PulseOnDuration value
195      Set CC[2:0] bits according to hlcd->Init.Contrast value
196      Set HD bit according to hlcd->Init.HighDrive value */
197   MODIFY_REG(hlcd->Instance->FCR, \
198              (LCD_FCR_PS | LCD_FCR_DIV | LCD_FCR_BLINK | LCD_FCR_BLINKF | \
199               LCD_FCR_DEAD | LCD_FCR_PON | LCD_FCR_CC | LCD_FCR_HD), \
200              (hlcd->Init.Prescaler | hlcd->Init.Divider | hlcd->Init.BlinkMode | hlcd->Init.BlinkFrequency | \
201               hlcd->Init.DeadTime | hlcd->Init.PulseOnDuration | hlcd->Init.Contrast | hlcd->Init.HighDrive));
202 
203   /* Wait until LCD Frame Control Register Synchronization flag (FCRSF) is set in the LCD_SR register
204      This bit is set by hardware each time the LCD_FCR register is updated in the LCDCLK
205      domain. It is cleared by hardware when writing to the LCD_FCR register.*/
206   status = LCD_WaitForSynchro(hlcd);
207   if (status != HAL_OK)
208   {
209     return status;
210   }
211 
212   /* Configure the LCD Duty, Bias, Voltage Source, Dead Time, Pulse On Duration and Contrast:
213      Set DUTY[2:0] bits according to hlcd->Init.Duty value
214      Set BIAS[1:0] bits according to hlcd->Init.Bias value
215      Set VSEL bit according to hlcd->Init.VoltageSource value
216      Set MUX_SEG bit according to hlcd->Init.MuxSegment value */
217   MODIFY_REG(hlcd->Instance->CR, \
218              (LCD_CR_DUTY | LCD_CR_BIAS | LCD_CR_VSEL | LCD_CR_MUX_SEG), \
219              (hlcd->Init.Duty | hlcd->Init.Bias | hlcd->Init.VoltageSource | hlcd->Init.MuxSegment));
220 
221   /* Enable the peripheral */
222   __HAL_LCD_ENABLE(hlcd);
223 
224   /* Get timeout */
225   tickstart = HAL_GetTick();
226 
227   /* Wait Until the LCD is enabled */
228   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_ENS) == RESET)
229   {
230     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
231     {
232       hlcd->ErrorCode = HAL_LCD_ERROR_ENS;
233       return HAL_TIMEOUT;
234     }
235   }
236 
237   /* Get timeout */
238   tickstart = HAL_GetTick();
239 
240   /*!< Wait Until the LCD Booster is ready */
241   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_RDY) == RESET)
242   {
243     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
244     {
245       hlcd->ErrorCode = HAL_LCD_ERROR_RDY;
246       return HAL_TIMEOUT;
247     }
248   }
249 
250   /* Initialize the LCD state */
251   hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
252   hlcd->State = HAL_LCD_STATE_READY;
253 
254   return status;
255 }
256 
257 /**
258   * @brief  DeInitialize the LCD peripheral.
259   * @param hlcd LCD handle
260   * @retval HAL status
261   */
HAL_LCD_DeInit(LCD_HandleTypeDef * hlcd)262 HAL_StatusTypeDef HAL_LCD_DeInit(LCD_HandleTypeDef *hlcd)
263 {
264   /* Check the LCD handle allocation */
265   if (hlcd == NULL)
266   {
267     return HAL_ERROR;
268   }
269 
270   /* Check the parameters */
271   assert_param(IS_LCD_ALL_INSTANCE(hlcd->Instance));
272 
273   hlcd->State = HAL_LCD_STATE_BUSY;
274 
275   /* DeInit the low level hardware */
276   HAL_LCD_MspDeInit(hlcd);
277 
278   hlcd->ErrorCode = HAL_LCD_ERROR_NONE;
279   hlcd->State = HAL_LCD_STATE_RESET;
280 
281   /* Release Lock */
282   __HAL_UNLOCK(hlcd);
283 
284   return HAL_OK;
285 }
286 
287 /**
288   * @brief  DeInitialize the LCD MSP.
289   * @param hlcd LCD handle
290   * @retval None
291   */
HAL_LCD_MspDeInit(LCD_HandleTypeDef * hlcd)292 __weak void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd)
293 {
294   /* Prevent unused argument(s) compilation warning */
295   UNUSED(hlcd);
296 
297   /* NOTE: This function should not be modified, when the callback is needed,
298            the HAL_LCD_MspDeInit it to be implemented in the user file
299    */
300 }
301 
302 /**
303   * @brief  Initialize the LCD MSP.
304   * @param hlcd LCD handle
305   * @retval None
306   */
HAL_LCD_MspInit(LCD_HandleTypeDef * hlcd)307 __weak void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd)
308 {
309   /* Prevent unused argument(s) compilation warning */
310   UNUSED(hlcd);
311 
312   /* NOTE: This function should not be modified, when the callback is needed,
313            the HAL_LCD_MspInit is to be implemented in the user file
314    */
315 }
316 
317 /**
318   * @}
319   */
320 
321 /** @defgroup LCD_Exported_Functions_Group2 IO operation methods
322   *  @brief LCD RAM functions
323   *
324 @verbatim
325  ===============================================================================
326                       ##### IO operation functions #####
327  ===============================================================================
328  [..] Using its double buffer memory the LCD controller ensures the coherency of the
329  displayed information without having to use interrupts to control LCD_RAM
330  modification.
331  The application software can access the first buffer level (LCD_RAM) through
332  the APB interface. Once it has modified the LCD_RAM using the HAL_LCD_Write() API,
333  it sets the UDR flag in the LCD_SR register using the HAL_LCD_UpdateDisplayRequest() API.
334  This UDR flag (update display request) requests the updated information to be
335  moved into the second buffer level (LCD_DISPLAY).
336  This operation is done synchronously with the frame (at the beginning of the
337  next frame), until the update is completed, the LCD_RAM is write protected and
338  the UDR flag stays high.
339  Once the update is completed another flag (UDD - Update Display Done) is set and
340  generates an interrupt if the UDDIE bit in the LCD_FCR register is set.
341  The time it takes to update LCD_DISPLAY is, in the worst case, one odd and one
342  even frame.
343  The update will not occur (UDR = 1 and UDD = 0) until the display is
344  enabled (LCDEN = 1).
345 
346 @endverbatim
347   * @{
348   */
349 
350 /**
351   * @brief  Write a word in the specific LCD RAM.
352   * @param hlcd LCD handle
353   * @param RAMRegisterIndex specifies the LCD RAM Register.
354   *   This parameter can be one of the following values:
355   *     @arg LCD_RAM_REGISTER0: LCD RAM Register 0
356   *     @arg LCD_RAM_REGISTER1: LCD RAM Register 1
357   *     @arg LCD_RAM_REGISTER2: LCD RAM Register 2
358   *     @arg LCD_RAM_REGISTER3: LCD RAM Register 3
359   *     @arg LCD_RAM_REGISTER4: LCD RAM Register 4
360   *     @arg LCD_RAM_REGISTER5: LCD RAM Register 5
361   *     @arg LCD_RAM_REGISTER6: LCD RAM Register 6
362   *     @arg LCD_RAM_REGISTER7: LCD RAM Register 7
363   *     @arg LCD_RAM_REGISTER8: LCD RAM Register 8
364   *     @arg LCD_RAM_REGISTER9: LCD RAM Register 9
365   *     @arg LCD_RAM_REGISTER10: LCD RAM Register 10
366   *     @arg LCD_RAM_REGISTER11: LCD RAM Register 11
367   *     @arg LCD_RAM_REGISTER12: LCD RAM Register 12
368   *     @arg LCD_RAM_REGISTER13: LCD RAM Register 13
369   *     @arg LCD_RAM_REGISTER14: LCD RAM Register 14
370   *     @arg LCD_RAM_REGISTER15: LCD RAM Register 15
371   * @param RAMRegisterMask specifies the LCD RAM Register Data Mask.
372   * @param Data specifies LCD Data Value to be written.
373   * @retval None
374   */
HAL_LCD_Write(LCD_HandleTypeDef * hlcd,uint32_t RAMRegisterIndex,uint32_t RAMRegisterMask,uint32_t Data)375 HAL_StatusTypeDef HAL_LCD_Write(LCD_HandleTypeDef *hlcd, uint32_t RAMRegisterIndex, uint32_t RAMRegisterMask, uint32_t Data)
376 {
377   uint32_t tickstart;
378   HAL_LCD_StateTypeDef state = hlcd->State;
379 
380   if ((state == HAL_LCD_STATE_READY) || (state == HAL_LCD_STATE_BUSY))
381   {
382     /* Check the parameters */
383     assert_param(IS_LCD_RAM_REGISTER(RAMRegisterIndex));
384 
385     if (hlcd->State == HAL_LCD_STATE_READY)
386     {
387       /* Process Locked */
388       __HAL_LOCK(hlcd);
389       hlcd->State = HAL_LCD_STATE_BUSY;
390 
391       /* Get timeout */
392       tickstart = HAL_GetTick();
393 
394       /*!< Wait Until the LCD is ready */
395       while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDR) != RESET)
396       {
397         if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
398         {
399           hlcd->ErrorCode = HAL_LCD_ERROR_UDR;
400 
401           /* Process Unlocked */
402           __HAL_UNLOCK(hlcd);
403 
404           return HAL_TIMEOUT;
405         }
406       }
407     }
408 
409     /* Copy the new Data bytes to LCD RAM register */
410     MODIFY_REG(hlcd->Instance->RAM[RAMRegisterIndex], ~(RAMRegisterMask), Data);
411 
412     return HAL_OK;
413   }
414   else
415   {
416     return HAL_ERROR;
417   }
418 }
419 
420 /**
421   * @brief Clear the LCD RAM registers.
422   * @param hlcd LCD handle
423   * @retval None
424   */
HAL_LCD_Clear(LCD_HandleTypeDef * hlcd)425 HAL_StatusTypeDef HAL_LCD_Clear(LCD_HandleTypeDef *hlcd)
426 {
427   uint32_t tickstart;
428   uint32_t counter;
429   HAL_StatusTypeDef status = HAL_ERROR;
430   HAL_LCD_StateTypeDef state = hlcd->State;
431 
432   if ((state == HAL_LCD_STATE_READY) || (state == HAL_LCD_STATE_BUSY))
433   {
434     /* Process Locked */
435     __HAL_LOCK(hlcd);
436 
437     hlcd->State = HAL_LCD_STATE_BUSY;
438 
439     /* Get timeout */
440     tickstart = HAL_GetTick();
441 
442     /*!< Wait Until the LCD is ready */
443     while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDR) != RESET)
444     {
445       if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
446       {
447         hlcd->ErrorCode = HAL_LCD_ERROR_UDR;
448 
449         /* Process Unlocked */
450         __HAL_UNLOCK(hlcd);
451 
452         return HAL_TIMEOUT;
453       }
454     }
455     /* Clear the LCD_RAM registers */
456     for (counter = LCD_RAM_REGISTER0; counter <= LCD_RAM_REGISTER15; counter++)
457     {
458       hlcd->Instance->RAM[counter] = 0;
459     }
460 
461     /* Update the LCD display */
462     status = HAL_LCD_UpdateDisplayRequest(hlcd);
463   }
464   return status;
465 }
466 
467 /**
468   * @brief  Enable the Update Display Request.
469   * @param hlcd LCD handle
470   * @note   Each time software modifies the LCD_RAM it must set the UDR bit to
471   *         transfer the updated data to the second level buffer.
472   *         The UDR bit stays set until the end of the update and during this
473   *         time the LCD_RAM is write protected.
474   * @note   When the display is disabled, the update is performed for all
475   *         LCD_DISPLAY locations.
476   *         When the display is enabled, the update is performed only for locations
477   *         for which commons are active (depending on DUTY). For example if
478   *         DUTY = 1/2, only the LCD_DISPLAY of COM0 and COM1 will be updated.
479   * @retval None
480   */
HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef * hlcd)481 HAL_StatusTypeDef HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef *hlcd)
482 {
483   uint32_t tickstart;
484 
485   /* Clear the Update Display Done flag before starting the update display request */
486   __HAL_LCD_CLEAR_FLAG(hlcd, LCD_FLAG_UDD);
487 
488   /* Enable the display request */
489   hlcd->Instance->SR |= LCD_SR_UDR;
490 
491   /* Get timeout */
492   tickstart = HAL_GetTick();
493 
494   /*!< Wait Until the LCD display is done */
495   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_UDD) == RESET)
496   {
497     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
498     {
499       hlcd->ErrorCode = HAL_LCD_ERROR_UDD;
500 
501       /* Process Unlocked */
502       __HAL_UNLOCK(hlcd);
503 
504       return HAL_TIMEOUT;
505     }
506   }
507 
508   hlcd->State = HAL_LCD_STATE_READY;
509 
510   /* Process Unlocked */
511   __HAL_UNLOCK(hlcd);
512 
513   return HAL_OK;
514 }
515 
516 /**
517   * @}
518   */
519 
520 /** @defgroup LCD_Exported_Functions_Group3 Peripheral State methods
521   *  @brief   LCD State functions
522   *
523 @verbatim
524  ===============================================================================
525                       ##### Peripheral State functions #####
526  ===============================================================================
527     [..]
528      This subsection provides a set of functions allowing to control the LCD:
529       (+) HAL_LCD_GetState() API can be helpful to check in run-time the state of the LCD peripheral State.
530       (+) HAL_LCD_GetError() API to return the LCD error code.
531 @endverbatim
532   * @{
533   */
534 
535 /**
536   * @brief Return the LCD handle state.
537   * @param hlcd LCD handle
538   * @retval HAL state
539   */
HAL_LCD_GetState(LCD_HandleTypeDef * hlcd)540 HAL_LCD_StateTypeDef HAL_LCD_GetState(LCD_HandleTypeDef *hlcd)
541 {
542   /* Return LCD handle state */
543   return hlcd->State;
544 }
545 
546 /**
547   * @brief Return the LCD error code.
548   * @param hlcd LCD handle
549   * @retval LCD Error Code
550   */
HAL_LCD_GetError(LCD_HandleTypeDef * hlcd)551 uint32_t HAL_LCD_GetError(LCD_HandleTypeDef *hlcd)
552 {
553   return hlcd->ErrorCode;
554 }
555 
556 /**
557   * @}
558   */
559 
560 /**
561   * @}
562   */
563 
564 /** @defgroup LCD_Private_Functions LCD Private Functions
565   * @{
566   */
567 
568 /**
569   * @brief  Wait until the LCD FCR register is synchronized in the LCDCLK domain.
570   *   This function must be called after any write operation to LCD_FCR register.
571   * @retval None
572   */
LCD_WaitForSynchro(LCD_HandleTypeDef * hlcd)573 HAL_StatusTypeDef LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd)
574 {
575   uint32_t tickstart;
576 
577   /* Get timeout */
578   tickstart = HAL_GetTick();
579 
580   /* Loop until FCRSF flag is set */
581   while (__HAL_LCD_GET_FLAG(hlcd, LCD_FLAG_FCRSF) == RESET)
582   {
583     if ((HAL_GetTick() - tickstart) > LCD_TIMEOUT_VALUE)
584     {
585       hlcd->ErrorCode = HAL_LCD_ERROR_FCRSF;
586       return HAL_TIMEOUT;
587     }
588   }
589 
590   return HAL_OK;
591 }
592 
593 /**
594   * @}
595   */
596 
597 /**
598   * @}
599   */
600 
601 #endif /* HAL_LCD_MODULE_ENABLED */
602 
603 /**
604   * @}
605   */
606 
607 #endif /* STM32L433xx || STM32L443xx || STM32L476xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
608 
609 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
610