1 /**
2   ******************************************************************************
3   * @file    lib_lcd.h
4   * @author  Application Team
5   * @version V1.1.0
6   * @date    2019-10-28
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 COMx IO typedef */
23 typedef struct
24 {
25   __IO uint32_t    *GPIO;
26        uint16_t     Pin;
27 }LCD_COMIO;
28 
29 typedef struct
30 {
31   uint32_t Type;
32   uint32_t Drv;
33   uint32_t FRQ;
34   uint32_t SWPR;
35   uint32_t FBMODE;
36   uint32_t BKFILL;
37 } LCD_InitType;
38 
39 typedef struct
40 {
41   uint32_t SegCtrl0;
42   uint32_t SegCtrl1;
43   uint16_t SegCtrl2;
44   uint32_t COMMode;
45 } LCD_IOInitType;
46 
47 /**************  Bits definition for ANA_REG6 register       ******************/
48 #define ANA_REG6_VLCD_0               (0x0U << ANA_REG6_VLCD_Pos)
49 #define ANA_REG6_VLCD_1               (0x1U << ANA_REG6_VLCD_Pos)
50 #define ANA_REG6_VLCD_2               (0x2U << ANA_REG6_VLCD_Pos)
51 #define ANA_REG6_VLCD_3               (0x3U << ANA_REG6_VLCD_Pos)
52 #define ANA_REG6_VLCD_4               (0x4U << ANA_REG6_VLCD_Pos)
53 #define ANA_REG6_VLCD_5               (0x5U << ANA_REG6_VLCD_Pos)
54 #define ANA_REG6_VLCD_6               (0x6U << ANA_REG6_VLCD_Pos)
55 #define ANA_REG6_VLCD_7               (0x7U << ANA_REG6_VLCD_Pos)
56 #define ANA_REG6_VLCD_8               (0x8U << ANA_REG6_VLCD_Pos)
57 #define ANA_REG6_VLCD_9               (0x9U << ANA_REG6_VLCD_Pos)
58 #define ANA_REG6_VLCD_A               (0xAU << ANA_REG6_VLCD_Pos)
59 #define ANA_REG6_VLCD_B               (0xBU << ANA_REG6_VLCD_Pos)
60 #define ANA_REG6_VLCD_C               (0xCU << ANA_REG6_VLCD_Pos)
61 #define ANA_REG6_VLCD_D               (0xDU << ANA_REG6_VLCD_Pos)
62 #define ANA_REG6_VLCD_E               (0xEU << ANA_REG6_VLCD_Pos)
63 #define ANA_REG6_VLCD_F               (0xFU << ANA_REG6_VLCD_Pos)
64 
65 /**************  Bits definition for LCD_CTRL register       ******************/
66 
67 /**************  Bits definition for LCD_CTRL2 register      ******************/
68 
69 //Type
70 #define LCD_TYPE_4COM          (0x0U << LCD_CTRL_TYPE_Pos)              /*!< 0x00000000 */
71 #define LCD_TYPE_6COM          (0x1U << LCD_CTRL_TYPE_Pos)              /*!< 0x00000010 */
72 #define LCD_TYPE_8COM          (0x2U << LCD_CTRL_TYPE_Pos)              /*!< 0x00000020 */
73 #define IS_LCD_TYPE(__TYPE__)  (((__TYPE__) == LCD_TYPE_4COM) ||\
74                                 ((__TYPE__) == LCD_TYPE_6COM) ||\
75                                 ((__TYPE__) == LCD_TYPE_8COM))
76 
77 //DrivingRes
78 #define LCD_DRV_300            (0x0U << LCD_CTRL_DRV_Pos)               /*!< 0x00000000 */
79 #define LCD_DRV_600            (0x1U << LCD_CTRL_DRV_Pos)               /*!< 0x00000004 */
80 #define LCD_DRV_150            (0x2U << LCD_CTRL_DRV_Pos)               /*!< 0x00000008 */
81 #define LCD_DRV_200            (0x3U << LCD_CTRL_DRV_Pos)               /*!< 0x0000000C */
82 #define IS_LCD_DRV(__DRV__)    (((__DRV__) == LCD_DRV_300) ||\
83                                 ((__DRV__) == LCD_DRV_600) ||\
84                                 ((__DRV__) == LCD_DRV_150) ||\
85                                 ((__DRV__) == LCD_DRV_200))
86 
87 //ScanFRQ
88 #define LCD_FRQ_64H            (0x0U << LCD_CTRL_FRQ_Pos)               /*!< 0x00000000 */
89 #define LCD_FRQ_128H           (0x1U << LCD_CTRL_FRQ_Pos)               /*!< 0x00000001 */
90 #define LCD_FRQ_256H           (0x2U << LCD_CTRL_FRQ_Pos)               /*!< 0x00000002 */
91 #define LCD_FRQ_512H           (0x3U << LCD_CTRL_FRQ_Pos)               /*!< 0x00000003 */
92 #define IS_LCD_FRQ(__FRQ__)    (((__FRQ__) == LCD_FRQ_64H)  ||\
93                                 ((__FRQ__) == LCD_FRQ_128H) ||\
94                                 ((__FRQ__) == LCD_FRQ_256H) ||\
95                                 ((__FRQ__) == LCD_FRQ_512H))
96 
97 #define IS_LCD_SWPR(__SWPR__)  ((__SWPR__) <= 0xFFUL)
98 
99 //SwitchMode
100 #define LCD_FBMODE_BUFA            (0x0U << LCD_CTRL2_FBMODE_Pos)           /*!< 0x00000000 */
101 #define LCD_FBMODE_BUFAB           (0x1U << LCD_CTRL2_FBMODE_Pos)           /*!< 0x00000040 */
102 #define LCD_FBMODE_BUFABLANK       (0x2U << LCD_CTRL2_FBMODE_Pos)           /*!< 0x00000080 */
103 #define IS_LCD_FBMODE(__FBMODE__)  (((__FBMODE__) == LCD_FBMODE_BUFA)  ||\
104                                     ((__FBMODE__) == LCD_FBMODE_BUFAB) ||\
105                                     ((__FBMODE__) == LCD_FBMODE_BUFABLANK))
106 
107 //BlankFill
108 #define LCD_BKFILL_1       LCD_CTRL2_BKFILL
109 #define LCD_BKFILL_0       0
110 #define IS_LCD_BKFILL(__BKFILL__)  (((__BKFILL__) == LCD_BKFILL_1) || ((__BKFILL__) == LCD_BKFILL_0))
111 
112 //ComMode
113 #define LCD_COMMOD_4COM     1
114 #define LCD_COMMOD_6COM     3
115 #define LCD_COMMOD_8COM     7
116 #define IS_LCD_COMMOD(__COMMOD__)  (((__COMMOD__) == LCD_COMMOD_4COM) ||\
117                                     ((__COMMOD__) == LCD_COMMOD_6COM) ||\
118                                     ((__COMMOD__) == LCD_COMMOD_8COM))
119 
120 //BiasSelection
121 #define LCD_BMODE_DIV3           0
122 #define LCD_BMODE_DIV4           ANA_REG6_LCDBMODE
123 #define IS_LCD_BMODE(__BMODE__)  (((__BMODE__) == LCD_BMODE_DIV3) ||\
124                                   ((__BMODE__) == LCD_BMODE_DIV4))
125 
126 /****************************** LCD Instances *********************************/
127 #define IS_LCD_ALL_INSTANCE(INSTANCE) ((INSTANCE) == LCD)
128 
129 /* Exported Functions ------------------------------------------------------- */
130 /* LCD Exported Functions Group1:
131                                   (De)Initialization -------------------------*/
132 void LCD_DeInit(void);
133 void LCD_StructInit(LCD_InitType *LCD_InitStruct);
134 void LCD_Init(LCD_InitType *InitStruct);
135 /* LCD Exported Functions Group1:
136                                   MISC Configuration -------------------------*/
137 void LCD_Cmd(LCD_IOInitType *IOInitType, uint32_t NewState);
138 void LCD_BiasModeConfig(uint32_t BiasSelection);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* __LIB_LCD_H */
145 
146 /*********************************** END OF FILE ******************************/
147 
148