stm32l0xx_hal_lcd.h 37 KB

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