1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#ifndef _HW_LCDCONTROL_H_
#define _HW_LCDCONTROL_H_

#include "hw_memmap.h"


#define LCDCtrlBase  (unsigned int)AHB1_LCDC_BASE

#define RegLCDC_ctrl    LCDCtrlBase+0x00
#define RegLCDC_mcu_ctrl   LCDCtrlBase+0x04
#define RegLCDC_hor_period   LCDCtrlBase+0x08
#define RegLCDC_vert_period   LCDCtrlBase+0x0c
#define RegLCDC_horpw    LCDCtrlBase+0x10
#define RegLCDC_vertpw    LCDCtrlBase+0x14
#define RegLCDC_horact    LCDCtrlBase+0x18
#define RegLCDC_vertact    LCDCtrlBase+0x1C
#define RegLCDC_horbp    LCDCtrlBase+0x20
#define RegLCDC_vertbp    LCDCtrlBase+0x24
#define RegLCDC_line0yaddr   LCDCtrlBase+0x28
#define RegLCDC_line0uvaddr   LCDCtrlBase+0x2c
#define RegLCDC_line1yaddr   LCDCtrlBase+0x30
#define RegLCDC_line1uvaddr   LCDCtrlBase+0x34
#define RegLCDC_line2yaddr   LCDCtrlBase+0x38
#define RegLCDC_line2uvaddr   LCDCtrlBase+0x3c
#define RegLCDC_line3yaddr   LCDCtrlBase+0x40
#define RegLCDC_line3uvaddr   LCDCtrlBase+0x44
#define RegLCDC_StartX    LCDCtrlBase+0x48
#define RegLCDC_StartY    LCDCtrlBase+0x4C
#define RegLCDC_DeltaX    LCDCtrlBase+0x50
#define RegLCDC_DeltaY    LCDCtrlBase+0x54
#define RegLCDC_intrmask   LCDCtrlBase+0x58
#define RegLCDC_alpALeftX   LCDCtrlBase+0x5C
#define RegLCDC_alpATopY   LCDCtrlBase+0x60
#define RegLCDC_alpARightX   LCDCtrlBase+0x64
#define RegLCDC_alpABottomY   LCDCtrlBase+0x68
#define RegLCDC_alpBLeftX   LCDCtrlBase+0x6C
#define RegLCDC_alpBTopY   LCDCtrlBase+0x70
#define RegLCDC_alpBRightX   LCDCtrlBase+0x74
#define RegLCDC_alpBBottomY   LCDCtrlBase+0x78
#define RegLCDC_lcdcsta    LCDCtrlBase+0x7c

#ifdef RS_HI      //RS ÓĐЧ”çÆœžß
#define RegLCDC_CMD     LCDCtrlBase+0x2004
#define RegLCDC_DAT     LCDCtrlBase+0x2000
#else
#define RegLCDC_CMD     LCDCtrlBase+0x2000
#define RegLCDC_DAT     LCDCtrlBase+0x2004
#endif

#define RegLCDC_BUF                 LCDCtrlBase+0x2000
#define RegLCDC_LCDCFIFO(Offset)    LCDCtrlBase+(Offset+0x40)*64


//Ò»Đ©ÎąČÙŚśșÍλČÙŚś
#define HWLCDC_SetAlp24bit()    SetRegBit32(RegLCDC_ctrl, 13)
#define HWLCDC_SetAlp16bit()    ClrRegBit32(RegLCDC_ctrl, 13)

#define HWLCDC_SetMCU8086IF()    SetRegBit32(RegLCDC_ctrl, 7)
#define HWLCDC_SelectAlpFactor()   SetRegBit32(RegLCDC_ctrl, 13)

#define HWLCDC_SetRGB24bit()    SetRegBit32(RegLCDC_ctrl, 6)
#define HWLCDC_SetRGB16bit()    ClrRegBit32(RegLCDC_ctrl, 6)

#define HWLCDC_StartEven()     SetRegBit32(RegLCDC_ctrl, 5)
#define HWLCDC_StopRGBFrame()    ClrRegBit32(RegLCDC_ctrl, 0)

#define HWLCDC_EnRGBMode()     SetRegBit32(RegLCDC_ctrl, 1)
#define HWLCDC_DisRGBMode()     ClrRegBit32(RegLCDC_ctrl, 1)

#define HWLCDC_EnAlpBuffer()    SetRegBit32(RegLCDC_mcu_ctrl, 6)
#define HWLCDC_DisAlpBuffer()    ClrRegBit32(RegLCDC_mcu_ctrl, 6)

#define HWLCDC_SetRS()      SetRegBit32(RegLCDC_mcu_ctrl, 5)
#define HWLCDC_ClrRS()      ClrRegBit32(RegLCDC_mcu_ctrl, 5)

#define HWLCDC_StartMcuBuf()    SetRegBit32(RegLCDC_mcu_ctrl, 1)
#define HWLCDC_EnMcuBufIntr()    SetRegBit32(RegLCDC_intrmask, 2)
#define HWLCDC_DisMcuBufIntr()    ClrRegBit32(RegLCDC_intrmask, 2)


#define HWLCDC_McuBypassMode()    SetRegBit32(RegLCDC_mcu_ctrl, 0)
#define HWLCDC_McuBufferMode()    ClrRegBit32(RegLCDC_mcu_ctrl, 0)


#define HWLCDC_GetMcuIdleState()    GetRegBit32(RegLCDC_lcdcsta,4)
#define HWLCDC_GetHactiveState()   GetRegBit32(RegLCDC_lcdcsta,0)
#define HWLCDC_GetVactiveState()   GetRegBit32(RegLCDC_lcdcsta,1)
#define HWLCDC_GetEvenLineState()   GetRegBit32(RegLCDC_lcdcsta,2)



#define BitEnLCDC 1
#define BitMcu  7
#define BitBypass 0



/**************************************************************
*LCDC register
**************************************************************/
#define  LCDC_BASE   LCDCtrlBase

#define   LCDC_CTRL   ((LCDC_BASE +0*4 ))
#define         b_DCLK_INVERTED     (1<<14)
#define   b_ALPHA_24B         (1<<13)
#define   b_ALPHA_16B         (0<<13)
#define     b_UVExchange        (1<<12)
#define   b_ALPHA(factor)     (factor<<9)
#define   b_Y_MIX       (1<<8)
#define   b_MCU_MODE   (1<<7)
#define   b_RGB_24B   (1<<6)
#define   b_RGB_16B   (0<<6)
#define   b_START_EVEN  (1<<5)
#define   b_EVEN_EN   (1<<4)
#define   b_RGB_DUMMY0  (0<<2)
#define   b_RGB_DUMMY2  (2<<2)
#define   b_RGB_DUMMY3  (3<<2)
#define   b_RGB_DUMMY(Dummy)  (Dummy<<2)
#define   b_LCDC_EN   (1<<1)
#define   b_LCDC_STOP   (1<<0)

#define   BUFF_CTRL   ((LCDC_BASE +1*4 )) // 0x04
#define   b_ALPHA_BASE(Addr)  (Addr<<8)
#define   b_LCDC_FIFOEN     (1<<6)
#define   b_RS_HIGH      (1<<5)
#define   b_BUFF_LINE3     (3<<3)
#define   b_BUFF_LINE2     (2<<3)
#define   b_BUFF_LINE1     (1<<3)
#define   b_BUFF_LINE0     (0<<3)
#define   b_BUFF_WRITE     (1<<2)
#define   b_BUFF_START     (1<<1)
#define   b_MCU_BYPASS     (1<<0)

#define   HOR_PERIOD   (LCDC_BASE +2*4 )  // 0x08
#define   VERT_PERIOD   (LCDC_BASE +3*4 ) // 0x0c
#define   LCD_WAIT   (LCDC_BASE +3*4 )    // 0x0c
#define   HOR_PW    (LCDC_BASE +4*4 )     // 0x10
#define   VERT_PW    (LCDC_BASE +5*4 )    // 0x14
#define   HOR_BP    (LCDC_BASE +6*4 )     // 0x18
#define   VERT_BP    (LCDC_BASE +7*4 )    // 0x1c
#define   HOR_ACT    (LCDC_BASE +8*4 )    // 0x20
#define   BUFF_LEN   (LCDC_BASE +8*4 )    // 0x20
#define   VERT_ACT   (LCDC_BASE +9*4 )    // 0x24

#define   LINE0_YADDR   (LCDC_BASE +10*4) // 0x28
#define   b_ALPHA_EN   (1<<14)
#define   b_SCALE_EN   (1<<13)
#define   b_GBR_ORDER   (1<<12)
#define   b_YUV_SRC   (1<<11)

#define   LINE0_UVADDR  (LCDC_BASE +11*4)
#define   LINE1_YADDR   (LCDC_BASE +12*4)
#define   LINE1_UVADDR  (LCDC_BASE +13*4)
#define   LINE2_YADDR   (LCDC_BASE +14*4)
#define   LINE2_UVADDR  (LCDC_BASE +15*4)
#define   LINE3_YADDR   (LCDC_BASE +16*4)
#define   LINE3_UVADDR  (LCDC_BASE +17*4)
#define   START_X    (LCDC_BASE +18*4)
#define   START_Y    (LCDC_BASE +19*4)
#define   DELTA_X    (LCDC_BASE +20*4)
#define   DELTA_Y    (LCDC_BASE +21*4)

#define   INTR_MASK   (LCDC_BASE +22*4)
#define   b_INTR_PERLINE     (1<<3)
#define   b_INTR_EVENLINE     (0<<3)
#define   b_BUFF_INTR   (1<<2)
#define   b_VERT_INTR   (1<<1)
#define   b_HOR_INTR   (1<<0)

#define         ALPHA_ALX           (LCDC_BASE +23*4)
#define         ALPHA_ATY           (LCDC_BASE +24*4)
#define         ALPHA_ARX           (LCDC_BASE +25*4)
#define         ALPHA_ABY           (LCDC_BASE +26*4)
#define         ALPHA_BLX           (LCDC_BASE +27*4)
#define         ALPHA_BTY           (LCDC_BASE +28*4)
#define         ALPHA_BRX           (LCDC_BASE +29*4)
#define         ALPHA_BBY           (LCDC_BASE +30*4)

#define   LCDC_STA   (LCDC_BASE +31*4)
#define   b_CURR_LINE1  (1<<14)
#define   b_MCU_IDLE   (1<<12)
#define   b_VERT_ACTIVE  (1<<11)
#define   b_HOR_ACTIVE  (1<<0)

#define   LCD_DATA   (LCDC_BASE +0x1004)
#define   LCD_COMMAND   (LCDC_BASE +0x1000)


#define         LCDC_FIFO           (LCDC_BASE +0x1c00)
#define         LCDC_FIFO_DEPTH     256         //480
#define         LCDC_DWDMA_FIFO     (LCDC_BASE +0x1000)
#define         LCDC_BUFFER         (LCDC_BASE +0x2000)
#define         LCDC_DWDMA_BUFFER   (LCDC_BASE +0x2000)

#define         LCDMode_Bypass    0
#define         LCDMode_DMABypass  1
#define         LCDMode_Buffer   2



#endif/* _HW_LCDCONTROL_H_ */

/*********************************************************************
 END OF FILE
*********************************************************************/