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