hc32l196_lcd.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /******************************************************************************
  2. * Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved.
  3. *
  4. * This software is owned and published by:
  5. * Huada Semiconductor Co.,Ltd ("HDSC").
  6. *
  7. * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
  8. * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
  9. *
  10. * This software contains source code for use with HDSC
  11. * components. This software is licensed by HDSC to be adapted only
  12. * for use in systems utilizing HDSC components. HDSC shall not be
  13. * responsible for misuse or illegal use of this software for devices not
  14. * supported herein. HDSC is providing this software "AS IS" and will
  15. * not be responsible for issues arising from incorrect user implementation
  16. * of the software.
  17. *
  18. * Disclaimer:
  19. * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
  20. * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
  21. * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
  22. * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
  23. * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
  24. * WARRANTY OF NONINFRINGEMENT.
  25. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
  26. * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
  27. * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
  28. * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
  29. * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
  30. * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
  31. * SAVINGS OR PROFITS,
  32. * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  33. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
  34. * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
  35. * FROM, THE SOFTWARE.
  36. *
  37. * This software may be replicated in part or whole for the licensed use,
  38. * with the restriction that this Disclaimer and Copyright notice must be
  39. * included with each copy of this software, whether used in part or whole,
  40. * at all times.
  41. */
  42. /******************************************************************************/
  43. /** \file lcd.h
  44. **
  45. ** Header file for lcd Converter functions
  46. ** @link LCD Group Some description @endlink
  47. **
  48. ** - 2019-04-02 First Version
  49. **
  50. ******************************************************************************/
  51. #ifndef __LCD_H__
  52. #define __LCD_H__
  53. /******************************************************************************/
  54. /* Include files */
  55. /******************************************************************************/
  56. #include "ddl.h"
  57. /******************************************************************************
  58. ** Global type definitions
  59. *****************************************************************************/
  60. /**
  61. ******************************************************************************
  62. ** \brief LCD bias源选择
  63. *****************************************************************************/
  64. typedef enum
  65. {
  66. LcdInResHighPower = 6,//内部电阻分压,大功耗模式
  67. LcdInResLowPower = 4,//内部电阻分压,小功耗模式
  68. LcdInResMidPower = 2,//内部电阻分压,中功耗模式
  69. LcdExtCap = 1,//电容分压模式,需要外部电路配合
  70. LcdExtRes = 0,//外部电阻模式,需要外部电路配合
  71. }en_lcd_biassrc_t;
  72. /**
  73. ******************************************************************************
  74. ** \brief LCD duty选择 LCD_CR0 Duty
  75. *****************************************************************************/
  76. typedef enum
  77. {
  78. LcdStatic = 0u, // 静态显示
  79. LcdDuty2 = 1u, // 1/2duty
  80. LcdDuty3 = 2u, // 1/3duty
  81. LcdDuty4 = 3u, // 1/4duty
  82. LcdDuty6 = 5u, // 1/6duty
  83. LcdDuty8 = 7u, // 1/8duty
  84. }en_lcd_duty_t;
  85. /**
  86. ******************************************************************************
  87. ** \brief LCD bias配置位 LCD_CR0 Bias
  88. *****************************************************************************/
  89. typedef enum
  90. {
  91. LcdBias3 = 0u, // 1/3 BIAS
  92. LcdBias2 = 1u, // 1/2 BIAS
  93. }en_lcd_bias_t;
  94. /**
  95. ******************************************************************************
  96. ** \brief LCD 电压泵时钟频率选择 LCD_CR0 CpClk
  97. *****************************************************************************/
  98. typedef enum
  99. {
  100. LcdClk2k = 0u, // 2k
  101. LcdClk4k = 1u, // 4k
  102. LcdClk8k = 2u, // 8k
  103. LcdClk16k = 3u // 16k
  104. }en_lcd_cpclk_t;
  105. /**
  106. ******************************************************************************
  107. ** \brief LCD 扫描频率选择 LCD_CR0 LcdClk
  108. *****************************************************************************/
  109. typedef enum
  110. {
  111. LcdClk64hz = 0u, // 64hz
  112. LcdClk128hz = 1u, // 128hz
  113. LcdClk256hz = 2u, // 256hz
  114. LcdClk512hz = 3u // 512hz
  115. }en_lcd_scanclk_t;
  116. /**
  117. ******************************************************************************
  118. ** \brief LCD 使能控制 LCD_CR0 EN
  119. *****************************************************************************/
  120. typedef enum
  121. {
  122. LcdEnable =1u, //LCD使能
  123. LcdDisable =0u //LCD禁止
  124. }en_lcd_en_t;
  125. /**
  126. ******************************************************************************
  127. ** \brief LCD显示模式 LCD_CR1 Mode
  128. *****************************************************************************/
  129. typedef enum
  130. {
  131. LcdMode0 = 0,///<模式0
  132. LcdMode1 = 1,///<模式1
  133. }en_lcd_dispmode_t;
  134. /**
  135. ******************************************************************************
  136. ** \brief LCD时钟源选择 LCD_CR1 ClkSrc
  137. *****************************************************************************/
  138. typedef enum
  139. {
  140. LcdXTL = 1,///<外部XTL
  141. LcdRCL = 0,///<内部RCL
  142. }en_lcd_clk_t;
  143. /**
  144. ******************************************************************************
  145. ** \brief LCD CR1寄存器的使能位、标志位
  146. *****************************************************************************/
  147. typedef enum
  148. {
  149. LcdBlinkEn = 6u, //LCD闪屏配置位
  150. LcdIe = 9u, //LCD 中断使能位
  151. LcdDmaEn = 10u, //LCD DMA硬件触发使能位
  152. }en_cr1_t;
  153. /**
  154. ******************************************************************************
  155. ** \brief LCD显示SEG COM端口寄存器的配置
  156. *****************************************************************************/
  157. typedef struct
  158. {
  159. uint32_t u32Seg0_31; ///<SEG0-31配置
  160. union{
  161. uint32_t seg32_51_com0_8;
  162. struct
  163. {
  164. uint32_t Seg32_35 :4;
  165. uint32_t Seg36Com7 :1;
  166. uint32_t Seg37Com6 :1;
  167. uint32_t Seg38Com5 :1;
  168. uint32_t Seg39Com4 :1;
  169. uint32_t Seg40 :1;
  170. uint32_t Seg41 :1;
  171. uint32_t Seg42 :1;
  172. uint32_t Seg43 :1;
  173. uint32_t Mux :1;
  174. uint32_t Seg44 :1;
  175. uint32_t Seg45 :1;
  176. uint32_t Seg46 :1;
  177. uint32_t Seg47 :1;
  178. uint32_t Seg48 :1;
  179. uint32_t Seg49 :1;
  180. uint32_t Seg50 :1;
  181. uint32_t Seg51 :1;
  182. uint32_t Com0_3 :4;
  183. }segcom_bit;
  184. }stc_seg32_51_com0_8_t;
  185. }stc_lcd_segcom_t;
  186. /**
  187. ******************************************************************************
  188. ** \brief LCD端口配置参数
  189. *****************************************************************************/
  190. typedef struct stc_lcd_segcompara
  191. {
  192. en_lcd_duty_t LcdDuty; ///<占空比
  193. en_lcd_biassrc_t LcdBiasSrc; ///<时钟源
  194. uint8_t u8MaxSeg; ///<最大SEG口
  195. }stc_lcd_segcompara_t;
  196. /**
  197. ******************************************************************************
  198. ** \brief I2C初始化配置结构
  199. *****************************************************************************/
  200. typedef struct
  201. {
  202. en_lcd_biassrc_t LcdBiasSrc; //偏置源选择
  203. en_lcd_duty_t LcdDuty; //duty配置选择
  204. en_lcd_bias_t LcdBias; //偏压选择
  205. en_lcd_cpclk_t LcdCpClk; //电压泵时钟频率选择
  206. en_lcd_scanclk_t LcdScanClk; //扫描频率选择
  207. en_lcd_dispmode_t LcdMode; //显示模式选择
  208. en_lcd_clk_t LcdClkSrc; //时钟源选择
  209. en_lcd_en_t LcdEn; //LCD使能
  210. }stc_lcd_cfg_t;
  211. /*******************************************************************************
  212. ** \brief lcd相关函数声明
  213. ******************************************************************************/
  214. extern boolean_t Lcd_GetItStatus(void);
  215. extern void Lcd_ClearItPendingBit(void);
  216. extern en_result_t Lcd_GetSegCom(stc_lcd_segcompara_t *pstcSegComPara,stc_lcd_segcom_t *pstcSegCom);
  217. extern void Lcd_SetSegCom(stc_lcd_segcom_t *pstcSegCom);
  218. extern void Lcd_Init(stc_lcd_cfg_t *pstcLcdCfg);
  219. extern void Lcd_FullDisp(void);
  220. extern void Lcd_ClearDisp(void);
  221. extern en_result_t Lcd_WriteRam(uint8_t u8Row,uint32_t u32Data);
  222. //@} // LCDGroup
  223. #ifdef __cplusplus
  224. #endif
  225. #endif /* __LCD_H__ */
  226. /******************************************************************************
  227. * EOF (not truncated)
  228. *****************************************************************************/