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