Umar Naeem / mbed-dev

Fork of mbed-dev by Umar Naeem

Committer:
ranaumarnaeem
Date:
Tue May 23 12:54:50 2017 +0000
Revision:
165:2dd56e6daeec
Parent:
149:156823d33999
jhjg

Who changed what in which revision?

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