You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

773 lines
37 KiB

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