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