2 ******************************************************************************
3 * @file stm32l0xx_hal_lcd.h
4 * @author MCD Application Team
6 * @date 06-February-2015
7 * @brief Header file of LCD Controller HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 #if defined (STM32L053xx) || defined (STM32L063xx) || defined (STM32L073xx) || defined (STM32L083xx)
40 /* Define to prevent recursive inclusion -------------------------------------*/
41 #ifndef __STM32L0xx_HAL_LCD_H
42 #define __STM32L0xx_HAL_LCD_H
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32l0xx_hal_def.h"
52 /** @addtogroup STM32L0xx_HAL_Driver
56 /** @addtogroup LCD LCD
60 /* Exported types ------------------------------------------------------------*/
61 /** @defgroup LCD_Exported_Types LCD Exported Types
66 * @brief LCD Init structure definition
71 uint32_t Prescaler; /*!< Configures the LCD Prescaler.
72 This parameter can be one value of @ref LCD_Prescaler */
73 uint32_t Divider; /*!< Configures the LCD Divider.
74 This parameter can be one value of @ref LCD_Divider */
75 uint32_t Duty; /*!< Configures the LCD Duty.
76 This parameter can be one value of @ref LCD_Duty */
77 uint32_t Bias; /*!< Configures the LCD Bias.
78 This parameter can be one value of @ref LCD_Bias */
79 uint32_t VoltageSource; /*!< Selects the LCD Voltage source.
80 This parameter can be one value of @ref LCD_Voltage_Source */
81 uint32_t Contrast; /*!< Configures the LCD Contrast.
82 This parameter can be one value of @ref LCD_Contrast */
83 uint32_t DeadTime; /*!< Configures the LCD Dead Time.
84 This parameter can be one value of @ref LCD_DeadTime */
85 uint32_t PulseOnDuration; /*!< Configures the LCD Pulse On Duration.
86 This parameter can be one value of @ref LCD_PulseOnDuration */
87 uint32_t HighDrive; /*!< Configures the LCD High Drive.
88 This parameter can be one value of @ref LCD_HighDrive */
89 uint32_t BlinkMode; /*!< Configures the LCD Blink Mode.
90 This parameter can be one value of @ref LCD_BlinkMode */
91 uint32_t BlinkFrequency; /*!< Configures the LCD Blink frequency.
92 This parameter can be one value of @ref LCD_BlinkFrequency */
96 * @brief HAL LCD State structures definition
100 HAL_LCD_STATE_RESET = 0x00, /*!< Peripheral is not yet Initialized */
101 HAL_LCD_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
102 HAL_LCD_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
103 HAL_LCD_STATE_TIMEOUT = 0x03, /*!< Timeout state */
104 HAL_LCD_STATE_ERROR = 0x04 /*!< Error */
105 }HAL_LCD_StateTypeDef;
108 * @brief UART handle Structure definition
112 LCD_TypeDef *Instance; /* LCD registers base address */
114 LCD_InitTypeDef Init; /* LCD communication parameters */
116 HAL_LockTypeDef Lock; /* Locking object */
118 __IO HAL_LCD_StateTypeDef State; /* LCD communication state */
120 __IO uint32_t ErrorCode; /* LCD Error code */
128 /* Exported constants --------------------------------------------------------*/
130 /** @defgroup LCD_Exported_Constants LCD Exported Constants
134 /** @defgroup LCD_ErrorCode LCD Error Code
137 #define HAL_LCD_ERROR_NONE ((uint32_t)0x00) /*!< No error */
138 #define HAL_LCD_ERROR_FCRSF ((uint32_t)0x01) /*!< Synchro flag timeout error */
139 #define HAL_LCD_ERROR_UDR ((uint32_t)0x02) /*!< Update display request flag timeout error */
140 #define HAL_LCD_ERROR_UDD ((uint32_t)0x04) /*!< Update display done flag timeout error */
141 #define HAL_LCD_ERROR_ENS ((uint32_t)0x08) /*!< LCD enabled status flag timeout error */
142 #define HAL_LCD_ERROR_RDY ((uint32_t)0x10) /*!< LCD Booster ready timeout error */
147 /** @defgroup LCD_Prescaler LCD Prescaler
151 #define LCD_PRESCALER_1 ((uint32_t)0x00000000) /*!< CLKPS = LCDCLK */
152 #define LCD_PRESCALER_2 ((uint32_t)0x00400000) /*!< CLKPS = LCDCLK/2 */
153 #define LCD_PRESCALER_4 ((uint32_t)0x00800000) /*!< CLKPS = LCDCLK/4 */
154 #define LCD_PRESCALER_8 ((uint32_t)0x00C00000) /*!< CLKPS = LCDCLK/8 */
155 #define LCD_PRESCALER_16 ((uint32_t)0x01000000) /*!< CLKPS = LCDCLK/16 */
156 #define LCD_PRESCALER_32 ((uint32_t)0x01400000) /*!< CLKPS = LCDCLK/32 */
157 #define LCD_PRESCALER_64 ((uint32_t)0x01800000) /*!< CLKPS = LCDCLK/64 */
158 #define LCD_PRESCALER_128 ((uint32_t)0x01C00000) /*!< CLKPS = LCDCLK/128 */
159 #define LCD_PRESCALER_256 ((uint32_t)0x02000000) /*!< CLKPS = LCDCLK/256 */
160 #define LCD_PRESCALER_512 ((uint32_t)0x02400000) /*!< CLKPS = LCDCLK/512 */
161 #define LCD_PRESCALER_1024 ((uint32_t)0x02800000) /*!< CLKPS = LCDCLK/1024 */
162 #define LCD_PRESCALER_2048 ((uint32_t)0x02C00000) /*!< CLKPS = LCDCLK/2048 */
163 #define LCD_PRESCALER_4096 ((uint32_t)0x03000000) /*!< CLKPS = LCDCLK/4096 */
164 #define LCD_PRESCALER_8192 ((uint32_t)0x03400000) /*!< CLKPS = LCDCLK/8192 */
165 #define LCD_PRESCALER_16384 ((uint32_t)0x03800000) /*!< CLKPS = LCDCLK/16384 */
166 #define LCD_PRESCALER_32768 ((uint32_t)LCD_FCR_PS) /*!< CLKPS = LCDCLK/32768 */
168 #define IS_LCD_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LCD_PRESCALER_1) || \
169 ((__PRESCALER__) == LCD_PRESCALER_2) || \
170 ((__PRESCALER__) == LCD_PRESCALER_4) || \
171 ((__PRESCALER__) == LCD_PRESCALER_8) || \
172 ((__PRESCALER__) == LCD_PRESCALER_16) || \
173 ((__PRESCALER__) == LCD_PRESCALER_32) || \
174 ((__PRESCALER__) == LCD_PRESCALER_64) || \
175 ((__PRESCALER__) == LCD_PRESCALER_128) || \
176 ((__PRESCALER__) == LCD_PRESCALER_256) || \
177 ((__PRESCALER__) == LCD_PRESCALER_512) || \
178 ((__PRESCALER__) == LCD_PRESCALER_1024) || \
179 ((__PRESCALER__) == LCD_PRESCALER_2048) || \
180 ((__PRESCALER__) == LCD_PRESCALER_4096) || \
181 ((__PRESCALER__) == LCD_PRESCALER_8192) || \
182 ((__PRESCALER__) == LCD_PRESCALER_16384) || \
183 ((__PRESCALER__) == LCD_PRESCALER_32768))
189 /** @defgroup LCD_Divider LCD Divider
193 #define LCD_DIVIDER_16 ((uint32_t)0x00000000) /*!< LCD frequency = CLKPS/16 */
194 #define LCD_DIVIDER_17 ((uint32_t)0x00040000) /*!< LCD frequency = CLKPS/17 */
195 #define LCD_DIVIDER_18 ((uint32_t)0x00080000) /*!< LCD frequency = CLKPS/18 */
196 #define LCD_DIVIDER_19 ((uint32_t)0x000C0000) /*!< LCD frequency = CLKPS/19 */
197 #define LCD_DIVIDER_20 ((uint32_t)0x00100000) /*!< LCD frequency = CLKPS/20 */
198 #define LCD_DIVIDER_21 ((uint32_t)0x00140000) /*!< LCD frequency = CLKPS/21 */
199 #define LCD_DIVIDER_22 ((uint32_t)0x00180000) /*!< LCD frequency = CLKPS/22 */
200 #define LCD_DIVIDER_23 ((uint32_t)0x001C0000) /*!< LCD frequency = CLKPS/23 */
201 #define LCD_DIVIDER_24 ((uint32_t)0x00200000) /*!< LCD frequency = CLKPS/24 */
202 #define LCD_DIVIDER_25 ((uint32_t)0x00240000) /*!< LCD frequency = CLKPS/25 */
203 #define LCD_DIVIDER_26 ((uint32_t)0x00280000) /*!< LCD frequency = CLKPS/26 */
204 #define LCD_DIVIDER_27 ((uint32_t)0x002C0000) /*!< LCD frequency = CLKPS/27 */
205 #define LCD_DIVIDER_28 ((uint32_t)0x00300000) /*!< LCD frequency = CLKPS/28 */
206 #define LCD_DIVIDER_29 ((uint32_t)0x00340000) /*!< LCD frequency = CLKPS/29 */
207 #define LCD_DIVIDER_30 ((uint32_t)0x00380000) /*!< LCD frequency = CLKPS/30 */
208 #define LCD_DIVIDER_31 ((uint32_t)LCD_FCR_DIV) /*!< LCD frequency = CLKPS/31 */
210 #define IS_LCD_DIVIDER(__DIVIDER__) (((__DIVIDER__) == LCD_DIVIDER_16) || \
211 ((__DIVIDER__) == LCD_DIVIDER_17) || \
212 ((__DIVIDER__) == LCD_DIVIDER_18) || \
213 ((__DIVIDER__) == LCD_DIVIDER_19) || \
214 ((__DIVIDER__) == LCD_DIVIDER_20) || \
215 ((__DIVIDER__) == LCD_DIVIDER_21) || \
216 ((__DIVIDER__) == LCD_DIVIDER_22) || \
217 ((__DIVIDER__) == LCD_DIVIDER_23) || \
218 ((__DIVIDER__) == LCD_DIVIDER_24) || \
219 ((__DIVIDER__) == LCD_DIVIDER_25) || \
220 ((__DIVIDER__) == LCD_DIVIDER_26) || \
221 ((__DIVIDER__) == LCD_DIVIDER_27) || \
222 ((__DIVIDER__) == LCD_DIVIDER_28) || \
223 ((__DIVIDER__) == LCD_DIVIDER_29) || \
224 ((__DIVIDER__) == LCD_DIVIDER_30) || \
225 ((__DIVIDER__) == LCD_DIVIDER_31))
232 /** @defgroup LCD_Duty LCD Duty
236 #define LCD_DUTY_STATIC ((uint32_t)0x00000000) /*!< Static duty */
237 #define LCD_DUTY_1_2 (LCD_CR_DUTY_0) /*!< 1/2 duty */
238 #define LCD_DUTY_1_3 (LCD_CR_DUTY_1) /*!< 1/3 duty */
239 #define LCD_DUTY_1_4 ((LCD_CR_DUTY_1 | LCD_CR_DUTY_0)) /*!< 1/4 duty */
240 #define LCD_DUTY_1_8 (LCD_CR_DUTY_2) /*!< 1/8 duty */
242 #define IS_LCD_DUTY(__DUTY__) (((__DUTY__) == LCD_DUTY_STATIC) || \
243 ((__DUTY__) == LCD_DUTY_1_2) || \
244 ((__DUTY__) == LCD_DUTY_1_3) || \
245 ((__DUTY__) == LCD_DUTY_1_4) || \
246 ((__DUTY__) == LCD_DUTY_1_8))
253 /** @defgroup LCD_Bias LCD Bias
257 #define LCD_BIAS_1_4 ((uint32_t)0x00000000) /*!< 1/4 Bias */
258 #define LCD_BIAS_1_2 LCD_CR_BIAS_0 /*!< 1/2 Bias */
259 #define LCD_BIAS_1_3 LCD_CR_BIAS_1 /*!< 1/3 Bias */
261 #define IS_LCD_BIAS(__BIAS__) (((__BIAS__) == LCD_BIAS_1_4) || \
262 ((__BIAS__) == LCD_BIAS_1_2) || \
263 ((__BIAS__) == LCD_BIAS_1_3))
268 /** @defgroup LCD_Voltage_Source LCD Voltage Source
272 #define LCD_VOLTAGESOURCE_INTERNAL ((uint32_t)0x00000000) /*!< Internal voltage source for the LCD */
273 #define LCD_VOLTAGESOURCE_EXTERNAL LCD_CR_VSEL /*!< External voltage source for the LCD */
275 #define IS_LCD_VOLTAGE_SOURCE(SOURCE) (((SOURCE) == LCD_VOLTAGESOURCE_INTERNAL) || \
276 ((SOURCE) == LCD_VOLTAGESOURCE_EXTERNAL))
282 /** @defgroup LCD_Interrupts LCD Interrupts
285 #define LCD_IT_SOF LCD_FCR_SOFIE
286 #define LCD_IT_UDD LCD_FCR_UDDIE
292 /** @defgroup LCD_PulseOnDuration LCD Pulse On Duration
296 #define LCD_PULSEONDURATION_0 ((uint32_t)0x00000000) /*!< Pulse ON duration = 0 pulse */
297 #define LCD_PULSEONDURATION_1 (LCD_FCR_PON_0) /*!< Pulse ON duration = 1/CK_PS */
298 #define LCD_PULSEONDURATION_2 (LCD_FCR_PON_1) /*!< Pulse ON duration = 2/CK_PS */
299 #define LCD_PULSEONDURATION_3 (LCD_FCR_PON_1 | LCD_FCR_PON_0) /*!< Pulse ON duration = 3/CK_PS */
300 #define LCD_PULSEONDURATION_4 (LCD_FCR_PON_2) /*!< Pulse ON duration = 4/CK_PS */
301 #define LCD_PULSEONDURATION_5 (LCD_FCR_PON_2 | LCD_FCR_PON_0) /*!< Pulse ON duration = 5/CK_PS */
302 #define LCD_PULSEONDURATION_6 (LCD_FCR_PON_2 | LCD_FCR_PON_1) /*!< Pulse ON duration = 6/CK_PS */
303 #define LCD_PULSEONDURATION_7 (LCD_FCR_PON) /*!< Pulse ON duration = 7/CK_PS */
305 #define IS_LCD_PULSE_ON_DURATION(__DURATION__) (((__DURATION__) == LCD_PULSEONDURATION_0) || \
306 ((__DURATION__) == LCD_PULSEONDURATION_1) || \
307 ((__DURATION__) == LCD_PULSEONDURATION_2) || \
308 ((__DURATION__) == LCD_PULSEONDURATION_3) || \
309 ((__DURATION__) == LCD_PULSEONDURATION_4) || \
310 ((__DURATION__) == LCD_PULSEONDURATION_5) || \
311 ((__DURATION__) == LCD_PULSEONDURATION_6) || \
312 ((__DURATION__) == LCD_PULSEONDURATION_7))
317 /** @defgroup LCD_HighDrive LCD HighDrive
321 #define LCD_HIGHDRIVE_0 ((uint32_t)0x00000000) /*!< Low resistance Drive */
322 #define LCD_HIGHDRIVE_1 (LCD_FCR_HD) /*!< High resistance Drive */
324 #define IS_LCD_HIGHDRIVE(__HIGHDRIVE__) (((__HIGHDRIVE__) == LCD_HIGHDRIVE_0) || \
325 ((__HIGHDRIVE__) == LCD_HIGHDRIVE_1))
330 /** @defgroup LCD_DeadTime LCD Dead Time
334 #define LCD_DEADTIME_0 ((uint32_t)0x00000000) /*!< No dead Time */
335 #define LCD_DEADTIME_1 (LCD_FCR_DEAD_0) /*!< One Phase between different couple of Frame */
336 #define LCD_DEADTIME_2 (LCD_FCR_DEAD_1) /*!< Two Phase between different couple of Frame */
337 #define LCD_DEADTIME_3 (LCD_FCR_DEAD_1 | LCD_FCR_DEAD_0) /*!< Three Phase between different couple of Frame */
338 #define LCD_DEADTIME_4 (LCD_FCR_DEAD_2) /*!< Four Phase between different couple of Frame */
339 #define LCD_DEADTIME_5 (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_0) /*!< Five Phase between different couple of Frame */
340 #define LCD_DEADTIME_6 (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_1) /*!< Six Phase between different couple of Frame */
341 #define LCD_DEADTIME_7 (LCD_FCR_DEAD) /*!< Seven Phase between different couple of Frame */
343 #define IS_LCD_DEAD_TIME(__TIME__) (((__TIME__) == LCD_DEADTIME_0) || \
344 ((__TIME__) == LCD_DEADTIME_1) || \
345 ((__TIME__) == LCD_DEADTIME_2) || \
346 ((__TIME__) == LCD_DEADTIME_3) || \
347 ((__TIME__) == LCD_DEADTIME_4) || \
348 ((__TIME__) == LCD_DEADTIME_5) || \
349 ((__TIME__) == LCD_DEADTIME_6) || \
350 ((__TIME__) == LCD_DEADTIME_7))
355 /** @defgroup LCD_BlinkMode LCD Blink Mode
359 #define LCD_BLINKMODE_OFF ((uint32_t)0x00000000) /*!< Blink disabled */
360 #define LCD_BLINKMODE_SEG0_COM0 (LCD_FCR_BLINK_0) /*!< Blink enabled on SEG[0], COM[0] (1 pixel) */
361 #define LCD_BLINKMODE_SEG0_ALLCOM (LCD_FCR_BLINK_1) /*!< Blink enabled on SEG[0], all COM (up to
362 8 pixels according to the programmed duty) */
363 #define LCD_BLINKMODE_ALLSEG_ALLCOM (LCD_FCR_BLINK) /*!< Blink enabled on all SEG and all COM (all pixels) */
365 #define IS_LCD_BLINK_MODE(__MODE__) (((__MODE__) == LCD_BLINKMODE_OFF) || \
366 ((__MODE__) == LCD_BLINKMODE_SEG0_COM0) || \
367 ((__MODE__) == LCD_BLINKMODE_SEG0_ALLCOM) || \
368 ((__MODE__) == LCD_BLINKMODE_ALLSEG_ALLCOM))
373 /** @defgroup LCD_BlinkFrequency LCD Blink Frequency
377 #define LCD_BLINKFREQUENCY_DIV8 ((uint32_t)0x00000000) /*!< The Blink frequency = fLCD/8 */
378 #define LCD_BLINKFREQUENCY_DIV16 (LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/16 */
379 #define LCD_BLINKFREQUENCY_DIV32 (LCD_FCR_BLINKF_1) /*!< The Blink frequency = fLCD/32 */
380 #define LCD_BLINKFREQUENCY_DIV64 (LCD_FCR_BLINKF_1 | LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/64 */
381 #define LCD_BLINKFREQUENCY_DIV128 (LCD_FCR_BLINKF_2) /*!< The Blink frequency = fLCD/128 */
382 #define LCD_BLINKFREQUENCY_DIV256 (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/256 */
383 #define LCD_BLINKFREQUENCY_DIV512 (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_1) /*!< The Blink frequency = fLCD/512 */
384 #define LCD_BLINKFREQUENCY_DIV1024 (LCD_FCR_BLINKF) /*!< The Blink frequency = fLCD/1024 */
386 #define IS_LCD_BLINK_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV8) || \
387 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV16) || \
388 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV32) || \
389 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV64) || \
390 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV128) || \
391 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV256) || \
392 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV512) || \
393 ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV1024))
398 /** @defgroup LCD_Contrast LCD Contrast
402 #define LCD_CONTRASTLEVEL_0 ((uint32_t)0x00000000) /*!< Maximum Voltage = 2.60V */
403 #define LCD_CONTRASTLEVEL_1 (LCD_FCR_CC_0) /*!< Maximum Voltage = 2.73V */
404 #define LCD_CONTRASTLEVEL_2 (LCD_FCR_CC_1) /*!< Maximum Voltage = 2.86V */
405 #define LCD_CONTRASTLEVEL_3 (LCD_FCR_CC_1 | LCD_FCR_CC_0) /*!< Maximum Voltage = 2.99V */
406 #define LCD_CONTRASTLEVEL_4 (LCD_FCR_CC_2) /*!< Maximum Voltage = 3.12V */
407 #define LCD_CONTRASTLEVEL_5 (LCD_FCR_CC_2 | LCD_FCR_CC_0) /*!< Maximum Voltage = 3.25V */
408 #define LCD_CONTRASTLEVEL_6 (LCD_FCR_CC_2 | LCD_FCR_CC_1) /*!< Maximum Voltage = 3.38V */
409 #define LCD_CONTRASTLEVEL_7 (LCD_FCR_CC) /*!< Maximum Voltage = 3.51V */
411 #define IS_LCD_CONTRAST(__CONTRAST__) (((__CONTRAST__) == LCD_CONTRASTLEVEL_0) || \
412 ((__CONTRAST__) == LCD_CONTRASTLEVEL_1) || \
413 ((__CONTRAST__) == LCD_CONTRASTLEVEL_2) || \
414 ((__CONTRAST__) == LCD_CONTRASTLEVEL_3) || \
415 ((__CONTRAST__) == LCD_CONTRASTLEVEL_4) || \
416 ((__CONTRAST__) == LCD_CONTRASTLEVEL_5) || \
417 ((__CONTRAST__) == LCD_CONTRASTLEVEL_6) || \
418 ((__CONTRAST__) == LCD_CONTRASTLEVEL_7))
423 /** @defgroup LCD_Flag LCD Flag
427 #define LCD_FLAG_ENS LCD_SR_ENS
428 #define LCD_FLAG_SOF LCD_SR_SOF
429 #define LCD_FLAG_UDR LCD_SR_UDR
430 #define LCD_FLAG_UDD LCD_SR_UDD
431 #define LCD_FLAG_RDY LCD_SR_RDY
432 #define LCD_FLAG_FCRSF LCD_SR_FCRSR
438 /** @defgroup LCD_RAMRegister LCD RAMRegister
442 #define LCD_RAM_REGISTER0 ((uint32_t)0x00000000) /*!< LCD RAM Register 0 */
443 #define LCD_RAM_REGISTER1 ((uint32_t)0x00000001) /*!< LCD RAM Register 1 */
444 #define LCD_RAM_REGISTER2 ((uint32_t)0x00000002) /*!< LCD RAM Register 2 */
445 #define LCD_RAM_REGISTER3 ((uint32_t)0x00000003) /*!< LCD RAM Register 3 */
446 #define LCD_RAM_REGISTER4 ((uint32_t)0x00000004) /*!< LCD RAM Register 4 */
447 #define LCD_RAM_REGISTER5 ((uint32_t)0x00000005) /*!< LCD RAM Register 5 */
448 #define LCD_RAM_REGISTER6 ((uint32_t)0x00000006) /*!< LCD RAM Register 6 */
449 #define LCD_RAM_REGISTER7 ((uint32_t)0x00000007) /*!< LCD RAM Register 7 */
450 #define LCD_RAM_REGISTER8 ((uint32_t)0x00000008) /*!< LCD RAM Register 8 */
451 #define LCD_RAM_REGISTER9 ((uint32_t)0x00000009) /*!< LCD RAM Register 9 */
452 #define LCD_RAM_REGISTER10 ((uint32_t)0x0000000A) /*!< LCD RAM Register 10 */
453 #define LCD_RAM_REGISTER11 ((uint32_t)0x0000000B) /*!< LCD RAM Register 11 */
454 #define LCD_RAM_REGISTER12 ((uint32_t)0x0000000C) /*!< LCD RAM Register 12 */
455 #define LCD_RAM_REGISTER13 ((uint32_t)0x0000000D) /*!< LCD RAM Register 13 */
456 #define LCD_RAM_REGISTER14 ((uint32_t)0x0000000E) /*!< LCD RAM Register 14 */
457 #define LCD_RAM_REGISTER15 ((uint32_t)0x0000000F) /*!< LCD RAM Register 15 */
459 #define IS_LCD_RAM_REGISTER(__REGISTER__) (((__REGISTER__) == LCD_RAM_REGISTER0) || \
460 ((__REGISTER__) == LCD_RAM_REGISTER1) || \
461 ((__REGISTER__) == LCD_RAM_REGISTER2) || \
462 ((__REGISTER__) == LCD_RAM_REGISTER3) || \
463 ((__REGISTER__) == LCD_RAM_REGISTER4) || \
464 ((__REGISTER__) == LCD_RAM_REGISTER5) || \
465 ((__REGISTER__) == LCD_RAM_REGISTER6) || \
466 ((__REGISTER__) == LCD_RAM_REGISTER7) || \
467 ((__REGISTER__) == LCD_RAM_REGISTER8) || \
468 ((__REGISTER__) == LCD_RAM_REGISTER9) || \
469 ((__REGISTER__) == LCD_RAM_REGISTER10) || \
470 ((__REGISTER__) == LCD_RAM_REGISTER11) || \
471 ((__REGISTER__) == LCD_RAM_REGISTER12) || \
472 ((__REGISTER__) == LCD_RAM_REGISTER13) || \
473 ((__REGISTER__) == LCD_RAM_REGISTER14) || \
474 ((__REGISTER__) == LCD_RAM_REGISTER15))
484 /* Exported macro ------------------------------------------------------------*/
486 /** @defgroup LCD_Exported_Macros LCD Exported Macros
490 /** @brief Reset LCD handle state
491 * @param __HANDLE__: specifies the LCD Handle.
494 #define __HAL_LCD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LCD_STATE_RESET)
496 /** @brief macros to enables or disables the LCD
497 * @param __HANDLE__: specifies the LCD Handle.
500 #define __HAL_LCD_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN))
501 #define __HAL_LCD_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN))
503 /** @brief Macros to enable or disable the low resistance divider. Displays with high
504 * internal resistance may need a longer drive time to achieve
505 * satisfactory contrast. This function is useful in this case if some
506 * additional power consumption can be tolerated.
507 * @param __HANDLE__: specifies the LCD Handle.
508 * @note When this mode is enabled, the PulseOn Duration (PON) have to be
509 * programmed to 1/CK_PS (LCD_PULSEONDURATION_1).
512 #define __HAL_LCD_HIGHDRIVER_ENABLE(__HANDLE__) \
514 SET_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \
515 LCD_WaitForSynchro(__HANDLE__); \
518 #define __HAL_LCD_HIGHDRIVER_DISABLE(__HANDLE__) \
520 CLEAR_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \
521 LCD_WaitForSynchro(__HANDLE__); \
525 * @brief Macro to configure the LCD pulses on duration.
526 * @param __HANDLE__: specifies the LCD Handle.
527 * @param __DURATION__: specifies the LCD pulse on duration in terms of
528 * CK_PS (prescaled LCD clock period) pulses.
529 * This parameter can be one of the following values:
530 * @arg LCD_PULSEONDURATION_0: 0 pulse
531 * @arg LCD_PULSEONDURATION_1: Pulse ON duration = 1/CK_PS
532 * @arg LCD_PULSEONDURATION_2: Pulse ON duration = 2/CK_PS
533 * @arg LCD_PULSEONDURATION_3: Pulse ON duration = 3/CK_PS
534 * @arg LCD_PULSEONDURATION_4: Pulse ON duration = 4/CK_PS
535 * @arg LCD_PULSEONDURATION_5: Pulse ON duration = 5/CK_PS
536 * @arg LCD_PULSEONDURATION_6: Pulse ON duration = 6/CK_PS
537 * @arg LCD_PULSEONDURATION_7: Pulse ON duration = 7/CK_PS
540 #define __HAL_LCD_PULSEONDURATION_CONFIG(__HANDLE__, __DURATION__) \
542 MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_PON, (__DURATION__)); \
543 LCD_WaitForSynchro(__HANDLE__); \
547 * @brief Macro to configure the LCD dead time.
548 * @param __HANDLE__: specifies the LCD Handle.
549 * @param __DEADTIME__: specifies the LCD dead time.
550 * This parameter can be one of the following values:
551 * @arg LCD_DEADTIME_0: No dead Time
552 * @arg LCD_DEADTIME_1: One Phase between different couple of Frame
553 * @arg LCD_DEADTIME_2: Two Phase between different couple of Frame
554 * @arg LCD_DEADTIME_3: Three Phase between different couple of Frame
555 * @arg LCD_DEADTIME_4: Four Phase between different couple of Frame
556 * @arg LCD_DEADTIME_5: Five Phase between different couple of Frame
557 * @arg LCD_DEADTIME_6: Six Phase between different couple of Frame
558 * @arg LCD_DEADTIME_7: Seven Phase between different couple of Frame
561 #define __HAL_LCD_DEADTIME_CONFIG(__HANDLE__, __DEADTIME__) \
563 MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_DEAD, (__DEADTIME__)); \
564 LCD_WaitForSynchro(__HANDLE__); \
568 * @brief Macro to configure the LCD Contrast.
569 * @param __HANDLE__: specifies the LCD Handle.
570 * @param __CONTRAST__: specifies the LCD Contrast.
571 * This parameter can be one of the following values:
572 * @arg LCD_CONTRASTLEVEL_0: Maximum Voltage = 2.60V
573 * @arg LCD_CONTRASTLEVEL_1: Maximum Voltage = 2.73V
574 * @arg LCD_CONTRASTLEVEL_2: Maximum Voltage = 2.86V
575 * @arg LCD_CONTRASTLEVEL_3: Maximum Voltage = 2.99V
576 * @arg LCD_CONTRASTLEVEL_4: Maximum Voltage = 3.12V
577 * @arg LCD_CONTRASTLEVEL_5: Maximum Voltage = 3.25V
578 * @arg LCD_CONTRASTLEVEL_6: Maximum Voltage = 3.38V
579 * @arg LCD_CONTRASTLEVEL_7: Maximum Voltage = 3.51V
582 #define __HAL_LCD_CONTRAST_CONFIG(__HANDLE__, __CONTRAST__) \
584 MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_CC, (__CONTRAST__)); \
585 LCD_WaitForSynchro(__HANDLE__); \
589 * @brief Macro to configure the LCD Blink mode and Blink frequency.
590 * @param __HANDLE__: specifies the LCD Handle.
591 * @param __BLINKMODE__: specifies the LCD blink mode.
592 * This parameter can be one of the following values:
593 * @arg LCD_BLINKMODE_OFF: Blink disabled
594 * @arg LCD_BLINKMODE_SEG0_COM0: Blink enabled on SEG[0], COM[0] (1 pixel)
595 * @arg LCD_BLINKMODE_SEG0_ALLCOM: Blink enabled on SEG[0], all COM (up to 8
596 * pixels according to the programmed duty)
597 * @arg LCD_BLINKMODE_ALLSEG_ALLCOM: Blink enabled on all SEG and all COM
599 * @param __BLINKFREQUENCY__: specifies the LCD blink frequency.
600 * @arg LCD_BLINKFREQUENCY_DIV8: The Blink frequency = fLcd/8
601 * @arg LCD_BLINKFREQUENCY_DIV16: The Blink frequency = fLcd/16
602 * @arg LCD_BLINKFREQUENCY_DIV32: The Blink frequency = fLcd/32
603 * @arg LCD_BLINKFREQUENCY_DIV64: The Blink frequency = fLcd/64
604 * @arg LCD_BLINKFREQUENCY_DIV128: The Blink frequency = fLcd/128
605 * @arg LCD_BLINKFREQUENCY_DIV256: The Blink frequency = fLcd/256
606 * @arg LCD_BLINKFREQUENCY_DIV512: The Blink frequency = fLcd/512
607 * @arg LCD_BLINKFREQUENCY_DIV1024: The Blink frequency = fLcd/1024
610 #define __HAL_LCD_BLINK_CONFIG(__HANDLE__, __BLINKMODE__, __BLINKFREQUENCY__) \
612 MODIFY_REG((__HANDLE__)->Instance->FCR, (LCD_FCR_BLINKF | LCD_FCR_BLINK), ((__BLINKMODE__) | (__BLINKFREQUENCY__))); \
613 LCD_WaitForSynchro(__HANDLE__); \
616 /** @brief Enables or disables the specified LCD interrupt.
617 * @param __HANDLE__: specifies the LCD Handle.
618 * @param __INTERRUPT__: specifies the LCD interrupt source to be enabled or disabled.
619 * This parameter can be one of the following values:
620 * @arg LCD_IT_SOF: Start of Frame Interrupt
621 * @arg LCD_IT_UDD: Update Display Done Interrupt
624 #define __HAL_LCD_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
626 SET_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__)); \
627 LCD_WaitForSynchro(__HANDLE__); \
629 #define __HAL_LCD_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
631 CLEAR_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__)); \
632 LCD_WaitForSynchro(__HANDLE__); \
635 /** @brief Checks whether the specified LCD interrupt is enabled or not.
636 * @param __HANDLE__: specifies the LCD Handle.
637 * @param __IT__: specifies the LCD interrupt source to check.
638 * This parameter can be one of the following values:
639 * @arg LCD_IT_SOF: Start of Frame Interrupt
640 * @arg LCD_IT_UDD: Update Display Done Interrupt.
641 * @note If the device is in STOP mode (PCLK not provided) UDD will not
642 * generate an interrupt even if UDDIE = 1.
643 * If the display is not enabled the UDD interrupt will never occur.
644 * @retval The state of __IT__ (TRUE or FALSE).
646 #define __HAL_LCD_GET_IT_SOURCE(__HANDLE__, __IT__) (((__HANDLE__)->Instance->FCR) & (__IT__))
648 /** @brief Checks whether the specified LCD flag is set or not.
649 * @param __HANDLE__: specifies the LCD Handle.
650 * @param __FLAG__: specifies the flag to check.
651 * This parameter can be one of the following values:
652 * @arg LCD_FLAG_ENS: LCD Enabled flag. It indicates the LCD controller status.
653 * @note The ENS bit is set immediately when the LCDEN bit in the LCD_CR
654 * goes from 0 to 1. On deactivation it reflects the real status of
655 * LCD so it becomes 0 at the end of the last displayed frame.
656 * @arg LCD_FLAG_SOF: Start of Frame flag. This flag is set by hardware at
657 * the beginning of a new frame, at the same time as the display data is
659 * @arg LCD_FLAG_UDR: Update Display Request flag.
660 * @arg LCD_FLAG_UDD: Update Display Done flag.
661 * @arg LCD_FLAG_RDY: Step_up converter Ready flag. It indicates the status
662 * of the step-up converter.
663 * @arg LCD_FLAG_FCRSF: LCD Frame Control Register Synchronization Flag.
664 * This flag is set by hardware each time the LCD_FCR register is updated
665 * in the LCDCLK domain.
666 * @retval The new state of __FLAG__ (TRUE or FALSE).
668 #define __HAL_LCD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
670 /** @brief Clears the specified LCD pending flag.
671 * @param __HANDLE__: specifies the LCD Handle.
672 * @param __FLAG__: specifies the flag to clear.
673 * This parameter can be any combination of the following values:
674 * @arg LCD_FLAG_SOF: Start of Frame Interrupt
675 * @arg LCD_FLAG_UDD: Update Display Done Interrupt
678 #define __HAL_LCD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLR = (__FLAG__))
684 /* Exported functions ------------------------------------------------------- */
686 /** @addtogroup LCD_Exported_Functions
690 /** @addtogroup LCD_Exported_Functions_Group1
694 /* Initialization/de-initialization methods **********************************/
695 HAL_StatusTypeDef HAL_LCD_DeInit(LCD_HandleTypeDef *hlcd);
696 HAL_StatusTypeDef HAL_LCD_Init(LCD_HandleTypeDef *hlcd);
697 void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd);
698 void HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd);
704 /** @addtogroup LCD_Exported_Functions_Group2
708 /* IO operation methods *******************************************************/
709 HAL_StatusTypeDef HAL_LCD_Write(LCD_HandleTypeDef *hlcd, uint32_t RAMRegisterIndex, uint32_t RAMRegisterMask, uint32_t Data);
710 HAL_StatusTypeDef HAL_LCD_Clear(LCD_HandleTypeDef *hlcd);
711 HAL_StatusTypeDef HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef *hlcd);
717 /** @addtogroup LCD_Exported_Functions_Group3
721 /* Peripheral State methods **************************************************/
722 HAL_LCD_StateTypeDef HAL_LCD_GetState(LCD_HandleTypeDef *hlcd);
723 uint32_t HAL_LCD_GetError(LCD_HandleTypeDef *hlcd);
733 /** @addtogroup LCD_Private_Functions
737 /* Private functions ---------------------------------------------------------*/
738 HAL_StatusTypeDef LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd);
756 #endif /* __STM32L0xx_HAL_LCD_H */
759 #endif /* STM32L053xx || STM32L063xx || STM32L073xx || STM32L083xx */
761 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/