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