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.

stm32l1xx_hal_lcd.h 36KB

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