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