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