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