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.
 
 
 

789 lines
37 KiB

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