Subversion Repositories DashDisplay

Rev

Rev 56 | Details | Compare with Previous | Last modification | View Log | RSS feed

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