stm32l1xx_hal_lcd.h 37 KB

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