1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_hal_lcd.h
4   * @author  MCD Application Team
5   * @brief   Header file of LCD Controller HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10   *
11   * Redistribution and use in source and binary forms, with or without modification,
12   * are permitted provided that the following conditions are met:
13   *   1. Redistributions of source code must retain the above copyright notice,
14   *      this list of conditions and the following disclaimer.
15   *   2. Redistributions in binary form must reproduce the above copyright notice,
16   *      this list of conditions and the following disclaimer in the documentation
17   *      and/or other materials provided with the distribution.
18   *   3. Neither the name of STMicroelectronics nor the names of its contributors
19   *      may be used to endorse or promote products derived from this software
20   *      without specific prior written permission.
21   *
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   *
33   ******************************************************************************
34   */
35 
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32L4xx_HAL_LCD_H
38 #define __STM32L4xx_HAL_LCD_H
39 
40 #ifdef __cplusplus
41  extern "C" {
42 #endif
43 
44 #if defined(STM32L433xx) || defined(STM32L443xx) || defined(STM32L476xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
45 
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l4xx_hal_def.h"
48 
49 /** @addtogroup STM32L4xx_HAL_Driver
50   * @{
51   */
52 
53 /** @addtogroup LCD
54   * @{
55   */
56 
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup LCD_Exported_Types LCD Exported Types
59   * @{
60   */
61 
62 /**
63   * @brief LCD Init structure definition
64   */
65 
66 typedef struct
67 {
68   uint32_t Prescaler;       /*!< Configures the LCD Prescaler.
69                                  This parameter can be one value of @ref LCD_Prescaler */
70   uint32_t Divider;         /*!< Configures the LCD Divider.
71                                  This parameter can be one value of @ref LCD_Divider */
72   uint32_t Duty;            /*!< Configures the LCD Duty.
73                                  This parameter can be one value of @ref LCD_Duty */
74   uint32_t Bias;            /*!< Configures the LCD Bias.
75                                  This parameter can be one value of @ref LCD_Bias */
76   uint32_t VoltageSource;   /*!< Selects the LCD Voltage source.
77                                  This parameter can be one value of @ref LCD_Voltage_Source */
78   uint32_t Contrast;        /*!< Configures the LCD Contrast.
79                                  This parameter can be one value of @ref LCD_Contrast */
80   uint32_t DeadTime;        /*!< Configures the LCD Dead Time.
81                                  This parameter can be one value of @ref LCD_DeadTime */
82   uint32_t PulseOnDuration; /*!< Configures the LCD Pulse On Duration.
83                                  This parameter can be one value of @ref LCD_PulseOnDuration */
84   uint32_t HighDrive;       /*!< Enable or disable the low resistance divider.
85                                  This parameter can be one value of @ref LCD_HighDrive */
86   uint32_t BlinkMode;       /*!< Configures the LCD Blink Mode.
87                                  This parameter can be one value of @ref LCD_BlinkMode */
88   uint32_t BlinkFrequency;  /*!< Configures the LCD Blink frequency.
89                                  This parameter can be one value of @ref LCD_BlinkFrequency */
90   uint32_t MuxSegment;      /*!< Enable or disable mux segment.
91                                  This parameter can be one value of @ref LCD_MuxSegment */
92 } LCD_InitTypeDef;
93 
94 /**
95   * @brief HAL LCD State structures definition
96   */
97 typedef enum
98 {
99   HAL_LCD_STATE_RESET             = 0x00,    /*!< Peripheral is not yet Initialized */
100   HAL_LCD_STATE_READY             = 0x01,    /*!< Peripheral Initialized and ready for use */
101   HAL_LCD_STATE_BUSY              = 0x02,    /*!< an internal process is ongoing */
102   HAL_LCD_STATE_TIMEOUT           = 0x03,    /*!< Timeout state */
103   HAL_LCD_STATE_ERROR             = 0x04     /*!< Error */
104 } HAL_LCD_StateTypeDef;
105 
106 /**
107   * @brief  UART handle Structure definition
108   */
109 typedef struct
110 {
111   LCD_TypeDef                   *Instance;  /* LCD registers base address */
112 
113   LCD_InitTypeDef               Init;       /* LCD communication parameters */
114 
115   HAL_LockTypeDef               Lock;       /* Locking object */
116 
117   __IO HAL_LCD_StateTypeDef     State;      /* LCD communication state */
118 
119   __IO uint32_t                 ErrorCode;  /* LCD Error code */
120 
121 }LCD_HandleTypeDef;
122 /**
123   * @}
124   */
125 
126 /* Exported constants --------------------------------------------------------*/
127 /** @defgroup LCD_Exported_Constants LCD Exported Constants
128   * @{
129   */
130 
131 /** @defgroup  LCD_ErrorCode LCD Error Code
132   * @{
133   */
134 #define HAL_LCD_ERROR_NONE       ((uint32_t)0x00)    /*!< No error */
135 #define HAL_LCD_ERROR_FCRSF      ((uint32_t)0x01)    /*!< Synchro flag timeout error */
136 #define HAL_LCD_ERROR_UDR        ((uint32_t)0x02)    /*!< Update display request flag timeout error */
137 #define HAL_LCD_ERROR_UDD        ((uint32_t)0x04)    /*!< Update display done flag timeout error */
138 #define HAL_LCD_ERROR_ENS        ((uint32_t)0x08)    /*!< LCD enabled status flag timeout error */
139 #define HAL_LCD_ERROR_RDY        ((uint32_t)0x10)    /*!< LCD Booster ready timeout error */
140 /**
141   * @}
142   */
143 
144 /** @defgroup LCD_Prescaler LCD Prescaler
145   * @{
146   */
147 #define LCD_PRESCALER_1        ((uint32_t)0x00000000)  /*!< CLKPS = LCDCLK        */
148 #define LCD_PRESCALER_2        ((uint32_t)0x00400000)  /*!< CLKPS = LCDCLK/2      */
149 #define LCD_PRESCALER_4        ((uint32_t)0x00800000)  /*!< CLKPS = LCDCLK/4      */
150 #define LCD_PRESCALER_8        ((uint32_t)0x00C00000)  /*!< CLKPS = LCDCLK/8      */
151 #define LCD_PRESCALER_16       ((uint32_t)0x01000000)  /*!< CLKPS = LCDCLK/16     */
152 #define LCD_PRESCALER_32       ((uint32_t)0x01400000)  /*!< CLKPS = LCDCLK/32     */
153 #define LCD_PRESCALER_64       ((uint32_t)0x01800000)  /*!< CLKPS = LCDCLK/64     */
154 #define LCD_PRESCALER_128      ((uint32_t)0x01C00000)  /*!< CLKPS = LCDCLK/128    */
155 #define LCD_PRESCALER_256      ((uint32_t)0x02000000)  /*!< CLKPS = LCDCLK/256    */
156 #define LCD_PRESCALER_512      ((uint32_t)0x02400000)  /*!< CLKPS = LCDCLK/512    */
157 #define LCD_PRESCALER_1024     ((uint32_t)0x02800000)  /*!< CLKPS = LCDCLK/1024   */
158 #define LCD_PRESCALER_2048     ((uint32_t)0x02C00000)  /*!< CLKPS = LCDCLK/2048   */
159 #define LCD_PRESCALER_4096     ((uint32_t)0x03000000)  /*!< CLKPS = LCDCLK/4096   */
160 #define LCD_PRESCALER_8192     ((uint32_t)0x03400000)  /*!< CLKPS = LCDCLK/8192   */
161 #define LCD_PRESCALER_16384    ((uint32_t)0x03800000)  /*!< CLKPS = LCDCLK/16384  */
162 #define LCD_PRESCALER_32768    ((uint32_t)0x03C00000)  /*!< CLKPS = LCDCLK/32768  */
163 /**
164   * @}
165   */
166 
167 /** @defgroup LCD_Divider LCD Divider
168   * @{
169   */
170 #define LCD_DIVIDER_16    ((uint32_t)0x00000000)  /*!< LCD frequency = CLKPS/16 */
171 #define LCD_DIVIDER_17    ((uint32_t)0x00040000)  /*!< LCD frequency = CLKPS/17 */
172 #define LCD_DIVIDER_18    ((uint32_t)0x00080000)  /*!< LCD frequency = CLKPS/18 */
173 #define LCD_DIVIDER_19    ((uint32_t)0x000C0000)  /*!< LCD frequency = CLKPS/19 */
174 #define LCD_DIVIDER_20    ((uint32_t)0x00100000)  /*!< LCD frequency = CLKPS/20 */
175 #define LCD_DIVIDER_21    ((uint32_t)0x00140000)  /*!< LCD frequency = CLKPS/21 */
176 #define LCD_DIVIDER_22    ((uint32_t)0x00180000)  /*!< LCD frequency = CLKPS/22 */
177 #define LCD_DIVIDER_23    ((uint32_t)0x001C0000)  /*!< LCD frequency = CLKPS/23 */
178 #define LCD_DIVIDER_24    ((uint32_t)0x00200000)  /*!< LCD frequency = CLKPS/24 */
179 #define LCD_DIVIDER_25    ((uint32_t)0x00240000)  /*!< LCD frequency = CLKPS/25 */
180 #define LCD_DIVIDER_26    ((uint32_t)0x00280000)  /*!< LCD frequency = CLKPS/26 */
181 #define LCD_DIVIDER_27    ((uint32_t)0x002C0000)  /*!< LCD frequency = CLKPS/27 */
182 #define LCD_DIVIDER_28    ((uint32_t)0x00300000)  /*!< LCD frequency = CLKPS/28 */
183 #define LCD_DIVIDER_29    ((uint32_t)0x00340000)  /*!< LCD frequency = CLKPS/29 */
184 #define LCD_DIVIDER_30    ((uint32_t)0x00380000)  /*!< LCD frequency = CLKPS/30 */
185 #define LCD_DIVIDER_31    ((uint32_t)0x003C0000)  /*!< LCD frequency = CLKPS/31 */
186 /**
187   * @}
188   */
189 
190 
191 /** @defgroup LCD_Duty LCD Duty
192   * @{
193   */
194 #define LCD_DUTY_STATIC                 ((uint32_t)0x00000000)            /*!< Static duty */
195 #define LCD_DUTY_1_2                    (LCD_CR_DUTY_0)                   /*!< 1/2 duty    */
196 #define LCD_DUTY_1_3                    (LCD_CR_DUTY_1)                   /*!< 1/3 duty    */
197 #define LCD_DUTY_1_4                    ((LCD_CR_DUTY_1 | LCD_CR_DUTY_0)) /*!< 1/4 duty    */
198 #define LCD_DUTY_1_8                    (LCD_CR_DUTY_2)                   /*!< 1/8 duty    */
199 /**
200   * @}
201   */
202 
203 
204 /** @defgroup LCD_Bias LCD Bias
205   * @{
206   */
207 #define LCD_BIAS_1_4                    ((uint32_t)0x00000000)  /*!< 1/4 Bias */
208 #define LCD_BIAS_1_2                    LCD_CR_BIAS_0           /*!< 1/2 Bias */
209 #define LCD_BIAS_1_3                    LCD_CR_BIAS_1           /*!< 1/3 Bias */
210 /**
211   * @}
212   */
213 
214 /** @defgroup LCD_Voltage_Source LCD Voltage Source
215   * @{
216   */
217 #define LCD_VOLTAGESOURCE_INTERNAL      ((uint32_t)0x00000000)  /*!< Internal voltage source for the LCD */
218 #define LCD_VOLTAGESOURCE_EXTERNAL      LCD_CR_VSEL             /*!< External voltage source for the LCD */
219 /**
220   * @}
221   */
222 
223 /** @defgroup LCD_Interrupts LCD Interrupts
224   * @{
225   */
226 #define LCD_IT_SOF                      LCD_FCR_SOFIE
227 #define LCD_IT_UDD                      LCD_FCR_UDDIE
228 /**
229   * @}
230   */
231 
232 /** @defgroup LCD_PulseOnDuration LCD Pulse On Duration
233   * @{
234   */
235 #define LCD_PULSEONDURATION_0           ((uint32_t)0x00000000)          /*!< Pulse ON duration = 0 pulse   */
236 #define LCD_PULSEONDURATION_1           (LCD_FCR_PON_0)                 /*!< Pulse ON duration = 1/CK_PS  */
237 #define LCD_PULSEONDURATION_2           (LCD_FCR_PON_1)                 /*!< Pulse ON duration = 2/CK_PS  */
238 #define LCD_PULSEONDURATION_3           (LCD_FCR_PON_1 | LCD_FCR_PON_0) /*!< Pulse ON duration = 3/CK_PS  */
239 #define LCD_PULSEONDURATION_4           (LCD_FCR_PON_2)                 /*!< Pulse ON duration = 4/CK_PS  */
240 #define LCD_PULSEONDURATION_5           (LCD_FCR_PON_2 | LCD_FCR_PON_0) /*!< Pulse ON duration = 5/CK_PS  */
241 #define LCD_PULSEONDURATION_6           (LCD_FCR_PON_2 | LCD_FCR_PON_1) /*!< Pulse ON duration = 6/CK_PS  */
242 #define LCD_PULSEONDURATION_7           (LCD_FCR_PON)                   /*!< Pulse ON duration = 7/CK_PS  */
243 /**
244   * @}
245   */
246 
247 
248 /** @defgroup LCD_DeadTime LCD Dead Time
249   * @{
250   */
251 #define LCD_DEADTIME_0                  ((uint32_t)0x00000000)            /*!< No dead Time  */
252 #define LCD_DEADTIME_1                  (LCD_FCR_DEAD_0)                  /*!< One Phase between different couple of Frame   */
253 #define LCD_DEADTIME_2                  (LCD_FCR_DEAD_1)                  /*!< Two Phase between different couple of Frame   */
254 #define LCD_DEADTIME_3                  (LCD_FCR_DEAD_1 | LCD_FCR_DEAD_0) /*!< Three Phase between different couple of Frame */
255 #define LCD_DEADTIME_4                  (LCD_FCR_DEAD_2)                  /*!< Four Phase between different couple of Frame  */
256 #define LCD_DEADTIME_5                  (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_0) /*!< Five Phase between different couple of Frame  */
257 #define LCD_DEADTIME_6                  (LCD_FCR_DEAD_2 | LCD_FCR_DEAD_1) /*!< Six Phase between different couple of Frame   */
258 #define LCD_DEADTIME_7                  (LCD_FCR_DEAD)                    /*!< Seven Phase between different couple of Frame */
259 /**
260   * @}
261   */
262 
263 /** @defgroup LCD_BlinkMode LCD Blink Mode
264   * @{
265   */
266 #define LCD_BLINKMODE_OFF               ((uint32_t)0x00000000)  /*!< Blink disabled            */
267 #define LCD_BLINKMODE_SEG0_COM0         (LCD_FCR_BLINK_0)       /*!< Blink enabled on SEG[0], COM[0] (1 pixel)   */
268 #define LCD_BLINKMODE_SEG0_ALLCOM       (LCD_FCR_BLINK_1)       /*!< Blink enabled on SEG[0], all COM (up to
269                                                                     8 pixels according to the programmed duty)  */
270 #define LCD_BLINKMODE_ALLSEG_ALLCOM     (LCD_FCR_BLINK)         /*!< Blink enabled on all SEG and all COM (all pixels)  */
271 /**
272   * @}
273   */
274 
275 /** @defgroup LCD_BlinkFrequency LCD Blink Frequency
276   * @{
277   */
278 #define LCD_BLINKFREQUENCY_DIV8         ((uint32_t)0x00000000)                /*!< The Blink frequency = fLCD/8    */
279 #define LCD_BLINKFREQUENCY_DIV16        (LCD_FCR_BLINKF_0)                    /*!< The Blink frequency = fLCD/16   */
280 #define LCD_BLINKFREQUENCY_DIV32        (LCD_FCR_BLINKF_1)                    /*!< The Blink frequency = fLCD/32   */
281 #define LCD_BLINKFREQUENCY_DIV64        (LCD_FCR_BLINKF_1 | LCD_FCR_BLINKF_0) /*!< The Blink frequency = fLCD/64   */
282 #define LCD_BLINKFREQUENCY_DIV128       (LCD_FCR_BLINKF_2)                    /*!< The Blink frequency = fLCD/128  */
283 #define LCD_BLINKFREQUENCY_DIV256       (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_0)  /*!< The Blink frequency = fLCD/256  */
284 #define LCD_BLINKFREQUENCY_DIV512       (LCD_FCR_BLINKF_2 |LCD_FCR_BLINKF_1)  /*!< The Blink frequency = fLCD/512  */
285 #define LCD_BLINKFREQUENCY_DIV1024      (LCD_FCR_BLINKF)                      /*!< The Blink frequency = fLCD/1024 */
286 /**
287   * @}
288   */
289 
290 /** @defgroup LCD_Contrast LCD Contrast
291   * @{
292   */
293 #define LCD_CONTRASTLEVEL_0               ((uint32_t)0x00000000)        /*!< Maximum Voltage = 2.60V    */
294 #define LCD_CONTRASTLEVEL_1               (LCD_FCR_CC_0)                /*!< Maximum Voltage = 2.73V    */
295 #define LCD_CONTRASTLEVEL_2               (LCD_FCR_CC_1)                /*!< Maximum Voltage = 2.86V    */
296 #define LCD_CONTRASTLEVEL_3               (LCD_FCR_CC_1 | LCD_FCR_CC_0) /*!< Maximum Voltage = 2.99V    */
297 #define LCD_CONTRASTLEVEL_4               (LCD_FCR_CC_2)                /*!< Maximum Voltage = 3.12V    */
298 #define LCD_CONTRASTLEVEL_5               (LCD_FCR_CC_2 | LCD_FCR_CC_0) /*!< Maximum Voltage = 3.26V    */
299 #define LCD_CONTRASTLEVEL_6               (LCD_FCR_CC_2 | LCD_FCR_CC_1) /*!< Maximum Voltage = 3.40V    */
300 #define LCD_CONTRASTLEVEL_7               (LCD_FCR_CC)                  /*!< Maximum Voltage = 3.55V    */
301 /**
302   * @}
303   */
304 
305 /** @defgroup LCD_RAMRegister LCD RAMRegister
306   * @{
307   */
308 #define LCD_RAM_REGISTER0               ((uint32_t)0x00000000) /*!< LCD RAM Register 0  */
309 #define LCD_RAM_REGISTER1               ((uint32_t)0x00000001) /*!< LCD RAM Register 1  */
310 #define LCD_RAM_REGISTER2               ((uint32_t)0x00000002) /*!< LCD RAM Register 2  */
311 #define LCD_RAM_REGISTER3               ((uint32_t)0x00000003) /*!< LCD RAM Register 3  */
312 #define LCD_RAM_REGISTER4               ((uint32_t)0x00000004) /*!< LCD RAM Register 4  */
313 #define LCD_RAM_REGISTER5               ((uint32_t)0x00000005) /*!< LCD RAM Register 5  */
314 #define LCD_RAM_REGISTER6               ((uint32_t)0x00000006) /*!< LCD RAM Register 6  */
315 #define LCD_RAM_REGISTER7               ((uint32_t)0x00000007) /*!< LCD RAM Register 7  */
316 #define LCD_RAM_REGISTER8               ((uint32_t)0x00000008) /*!< LCD RAM Register 8  */
317 #define LCD_RAM_REGISTER9               ((uint32_t)0x00000009) /*!< LCD RAM Register 9  */
318 #define LCD_RAM_REGISTER10              ((uint32_t)0x0000000A) /*!< LCD RAM Register 10 */
319 #define LCD_RAM_REGISTER11              ((uint32_t)0x0000000B) /*!< LCD RAM Register 11 */
320 #define LCD_RAM_REGISTER12              ((uint32_t)0x0000000C) /*!< LCD RAM Register 12 */
321 #define LCD_RAM_REGISTER13              ((uint32_t)0x0000000D) /*!< LCD RAM Register 13 */
322 #define LCD_RAM_REGISTER14              ((uint32_t)0x0000000E) /*!< LCD RAM Register 14 */
323 #define LCD_RAM_REGISTER15              ((uint32_t)0x0000000F) /*!< LCD RAM Register 15 */
324 /**
325   * @}
326   */
327 
328 /** @defgroup LCD_HighDrive LCD High Drive
329   * @{
330   */
331 
332 #define LCD_HIGHDRIVE_DISABLE             ((uint32_t)0x00000000)        /*!< High drive disabled */
333 #define LCD_HIGHDRIVE_ENABLE              (LCD_FCR_HD)                  /*!< High drive enabled  */
334 /**
335   * @}
336   */
337 
338 /** @defgroup LCD_MuxSegment LCD Mux Segment
339   * @{
340   */
341 
342 #define LCD_MUXSEGMENT_DISABLE            ((uint32_t)0x00000000)        /*!< SEG pin multiplexing disabled */
343 #define LCD_MUXSEGMENT_ENABLE             (LCD_CR_MUX_SEG)              /*!< SEG[31:28] are multiplexed with SEG[43:40]    */
344 /**
345   * @}
346   */
347 
348 /** @defgroup LCD_Flag_Definition LCD Flags Definition
349   * @{
350   */
351 #define LCD_FLAG_ENS                    LCD_SR_ENS   /*!< LCD enabled status */
352 #define LCD_FLAG_SOF                    LCD_SR_SOF   /*!< Start of frame flag */
353 #define LCD_FLAG_UDR                    LCD_SR_UDR   /*!< Update display request */
354 #define LCD_FLAG_UDD                    LCD_SR_UDD   /*!< Update display done */
355 #define LCD_FLAG_RDY                    LCD_SR_RDY   /*!< Ready flag */
356 #define LCD_FLAG_FCRSF                  LCD_SR_FCRSR /*!< LCD Frame Control Register Synchronization flag */
357 /**
358   * @}
359   */
360 
361 /**
362   * @}
363   */
364 
365 /* Exported macros -----------------------------------------------------------*/
366 /** @defgroup LCD_Exported_Macros LCD Exported Macros
367   * @{
368   */
369 
370 /** @brief Reset LCD handle state.
371   * @param  __HANDLE__: specifies the LCD Handle.
372   * @retval None
373   */
374 #define __HAL_LCD_RESET_HANDLE_STATE(__HANDLE__)  ((__HANDLE__)->State = HAL_LCD_STATE_RESET)
375 
376 /** @brief  Enable the LCD peripheral.
377   * @param  __HANDLE__: specifies the LCD Handle.
378   * @retval None
379   */
380 #define __HAL_LCD_ENABLE(__HANDLE__)              SET_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN)
381 
382 /** @brief  Disable the LCD peripheral.
383   * @param  __HANDLE__: specifies the LCD Handle.
384   * @retval None
385   */
386 #define __HAL_LCD_DISABLE(__HANDLE__)             CLEAR_BIT((__HANDLE__)->Instance->CR, LCD_CR_LCDEN)
387 
388 /** @brief  Enable the low resistance divider.
389   * @param  __HANDLE__: specifies the LCD Handle.
390   * @note   Displays with high internal resistance may need a longer drive time to
391   *         achieve satisfactory contrast. This function is useful in this case if
392   *         some additional power consumption can be tolerated.
393   * @note   When this mode is enabled, the PulseOn Duration (PON) have to be
394   *         programmed to 1/CK_PS (LCD_PULSEONDURATION_1).
395   * @retval None
396   */
397 #define __HAL_LCD_HIGHDRIVER_ENABLE(__HANDLE__)                       \
398                   do {                                                \
399                     SET_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \
400                     LCD_WaitForSynchro(__HANDLE__);                   \
401                   } while(0)
402 
403 /** @brief  Disable the low resistance divider.
404   * @param  __HANDLE__: specifies the LCD Handle.
405   * @retval None
406   */
407 #define __HAL_LCD_HIGHDRIVER_DISABLE(__HANDLE__)                        \
408                   do {                                                  \
409                     CLEAR_BIT((__HANDLE__)->Instance->FCR, LCD_FCR_HD); \
410                     LCD_WaitForSynchro(__HANDLE__);                     \
411                   } while(0)
412 
413 /** @brief  Enable the voltage output buffer for higher driving capability.
414   * @param  __HANDLE__: specifies the LCD Handle.
415   * @retval None
416   */
417 #define __HAL_LCD_VOLTAGE_BUFFER_ENABLE(__HANDLE__)   SET_BIT((__HANDLE__)->Instance->CR, LCD_CR_BUFEN)
418 
419 /** @brief  Disable the voltage output buffer for higher driving capability.
420   * @param  __HANDLE__: specifies the LCD Handle.
421   * @retval None
422   */
423 #define __HAL_LCD_VOLTAGE_BUFFER_DISABLE(__HANDLE__)  CLEAR_BIT((__HANDLE__)->Instance->CR, LCD_CR_BUFEN)
424 
425 /**
426   * @brief  Configure the LCD pulse on duration.
427   * @param  __HANDLE__: specifies the LCD Handle.
428   * @param  __DURATION__: specifies the LCD pulse on duration in terms of
429   *         CK_PS (prescaled LCD clock period) pulses.
430   *   This parameter can be one of the following values:
431   *     @arg LCD_PULSEONDURATION_0: 0 pulse
432   *     @arg LCD_PULSEONDURATION_1: Pulse ON duration = 1/CK_PS
433   *     @arg LCD_PULSEONDURATION_2: Pulse ON duration = 2/CK_PS
434   *     @arg LCD_PULSEONDURATION_3: Pulse ON duration = 3/CK_PS
435   *     @arg LCD_PULSEONDURATION_4: Pulse ON duration = 4/CK_PS
436   *     @arg LCD_PULSEONDURATION_5: Pulse ON duration = 5/CK_PS
437   *     @arg LCD_PULSEONDURATION_6: Pulse ON duration = 6/CK_PS
438   *     @arg LCD_PULSEONDURATION_7: Pulse ON duration = 7/CK_PS
439   * @retval None
440   */
441 #define __HAL_LCD_PULSEONDURATION_CONFIG(__HANDLE__, __DURATION__)                        \
442                   do {                                                                    \
443                     MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_PON, (__DURATION__)); \
444                     LCD_WaitForSynchro(__HANDLE__);                                       \
445                   } while(0)
446 
447 /**
448   * @brief  Configure the LCD dead time.
449   * @param  __HANDLE__: specifies the LCD Handle.
450   * @param  __DEADTIME__: specifies the LCD dead time.
451   *   This parameter can be one of the following values:
452   *     @arg LCD_DEADTIME_0: No dead Time
453   *     @arg LCD_DEADTIME_1: One Phase between different couple of Frame
454   *     @arg LCD_DEADTIME_2: Two Phase between different couple of Frame
455   *     @arg LCD_DEADTIME_3: Three Phase between different couple of Frame
456   *     @arg LCD_DEADTIME_4: Four Phase between different couple of Frame
457   *     @arg LCD_DEADTIME_5: Five Phase between different couple of Frame
458   *     @arg LCD_DEADTIME_6: Six Phase between different couple of Frame
459   *     @arg LCD_DEADTIME_7: Seven Phase between different couple of Frame
460   * @retval None
461   */
462 #define __HAL_LCD_DEADTIME_CONFIG(__HANDLE__, __DEADTIME__)                                \
463                   do {                                                                     \
464                     MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_DEAD, (__DEADTIME__)); \
465                     LCD_WaitForSynchro(__HANDLE__);                                        \
466                   } while(0)
467 
468 /**
469   * @brief  Configure the LCD contrast.
470   * @param  __HANDLE__: specifies the LCD Handle.
471   * @param  __CONTRAST__: specifies the LCD Contrast.
472   *   This parameter can be one of the following values:
473   *     @arg LCD_CONTRASTLEVEL_0: Maximum Voltage = 2.60V
474   *     @arg LCD_CONTRASTLEVEL_1: Maximum Voltage = 2.73V
475   *     @arg LCD_CONTRASTLEVEL_2: Maximum Voltage = 2.86V
476   *     @arg LCD_CONTRASTLEVEL_3: Maximum Voltage = 2.99V
477   *     @arg LCD_CONTRASTLEVEL_4: Maximum Voltage = 3.12V
478   *     @arg LCD_CONTRASTLEVEL_5: Maximum Voltage = 3.25V
479   *     @arg LCD_CONTRASTLEVEL_6: Maximum Voltage = 3.38V
480   *     @arg LCD_CONTRASTLEVEL_7: Maximum Voltage = 3.51V
481   * @retval None
482   */
483 #define __HAL_LCD_CONTRAST_CONFIG(__HANDLE__, __CONTRAST__)                           \
484               do {                                                                    \
485                 MODIFY_REG((__HANDLE__)->Instance->FCR, LCD_FCR_CC, (__CONTRAST__));  \
486                 LCD_WaitForSynchro(__HANDLE__);                                       \
487               } while(0)
488 
489 /**
490   * @brief  Configure the LCD Blink mode and Blink frequency.
491   * @param  __HANDLE__: specifies the LCD Handle.
492   * @param  __BLINKMODE__: specifies the LCD blink mode.
493   *   This parameter can be one of the following values:
494   *     @arg LCD_BLINKMODE_OFF:           Blink disabled
495   *     @arg LCD_BLINKMODE_SEG0_COM0:     Blink enabled on SEG[0], COM[0] (1 pixel)
496   *     @arg LCD_BLINKMODE_SEG0_ALLCOM:   Blink enabled on SEG[0], all COM (up to 8
497   *                                       pixels according to the programmed duty)
498   *     @arg LCD_BLINKMODE_ALLSEG_ALLCOM: Blink enabled on all SEG and all COM
499   *                                       (all pixels)
500   * @param  __BLINKFREQUENCY__: specifies the LCD blink frequency.
501   *     @arg LCD_BLINKFREQUENCY_DIV8:    The Blink frequency = fLcd/8
502   *     @arg LCD_BLINKFREQUENCY_DIV16:   The Blink frequency = fLcd/16
503   *     @arg LCD_BLINKFREQUENCY_DIV32:   The Blink frequency = fLcd/32
504   *     @arg LCD_BLINKFREQUENCY_DIV64:   The Blink frequency = fLcd/64
505   *     @arg LCD_BLINKFREQUENCY_DIV128:  The Blink frequency = fLcd/128
506   *     @arg LCD_BLINKFREQUENCY_DIV256:  The Blink frequency = fLcd/256
507   *     @arg LCD_BLINKFREQUENCY_DIV512:  The Blink frequency = fLcd/512
508   *     @arg LCD_BLINKFREQUENCY_DIV1024: The Blink frequency = fLcd/1024
509   * @retval None
510   */
511 #define __HAL_LCD_BLINK_CONFIG(__HANDLE__, __BLINKMODE__, __BLINKFREQUENCY__)         \
512               do {                                                                    \
513                 MODIFY_REG((__HANDLE__)->Instance->FCR, (LCD_FCR_BLINKF | LCD_FCR_BLINK), ((__BLINKMODE__) | (__BLINKFREQUENCY__))); \
514                 LCD_WaitForSynchro(__HANDLE__);                                       \
515               } while(0)
516 
517 /** @brief  Enable the specified LCD interrupt.
518   * @param  __HANDLE__: specifies the LCD Handle.
519   * @param  __INTERRUPT__: specifies the LCD interrupt source to be enabled.
520   *          This parameter can be one of the following values:
521   *     @arg LCD_IT_SOF: Start of Frame Interrupt
522   *     @arg LCD_IT_UDD: Update Display Done Interrupt
523   * @retval None
524   */
525 #define __HAL_LCD_ENABLE_IT(__HANDLE__, __INTERRUPT__)                      \
526                   do {                                                      \
527                     SET_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__));  \
528                     LCD_WaitForSynchro(__HANDLE__);                         \
529                   } while(0)
530 
531 /** @brief  Disable the specified LCD interrupt.
532   * @param  __HANDLE__: specifies the LCD Handle.
533   * @param  __INTERRUPT__: specifies the LCD interrupt source to be disabled.
534   *          This parameter can be one of the following values:
535   *     @arg LCD_IT_SOF: Start of Frame Interrupt
536   *     @arg LCD_IT_UDD: Update Display Done Interrupt
537   * @retval None
538   */
539 #define __HAL_LCD_DISABLE_IT(__HANDLE__, __INTERRUPT__)                      \
540                   do {                                                       \
541                     CLEAR_BIT((__HANDLE__)->Instance->FCR, (__INTERRUPT__)); \
542                     LCD_WaitForSynchro(__HANDLE__);                          \
543                   } while(0)
544 
545 /** @brief  Check whether the specified LCD interrupt source is enabled or not.
546   * @param  __HANDLE__: specifies the LCD Handle.
547   * @param  __IT__: specifies the LCD interrupt source to check.
548   *        This parameter can be one of the following values:
549   *        @arg LCD_IT_SOF: Start of Frame Interrupt
550   *        @arg LCD_IT_UDD: Update Display Done Interrupt.
551   * @note If the device is in STOP mode (PCLK not provided) UDD will not
552   *          generate an interrupt even if UDDIE = 1.
553   *          If the display is not enabled the UDD interrupt will never occur.
554   * @retval The state of __IT__ (TRUE or FALSE).
555   */
556 #define __HAL_LCD_GET_IT_SOURCE(__HANDLE__, __IT__) (((__HANDLE__)->Instance->FCR) & (__IT__))
557 
558 /** @brief  Check whether the specified LCD flag is set or not.
559   * @param  __HANDLE__: specifies the LCD Handle.
560   * @param  __FLAG__: specifies the flag to check.
561   *        This parameter can be one of the following values:
562   *        @arg LCD_FLAG_ENS: LCD Enabled flag. It indicates the LCD controller status.
563   * @note  The ENS bit is set immediately when the LCDEN bit in the LCD_CR
564   *             goes from 0 to 1. On deactivation it reflects the real status of
565   *             LCD so it becomes 0 at the end of the last displayed frame.
566   *        @arg LCD_FLAG_SOF: Start of Frame flag. This flag is set by hardware at
567   *             the beginning of a new frame, at the same time as the display data is
568   *             updated.
569   *        @arg LCD_FLAG_UDR: Update Display Request flag.
570   *        @arg LCD_FLAG_UDD: Update Display Done flag.
571   *        @arg LCD_FLAG_RDY: Step_up converter Ready flag. It indicates the status
572   *             of the step-up converter.
573   *        @arg LCD_FLAG_FCRSF: LCD Frame Control Register Synchronization Flag.
574   *             This flag is set by hardware each time the LCD_FCR register is updated
575   *             in the LCDCLK domain.
576   * @retval The new state of __FLAG__ (TRUE or FALSE).
577   */
578 #define __HAL_LCD_GET_FLAG(__HANDLE__, __FLAG__)    (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
579 
580 /** @brief  Clear the specified LCD pending flag.
581   * @param  __HANDLE__: specifies the LCD Handle.
582   * @param  __FLAG__: specifies the flag to clear.
583   *        This parameter can be any combination of the following values:
584   *        @arg LCD_FLAG_SOF: Start of Frame Interrupt
585   *        @arg LCD_FLAG_UDD: Update Display Done Interrupt
586   * @retval None
587   */
588 #define __HAL_LCD_CLEAR_FLAG(__HANDLE__, __FLAG__)  WRITE_REG((__HANDLE__)->Instance->CLR, (__FLAG__))
589 
590 /**
591   * @}
592   */
593 
594 /* Exported functions ------------------------------------------------------- */
595 /** @addtogroup LCD_Exported_Functions
596   * @{
597   */
598 
599 /* Initialization/de-initialization methods  **********************************/
600 /** @addtogroup LCD_Exported_Functions_Group1
601   * @{
602   */
603 HAL_StatusTypeDef    HAL_LCD_DeInit(LCD_HandleTypeDef *hlcd);
604 HAL_StatusTypeDef    HAL_LCD_Init(LCD_HandleTypeDef *hlcd);
605 void                 HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd);
606 void                 HAL_LCD_MspDeInit(LCD_HandleTypeDef *hlcd);
607 /**
608   * @}
609   */
610 
611 /* IO operation methods *******************************************************/
612 /** @addtogroup LCD_Exported_Functions_Group2
613   * @{
614   */
615 HAL_StatusTypeDef    HAL_LCD_Write(LCD_HandleTypeDef *hlcd, uint32_t RAMRegisterIndex, uint32_t RAMRegisterMask, uint32_t Data);
616 HAL_StatusTypeDef    HAL_LCD_Clear(LCD_HandleTypeDef *hlcd);
617 HAL_StatusTypeDef    HAL_LCD_UpdateDisplayRequest(LCD_HandleTypeDef *hlcd);
618 /**
619   * @}
620   */
621 
622 /* Peripheral State methods  **************************************************/
623 /** @addtogroup LCD_Exported_Functions_Group3
624   * @{
625   */
626 HAL_LCD_StateTypeDef HAL_LCD_GetState(LCD_HandleTypeDef *hlcd);
627 uint32_t             HAL_LCD_GetError(LCD_HandleTypeDef *hlcd);
628 /**
629   * @}
630   */
631 
632 /**
633   * @}
634   */
635 
636 /* Private types -------------------------------------------------------------*/
637 /* Private variables ---------------------------------------------------------*/
638 /* Private constants ---------------------------------------------------------*/
639 /* Private macros ------------------------------------------------------------*/
640 /** @defgroup LCD_Private_Macros LCD Private Macros
641   * @{
642   */
643 
644 #define IS_LCD_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LCD_PRESCALER_1)     || \
645                                          ((__PRESCALER__) == LCD_PRESCALER_2)     || \
646                                          ((__PRESCALER__) == LCD_PRESCALER_4)     || \
647                                          ((__PRESCALER__) == LCD_PRESCALER_8)     || \
648                                          ((__PRESCALER__) == LCD_PRESCALER_16)    || \
649                                          ((__PRESCALER__) == LCD_PRESCALER_32)    || \
650                                          ((__PRESCALER__) == LCD_PRESCALER_64)    || \
651                                          ((__PRESCALER__) == LCD_PRESCALER_128)   || \
652                                          ((__PRESCALER__) == LCD_PRESCALER_256)   || \
653                                          ((__PRESCALER__) == LCD_PRESCALER_512)   || \
654                                          ((__PRESCALER__) == LCD_PRESCALER_1024)  || \
655                                          ((__PRESCALER__) == LCD_PRESCALER_2048)  || \
656                                          ((__PRESCALER__) == LCD_PRESCALER_4096)  || \
657                                          ((__PRESCALER__) == LCD_PRESCALER_8192)  || \
658                                          ((__PRESCALER__) == LCD_PRESCALER_16384) || \
659                                          ((__PRESCALER__) == LCD_PRESCALER_32768))
660 
661 #define IS_LCD_DIVIDER(__DIVIDER__) (((__DIVIDER__) == LCD_DIVIDER_16) || \
662                                      ((__DIVIDER__) == LCD_DIVIDER_17) || \
663                                      ((__DIVIDER__) == LCD_DIVIDER_18) || \
664                                      ((__DIVIDER__) == LCD_DIVIDER_19) || \
665                                      ((__DIVIDER__) == LCD_DIVIDER_20) || \
666                                      ((__DIVIDER__) == LCD_DIVIDER_21) || \
667                                      ((__DIVIDER__) == LCD_DIVIDER_22) || \
668                                      ((__DIVIDER__) == LCD_DIVIDER_23) || \
669                                      ((__DIVIDER__) == LCD_DIVIDER_24) || \
670                                      ((__DIVIDER__) == LCD_DIVIDER_25) || \
671                                      ((__DIVIDER__) == LCD_DIVIDER_26) || \
672                                      ((__DIVIDER__) == LCD_DIVIDER_27) || \
673                                      ((__DIVIDER__) == LCD_DIVIDER_28) || \
674                                      ((__DIVIDER__) == LCD_DIVIDER_29) || \
675                                      ((__DIVIDER__) == LCD_DIVIDER_30) || \
676                                      ((__DIVIDER__) == LCD_DIVIDER_31))
677 
678 #define IS_LCD_DUTY(__DUTY__) (((__DUTY__) == LCD_DUTY_STATIC)  || \
679                                ((__DUTY__) == LCD_DUTY_1_2)     || \
680                                ((__DUTY__) == LCD_DUTY_1_3)     || \
681                                ((__DUTY__) == LCD_DUTY_1_4)     || \
682                                ((__DUTY__) == LCD_DUTY_1_8))
683 
684 #define IS_LCD_BIAS(__BIAS__) (((__BIAS__) == LCD_BIAS_1_4) || \
685                                ((__BIAS__) == LCD_BIAS_1_2) || \
686                                ((__BIAS__) == LCD_BIAS_1_3))
687 
688 #define IS_LCD_VOLTAGE_SOURCE(SOURCE) (((SOURCE) == LCD_VOLTAGESOURCE_INTERNAL) || \
689                                        ((SOURCE) == LCD_VOLTAGESOURCE_EXTERNAL))
690 
691 
692 #define IS_LCD_PULSE_ON_DURATION(__DURATION__) (((__DURATION__) == LCD_PULSEONDURATION_0) || \
693                                                 ((__DURATION__) == LCD_PULSEONDURATION_1) || \
694                                                 ((__DURATION__) == LCD_PULSEONDURATION_2) || \
695                                                 ((__DURATION__) == LCD_PULSEONDURATION_3) || \
696                                                 ((__DURATION__) == LCD_PULSEONDURATION_4) || \
697                                                 ((__DURATION__) == LCD_PULSEONDURATION_5) || \
698                                                 ((__DURATION__) == LCD_PULSEONDURATION_6) || \
699                                                 ((__DURATION__) == LCD_PULSEONDURATION_7))
700 
701 #define IS_LCD_DEAD_TIME(__TIME__) (((__TIME__) == LCD_DEADTIME_0) || \
702                                     ((__TIME__) == LCD_DEADTIME_1) || \
703                                     ((__TIME__) == LCD_DEADTIME_2) || \
704                                     ((__TIME__) == LCD_DEADTIME_3) || \
705                                     ((__TIME__) == LCD_DEADTIME_4) || \
706                                     ((__TIME__) == LCD_DEADTIME_5) || \
707                                     ((__TIME__) == LCD_DEADTIME_6) || \
708                                     ((__TIME__) == LCD_DEADTIME_7))
709 
710 #define IS_LCD_BLINK_MODE(__MODE__) (((__MODE__) == LCD_BLINKMODE_OFF)            || \
711                                      ((__MODE__) == LCD_BLINKMODE_SEG0_COM0)      || \
712                                      ((__MODE__) == LCD_BLINKMODE_SEG0_ALLCOM)    || \
713                                      ((__MODE__) == LCD_BLINKMODE_ALLSEG_ALLCOM))
714 
715 #define IS_LCD_BLINK_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV8)   || \
716                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV16)  || \
717                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV32)  || \
718                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV64)  || \
719                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV128) || \
720                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV256) || \
721                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV512) || \
722                                                ((__FREQUENCY__) == LCD_BLINKFREQUENCY_DIV1024))
723 
724 #define IS_LCD_CONTRAST(__CONTRAST__) (((__CONTRAST__) == LCD_CONTRASTLEVEL_0) || \
725                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_1) || \
726                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_2) || \
727                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_3) || \
728                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_4) || \
729                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_5) || \
730                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_6) || \
731                                        ((__CONTRAST__) == LCD_CONTRASTLEVEL_7))
732 
733 #define IS_LCD_RAM_REGISTER(__REGISTER__) (((__REGISTER__) == LCD_RAM_REGISTER0)  || \
734                                            ((__REGISTER__) == LCD_RAM_REGISTER1)  || \
735                                            ((__REGISTER__) == LCD_RAM_REGISTER2)  || \
736                                            ((__REGISTER__) == LCD_RAM_REGISTER3)  || \
737                                            ((__REGISTER__) == LCD_RAM_REGISTER4)  || \
738                                            ((__REGISTER__) == LCD_RAM_REGISTER5)  || \
739                                            ((__REGISTER__) == LCD_RAM_REGISTER6)  || \
740                                            ((__REGISTER__) == LCD_RAM_REGISTER7)  || \
741                                            ((__REGISTER__) == LCD_RAM_REGISTER8)  || \
742                                            ((__REGISTER__) == LCD_RAM_REGISTER9)  || \
743                                            ((__REGISTER__) == LCD_RAM_REGISTER10) || \
744                                            ((__REGISTER__) == LCD_RAM_REGISTER11) || \
745                                            ((__REGISTER__) == LCD_RAM_REGISTER12) || \
746                                            ((__REGISTER__) == LCD_RAM_REGISTER13) || \
747                                            ((__REGISTER__) == LCD_RAM_REGISTER14) || \
748                                            ((__REGISTER__) == LCD_RAM_REGISTER15))
749 
750 #define IS_LCD_HIGH_DRIVE(__VALUE__) (((__VALUE__) == LCD_HIGHDRIVE_DISABLE) || \
751                                       ((__VALUE__) == LCD_HIGHDRIVE_ENABLE))
752 
753 #define IS_LCD_MUX_SEGMENT(__VALUE__) (((__VALUE__) == LCD_MUXSEGMENT_ENABLE) || \
754                                        ((__VALUE__) == LCD_MUXSEGMENT_DISABLE))
755 
756 /**
757   * @}
758   */
759 
760 /* Private functions ---------------------------------------------------------*/
761 /** @addtogroup LCD_Private_Functions
762   * @{
763   */
764 
765 HAL_StatusTypeDef     LCD_WaitForSynchro(LCD_HandleTypeDef *hlcd);
766 
767 /**
768   * @}
769   */
770 
771 /**
772   * @}
773   */
774 
775 /**
776   * @}
777   */
778 
779 #endif /* STM32L433xx || STM32L443xx || STM32L476xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
780 
781 #ifdef __cplusplus
782 }
783 #endif
784 
785 #endif /* __STM32L4xx_HAL_LCD_H */
786 
787 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
788