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