mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
181:a4cbdfbbd2f4
test with CLOCK_SETUP = 0

Who changed what in which revision?

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