fix LPC812 PWM

Dependents:   IR_LED_Send

Fork of mbed-dev by mbed official

Committer:
nameless129
Date:
Mon May 16 16:50:30 2016 +0000
Revision:
129:2e517c56bcfb
Parent:
113:b3775bf36a83
PWM Fix:Duty 0%??H???????????????

Who changed what in which revision?

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