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