mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
184:08ed48f1de7f
mbed library release version 165

Who changed what in which revision?

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