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