mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
489:119543c9f674
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

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