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 /******************************************************************************
59  ** Global type definitions
60  *****************************************************************************/
61 
62 /**
63 ******************************************************************************
64 ** \brief LCD bias源选择
65 *****************************************************************************/
66  typedef enum
67  {
68     LcdInResHighPower = 6,//内部电阻分压,大功耗模式
69     LcdInResLowPower  = 4,//内部电阻分压,小功耗模式
70     LcdInResMidPower  = 2,//内部电阻分压,中功耗模式
71     LcdExtCap          = 1,//电容分压模式,需要外部电路配合
72     LcdExtRes          = 0,//外部电阻模式,需要外部电路配合
73  }en_lcd_biassrc_t;
74 
75 /**
76 ******************************************************************************
77 ** \brief LCD duty选择                  LCD_CR0    Duty
78 *****************************************************************************/
79  typedef enum
80  {
81     LcdStatic = 0u,        // 静态显示
82     LcdDuty2  = 1u,        // 1/2duty
83     LcdDuty3  = 2u,        // 1/3duty
84     LcdDuty4  = 3u,        // 1/4duty
85     LcdDuty6  = 5u,        // 1/6duty
86     LcdDuty8  = 7u,        // 1/8duty
87  }en_lcd_duty_t;
88 
89 /**
90 ******************************************************************************
91 ** \brief LCD bias配置位                 LCD_CR0    Bias
92 *****************************************************************************/
93  typedef enum
94  {
95     LcdBias3 = 0u,        // 1/3 BIAS
96     LcdBias2 = 1u,        // 1/2 BIAS
97  }en_lcd_bias_t;
98 
99 /**
100 ******************************************************************************
101 ** \brief LCD 电压泵时钟频率选择         LCD_CR0    CpClk
102 *****************************************************************************/
103  typedef enum
104  {
105     LcdClk2k  = 0u,        // 2k
106     LcdClk4k  = 1u,        // 4k
107     LcdClk8k  = 2u,        // 8k
108     LcdClk16k = 3u         // 16k
109  }en_lcd_cpclk_t;
110 
111 /**
112 ******************************************************************************
113 ** \brief LCD 扫描频率选择                LCD_CR0    LcdClk
114 *****************************************************************************/
115  typedef enum
116  {
117     LcdClk64hz   = 0u,    // 64hz
118     LcdClk128hz  = 1u,    // 128hz
119     LcdClk256hz  = 2u,    // 256hz
120     LcdClk512hz  = 3u     // 512hz
121  }en_lcd_scanclk_t;
122 
123 /**
124 ******************************************************************************
125 ** \brief LCD 使能控制                    LCD_CR0    EN
126 *****************************************************************************/
127 typedef enum
128 {
129     LcdEnable   =1u,    //LCD使能
130     LcdDisable  =0u     //LCD禁止
131 }en_lcd_en_t;
132 
133 /**
134  ******************************************************************************
135  ** \brief LCD显示模式               LCD_CR1    Mode
136  *****************************************************************************/
137  typedef enum
138  {
139     LcdMode0 = 0,///<模式0
140     LcdMode1 = 1,///<模式1
141  }en_lcd_dispmode_t;
142 
143  /**
144  ******************************************************************************
145  ** \brief LCD时钟源选择             LCD_CR1    ClkSrc
146  *****************************************************************************/
147  typedef enum
148  {
149     LcdXTL = 1,///<外部XTL
150     LcdRCL = 0,///<内部RCL
151  }en_lcd_clk_t;
152 
153 
154 /**
155 ******************************************************************************
156 ** \brief LCD CR1寄存器的使能位、标志位
157 *****************************************************************************/
158 typedef enum
159 {
160     LcdBlinkEn   = 6u,  //LCD闪屏配置位
161     LcdIe        = 9u,  //LCD 中断使能位
162     LcdDmaEn     = 10u, //LCD DMA硬件触发使能位
163 }en_cr1_t;
164 
165 /**
166  ******************************************************************************
167  ** \brief LCD显示SEG COM端口寄存器的配置
168  *****************************************************************************/
169 typedef struct
170 {
171     uint32_t u32Seg0_31;      ///<SEG0-31配置
172     union{
173         uint32_t seg32_51_com0_8;
174         struct
175         {
176             uint32_t Seg32_35     :4;
177             uint32_t Seg36Com7    :1;
178             uint32_t Seg37Com6    :1;
179             uint32_t Seg38Com5    :1;
180             uint32_t Seg39Com4    :1;
181             uint32_t Seg40        :1;
182             uint32_t Seg41        :1;
183             uint32_t Seg42        :1;
184             uint32_t Seg43        :1;
185             uint32_t Mux          :1;
186             uint32_t Seg44        :1;
187             uint32_t Seg45        :1;
188             uint32_t Seg46        :1;
189             uint32_t Seg47        :1;
190             uint32_t Seg48        :1;
191             uint32_t Seg49        :1;
192             uint32_t Seg50        :1;
193             uint32_t Seg51        :1;
194             uint32_t Com0_3       :4;
195         }segcom_bit;
196     }stc_seg32_51_com0_8_t;
197 }stc_lcd_segcom_t;
198 
199 /**
200  ******************************************************************************
201  ** \brief LCD端口配置参数
202  *****************************************************************************/
203 typedef struct stc_lcd_segcompara
204 {
205     en_lcd_duty_t LcdDuty;       ///<占空比
206     en_lcd_biassrc_t LcdBiasSrc; ///<时钟源
207     uint8_t u8MaxSeg;             ///<最大SEG口
208 }stc_lcd_segcompara_t;
209 
210 /**
211  ******************************************************************************
212  ** \brief I2C初始化配置结构
213  *****************************************************************************/
214 typedef struct
215 {
216     en_lcd_biassrc_t    LcdBiasSrc;    //偏置源选择
217     en_lcd_duty_t       LcdDuty;       //duty配置选择
218     en_lcd_bias_t       LcdBias;       //偏压选择
219     en_lcd_cpclk_t      LcdCpClk;      //电压泵时钟频率选择
220     en_lcd_scanclk_t    LcdScanClk;    //扫描频率选择
221     en_lcd_dispmode_t   LcdMode;       //显示模式选择
222     en_lcd_clk_t        LcdClkSrc;     //时钟源选择
223     en_lcd_en_t         LcdEn;         //LCD使能
224 }stc_lcd_cfg_t;
225 
226 /*******************************************************************************
227  ** \brief lcd相关函数声明
228  ******************************************************************************/
229 
230 extern boolean_t Lcd_GetItStatus(void);
231 extern void Lcd_ClearItPendingBit(void);
232 extern en_result_t Lcd_GetSegCom(stc_lcd_segcompara_t *pstcSegComPara,stc_lcd_segcom_t *pstcSegCom);
233 extern void Lcd_SetSegCom(stc_lcd_segcom_t *pstcSegCom);
234 extern void Lcd_Init(stc_lcd_cfg_t *pstcLcdCfg);
235 extern void Lcd_FullDisp(void);
236 extern void Lcd_ClearDisp(void);
237 extern en_result_t Lcd_WriteRam(uint8_t u8Row,uint32_t u32Data);
238 
239 
240 //@} // LCDGroup
241 
242 #ifdef __cplusplus
243 #endif
244 
245 #endif /* __LCD_H__ */
246 /******************************************************************************
247  * EOF (not truncated)
248  *****************************************************************************/
249 
250 
251