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