lcd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /******************************************************************************
  2. * Copyright (C) 2018, 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. ** Headerfile for LCD functions
  46. **
  47. **
  48. ** History:
  49. ** - 2018-05-03 CJ First Version
  50. **
  51. *****************************************************************************/
  52. #ifndef __LCD_H__
  53. #define __LCD_H__
  54. #include "ddl.h"
  55. #include "interrupts_hc32l136.h"
  56. /**
  57. *******************************************************************************
  58. ** \def group LCD Group LCD
  59. **
  60. **
  61. ******************************************************************************/
  62. //@{
  63. /******************************************************************************/
  64. /* Global pre-processor symbols/macros ('#define') */
  65. /******************************************************************************/
  66. #define LCDFULLWRITE 0XFFFFFFFF ///<LCD全显
  67. #define LCDFULLCLEAR 0X00000000 ///<LCD全清
  68. #define LCDRAM0_7SIZE 31
  69. #define LCDRAM8_FSIZE 7
  70. #define LCDRAMSIZE 0x0F
  71. /******************************************************************************
  72. * Global type definitions
  73. ******************************************************************************/
  74. /**
  75. ******************************************************************************
  76. ** \brief LCD bias源选择
  77. *****************************************************************************/
  78. typedef enum en_lcd_biassrc
  79. {
  80. LcdInRes_High = 6,///<内部电阻分压,大功耗模式
  81. LcdInRes_Low = 4,///<内部电阻分压,小功耗模式
  82. LcdInRes_Mid = 2,///<内部电阻分压,中功耗模式
  83. LcdExtCap = 1,///<外部电容分压模式
  84. LcdExtRes = 0,///<外部电阻模式
  85. }en_lcd_biassrc_t;
  86. /**
  87. ******************************************************************************
  88. ** \brief LCD duty源选择
  89. *****************************************************************************/
  90. typedef enum en_lcd_duty
  91. {
  92. LcdStatic = 0,///<静态
  93. LcdDuty2 = 1,///<1/2duty
  94. LcdDuty3 = 2,///<1/3duty
  95. LcdDuty4 = 3,///<1/4duty
  96. LcdDuty6 = 5,///<1/6duty
  97. LcdDuty8 = 7,///<1/8duty
  98. }en_lcd_duty_t;
  99. /**
  100. ******************************************************************************
  101. ** \brief LCD bias配置
  102. *****************************************************************************/
  103. typedef enum en_lcd_bias
  104. {
  105. LcdBias3 = 0,///<1/3 BIAS
  106. LcdBias2 = 1,///<1/2 BIAS
  107. }en_lcd_bias_t;
  108. /**
  109. ******************************************************************************
  110. ** \brief LCD 电压泵时钟频率配置
  111. *****************************************************************************/
  112. typedef enum en_lcd_cpclk
  113. {
  114. LcdClk2k = 0,///<2k
  115. LcdClk4k = 1,///<4k
  116. LcdClk8k = 2,///<8k
  117. LcdClk16k = 3,///<16k
  118. }en_lcd_cpclk_t;
  119. /**
  120. ******************************************************************************
  121. ** \brief LCD 扫描频率配置
  122. *****************************************************************************/
  123. typedef enum en_lcd_scanclk
  124. {
  125. LcdClk64hz = 0,///<64hz
  126. LcdClk128hz = 1,///<128hz
  127. LcdClk256hz = 2,///<256hz
  128. LcdClk512hz = 3,///<512hz
  129. }en_lcd_scanclk_t;
  130. /**
  131. ******************************************************************************
  132. ** \brief LCD功能使能
  133. *****************************************************************************/
  134. typedef enum en_lcd_func
  135. {
  136. LcdEn = 0,///<模块使能
  137. LcdBlinkEn = 1,///<LCD闪屏使能
  138. }en_lcd_func_t;
  139. /**
  140. ******************************************************************************
  141. ** \brief LCD显示模式
  142. *****************************************************************************/
  143. typedef enum en_lcd_dispmode
  144. {
  145. LcdMode0 = 0,///<模式0
  146. LcdMode1 = 1,///<模式1
  147. }en_lcd_dispmode_t;
  148. /**
  149. ******************************************************************************
  150. ** \brief LCD时钟源选择
  151. *****************************************************************************/
  152. typedef enum en_lcd_clk
  153. {
  154. LcdXTL = 1,///<外部32k
  155. LcdRCL = 0,///<内部32k
  156. }en_lcd_clk_t;
  157. /**
  158. ******************************************************************************
  159. ** \brief LCD显示SEG COM端口配置
  160. *****************************************************************************/
  161. typedef struct stc_lcd_segcom
  162. {
  163. uint32_t u32Seg0_31; ///<SEG0-31配置
  164. boolean_t bMux; ///<SEG32-35
  165. uint8_t u8Com0_3; ///<COM0-3配置
  166. union Seg32_39VLcdCom7_4 ///<Seg32_39/Com7_4配置
  167. {
  168. uint8_t SegVLcdCom;
  169. struct
  170. {
  171. uint8_t Seg39Com4 :1;
  172. uint8_t Seg38Com5 :1;
  173. uint8_t Seg37Com6 :1;
  174. uint8_t Seg36Com7 :1;
  175. uint8_t Seg35LcdH :1;
  176. uint8_t Seg34Lcd3 :1;
  177. uint8_t Seg33Lcd2 :1;
  178. uint8_t Seg32Lcd1 :1;
  179. }Bits;
  180. }Seg32_39VLcdCom7_4_t;
  181. }stc_lcd_segcom_t;
  182. /**
  183. ******************************************************************************
  184. ** \brief LCD端口配置参数
  185. *****************************************************************************/
  186. typedef struct stc_lcd_segcompara
  187. {
  188. en_lcd_duty_t enDuty; ///<占空比
  189. en_lcd_biassrc_t enBiasSrc; ///<时钟源
  190. uint8_t u8MaxSeg; ///<最大SEG口
  191. }stc_lcd_segcompara_t;
  192. /**
  193. ******************************************************************************
  194. ** \brief I2C初始化配置结构
  195. *****************************************************************************/
  196. typedef struct stc_lcd_config
  197. {
  198. en_lcd_biassrc_t enBiasSrc; ///<Bias源选择
  199. en_lcd_duty_t enDuty; ///<占空比选择
  200. en_lcd_bias_t enBias; ///bias配置
  201. en_lcd_cpclk_t enCpClk; ///<电压泵时钟频率选择
  202. en_lcd_scanclk_t enScanClk; ///<扫描频率选择
  203. en_lcd_dispmode_t enDispMode;///<显示模式选择
  204. en_lcd_clk_t enClk; ///<模块clk选择
  205. boolean_t bTouchNvic; ///<是否使能NVIC
  206. }stc_lcd_config_t;
  207. /******************************************************************************
  208. * Global variable declarations ('extern', definition in C source)
  209. *****************************************************************************/
  210. /******************************************************************************
  211. * Global function prototypes (definition in C source)
  212. *****************************************************************************/
  213. //LCD初始化函数
  214. en_result_t LCD_Init(stc_lcd_config_t *pstcLcdCfg);
  215. //lcd模块关闭函数
  216. en_result_t LCD_DeInit(void);
  217. //lcd 时钟源选择函数
  218. en_result_t LCD_SetClkSrc(en_lcd_clk_t enLcdClk);
  219. //lcd bias源选择函数
  220. en_result_t LCD_SelBiasSrc(en_lcd_biassrc_t enBiasSrc);
  221. //lcd duty配置函数
  222. en_result_t LCD_SetDuty(en_lcd_duty_t enDuty);
  223. //lcd bias配置函数
  224. en_result_t LCD_SetBias(en_lcd_bias_t enBias);
  225. //lcd电压泵时钟频率选择
  226. en_result_t LCD_SelCpClk(en_lcd_cpclk_t enCpClk);
  227. //lcd扫描频率选择
  228. en_result_t LCD_SelScanClk(en_lcd_scanclk_t enScanClk);
  229. //lcd 功能使能禁止函数
  230. en_result_t LCD_EnFunc(en_lcd_func_t enFunc,boolean_t bFlag);
  231. //lcd显示模式函数
  232. en_result_t LCD_SetDispMode(en_lcd_dispmode_t enDispMode);
  233. //lcd对比度设置
  234. en_result_t LCD_SetContrast(uint8_t u8Contrast);
  235. //lcd闪屏计数器设置
  236. en_result_t LCD_SetBlinkCnt(uint8_t u8BlinkCnt);
  237. //lcd中断清除
  238. en_result_t LCD_ClrIntState(void);
  239. //LCD运行模式获取端口配置
  240. en_result_t LCD_GetSegCom(stc_lcd_segcompara_t *pstcSegComPara,stc_lcd_segcom_t *pstcSegCom);
  241. //lcd segcom端口配置
  242. en_result_t LCD_SetSegCom(stc_lcd_segcom_t *pstcSegCom);
  243. //lcd全显
  244. en_result_t LCD_FullDisp(void);
  245. //lcd全清
  246. en_result_t LCD_ClearDisp(void);
  247. //lcd写RAM函数
  248. en_result_t LCD_WriteRam(uint16_t u16Row, uint32_t u32List, boolean_t bData);
  249. en_result_t LCD_WriteRam0_7Int32(uint8_t u8Row,uint32_t u32Data);
  250. en_result_t LCD_WriteRam8_FInt8(uint8_t u8Row,uint8_t u8Data);
  251. //@} // LCDGroup
  252. #ifdef __cplusplus
  253. #endif
  254. #endif /* __LCD_H__ */
  255. /******************************************************************************
  256. * EOF (not truncated)
  257. *****************************************************************************/