1 /**
2   ******************************************************************************
3   * @file    lib_lcd.h
4   * @author  Application Team
5   * @version V4.5.0
6   * @date    2019-05-14
7   * @brief   LCD library.
8   ******************************************************************************
9   * @attention
10   *
11   ******************************************************************************
12   */
13 #ifndef __LIB_LCD_H
14 #define __LIB_LCD_H
15 
16 #ifdef __cplusplus
17  extern "C" {
18 #endif
19 
20 #include "target.h"
21 
22 /* LCD SEGx IO typedef */
23 typedef struct
24 {
25   __IO uint32_t    *GPIO;
26        uint16_t     Pin;
27 }LCD_SEGIO;
28 
29 /* LCD COMx IO typedef */
30 typedef struct
31 {
32   __IO uint32_t    *GPIO;
33        uint16_t     Pin;
34 }LCD_COMIO;
35 
36 typedef struct
37 {
38   uint32_t Type;
39   uint32_t Drv;
40   uint32_t FRQ;
41   uint32_t SWPR;
42   uint32_t FBMODE;
43   uint32_t BKFILL;
44 } LCD_InitType;
45 //Type
46 #define LCD_TYPE_4COM   LCD_CTRL_TYPE_4COM
47 #define LCD_TYPE_6COM   LCD_CTRL_TYPE_6COM
48 #define LCD_TYPE_8COM   LCD_CTRL_TYPE_8COM
49 //DrivingRes
50 #define LCD_DRV_300     LCD_CTRL_DRV_300KOHM
51 #define LCD_DRV_600     LCD_CTRL_DRV_600KOHM
52 #define LCD_DRV_150     LCD_CTRL_DRV_150KOHM
53 #define LCD_DRV_200     LCD_CTRL_DRV_200KOHM
54 //ScanFRQ
55 #define LCD_FRQ_64H     LCD_CTRL_FRQ_64HZ
56 #define LCD_FRQ_128H    LCD_CTRL_FRQ_128HZ
57 #define LCD_FRQ_256H    LCD_CTRL_FRQ_256HZ
58 #define LCD_FRQ_512H    LCD_CTRL_FRQ_512HZ
59 //SwitchMode
60 #define LCD_FBMODE_BUFA         LCD_CTRL2_FBMODE_BUFA
61 #define LCD_FBMODE_BUFAB        LCD_CTRL2_FBMODE_BUFAANDBUFB
62 #define LCD_FBMODE_BUFABLANK    LCD_CTRL2_FBMODE_BUFAANDBLANK
63 //BlankFill
64 #define LCD_BKFILL_1       LCD_CTRL2_BKFILL
65 #define LCD_BKFILL_0       0
66 
67 //ComMode
68 #define LCD_COMMOD_4COM     1
69 #define LCD_COMMOD_6COM     3
70 #define LCD_COMMOD_8COM     7
71 
72 //BiasSelection
73 #define LCD_BMODE_DIV3                     0
74 #define LCD_BMODE_DIV4       ANA_REG6_LCD_BMODE
75 
76 //VLCDSelection
77 #define LCD_VLCD_0           0
78 #define LCD_VLCD_INC60MV     1
79 #define LCD_VLCD_INC120MV    2
80 #define LCD_VLCD_INC180MV    3
81 #define LCD_VLCD_INC240MV    4
82 #define LCD_VLCD_INC300MV    5
83 #define LCD_VLCD_DEC60MV     6
84 #define LCD_VLCD_DEC120MV    7
85 #define LCD_VLCD_DEC180MV    8
86 #define LCD_VLCD_DEC240MV    9
87 #define LCD_VLCD_DEC300MV    10
88 #define LCD_VLCD_DEC360MV    11
89 #define LCD_VLCD_DEC420MV    12
90 #define LCD_VLCD_DEC480MV    13
91 #define LCD_VLCD_DEC540MV    14
92 #define LCD_VLCD_DEC600MV    15
93 
94 /* Private macros ------------------------------------------------------------*/
95 #define IS_LCD_TYPE(__TYPE__)  (((__TYPE__) == LCD_TYPE_4COM) ||\
96                                 ((__TYPE__) == LCD_TYPE_6COM) ||\
97                                 ((__TYPE__) == LCD_TYPE_8COM))
98 
99 #define IS_LCD_DRV(__DRV__)  (((__DRV__) == LCD_DRV_300) ||\
100                               ((__DRV__) == LCD_DRV_600) ||\
101                               ((__DRV__) == LCD_DRV_150) ||\
102                               ((__DRV__) == LCD_DRV_200))
103 
104 #define IS_LCD_FRQ(__FRQ__)  (((__FRQ__) == LCD_FRQ_64H)  ||\
105                               ((__FRQ__) == LCD_FRQ_128H) ||\
106                               ((__FRQ__) == LCD_FRQ_256H) ||\
107                               ((__FRQ__) == LCD_FRQ_512H))
108 
109 #define IS_LCD_SWPR(__SWPR__)  ((__SWPR__) <= 0xFFUL)
110 
111 #define IS_LCD_FBMODE(__FBMODE__)  (((__FBMODE__) == LCD_FBMODE_BUFA)  ||\
112                                     ((__FBMODE__) == LCD_FBMODE_BUFAB) ||\
113                                     ((__FBMODE__) == LCD_FBMODE_BUFABLANK))
114 
115 #define IS_LCD_BKFILL(__BKFILL__)  (((__BKFILL__) == LCD_BKFILL_1) || ((__BKFILL__) == LCD_BKFILL_0))
116 
117 #define IS_LCD_BMODE(__BMODE__)  (((__BMODE__) == LCD_BMODE_DIV3) ||\
118                                   ((__BMODE__) == LCD_BMODE_DIV4))
119 
120 #define IS_LCD_COMMOD(__COMMOD__)  (((__COMMOD__) == LCD_COMMOD_4COM) ||\
121                                     ((__COMMOD__) == LCD_COMMOD_6COM) ||\
122                                     ((__COMMOD__) == LCD_COMMOD_8COM))
123 
124 #define IS_LCD_VLCD(__VLCD__)  (((__VLCD__) == LCD_VLCD_0)        ||\
125                                 ((__VLCD__) == LCD_VLCD_INC60MV)  ||\
126                                 ((__VLCD__) == LCD_VLCD_INC120MV)  ||\
127                                 ((__VLCD__) == LCD_VLCD_INC180MV) ||\
128                                 ((__VLCD__) == LCD_VLCD_INC240MV) ||\
129                                 ((__VLCD__) == LCD_VLCD_INC300MV) ||\
130                                 ((__VLCD__) == LCD_VLCD_DEC60MV) ||\
131                                 ((__VLCD__) == LCD_VLCD_DEC120MV) ||\
132                                 ((__VLCD__) == LCD_VLCD_DEC180MV) ||\
133                                 ((__VLCD__) == LCD_VLCD_DEC240MV) ||\
134                                 ((__VLCD__) == LCD_VLCD_DEC300MV) ||\
135                                 ((__VLCD__) == LCD_VLCD_DEC360MV) ||\
136                                 ((__VLCD__) == LCD_VLCD_DEC420MV) ||\
137                                 ((__VLCD__) == LCD_VLCD_DEC480MV) ||\
138                                 ((__VLCD__) == LCD_VLCD_DEC540MV) ||\
139                                 ((__VLCD__) == LCD_VLCD_DEC600MV))
140 
141 /* Exported Functions ------------------------------------------------------- */
142 /* LCD Exported Functions Group1:
143                                   (De)Initialization -------------------------*/
144 void LCD_DeInit(void);
145 void LCD_StructInit(LCD_InitType *LCD_InitStruct);
146 void LCD_Init(LCD_InitType *InitStruct);
147 /* LCD Exported Functions Group1:
148                                   MISC Configuration -------------------------*/
149 void LCD_Cmd(uint32_t NewState);
150 void LCD_IOConfig(uint32_t ComMode, uint32_t SEGVal0, uint32_t SEGVal1, uint16_t SEGVal2, uint32_t NewState);
151 void LCD_SetSEG(uint32_t SegCtrl0, uint32_t SegCtrl1, uint16_t SegCtrl2);
152 void LCD_BiasModeConfig(uint32_t BiasSelection);
153 uint32_t LCD_VoltageConfig(uint32_t VLCDSelection);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* __LIB_LCD_H */
160 
161 /*********************************** END OF FILE ******************************/
162 
163