📄 lcd_auto.lst
字号:
C51 COMPILER V6.20c LCD_AUTO 04/15/2004 12:59:06 PAGE 1
C51 COMPILER V6.20c, COMPILATION OF MODULE LCD_AUTO
OBJECT MODULE PLACED IN .\Output\Lcd_auto.obj
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Code\Lcd_auto.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\
-Lcd_auto.lst) OBJECT(.\Output\Lcd_auto.obj)
stmt level source
1 #define __AUTO__
2
3 #include "reg52.h"
4
5 #include "Header\MAIN_DEF.h"
6 #include "Header\ACCESS.H"
7 #include "Header\LCD_MAIN.H"
8 #include "Header\CONFIG.H"
9 #include "Header\LCD_FUNC.H"
10 #include "Header\LCD_AUTO.H"
11 #include "Header\LCD_OSD.H"
12 #include "Header\FRAME_SYNC.H"
13
14
15 void Wait_Finish(void)
16 {
17 1 unsigned char Wait_Time_Cnt, IVS_Event;
18 1
19 1 RTDSetByte(STATUS0_01, 0x00); // Clear status
20 1 RTDSetByte(STATUS1_1F, 0x00); // Clear status
21 1
22 1 Wait_Time_Cnt = 60; // Auto timeout 60ms
23 1 IVS_Event = 25; // IVS timeout 25ms
24 1 do
25 1 {
26 2 Delay_Xms(1);
27 2
28 2 RTDRead(STATUS1_1F, 1, N_INC); // Read Status
29 2
30 2 IVS_Event = (Data[0] & EVENT_IVS) ? 25 : IVS_Event - 1;
31 2
32 2 if (0 == IVS_Event)
33 2 {
34 3 Data[0] = ERROR_INPUT;
35 3 return;
36 3 }
37 2
38 2 RTDRead(AUTO_ADJ_CTRL_7F, 1, N_INC);
39 2 }
40 1 while ((Data[0] & 0x01) && (--Wait_Time_Cnt));
41 1
42 1 RTDRead(STATUS0_01, 1, N_INC); // Read Status
43 1
44 1 RTDSetByte(STATUS0_01, 0x00); // Clear Status
45 1
46 1 // Return non-zero value in Data[0] if :
47 1 // 1. IVS or IHS changed
48 1 // 2. Auto-Phase Tracking timeout
49 1
50 1 Data[0] = (Data[0] & 0x60) ? ERROR_INPUT : (0 == Wait_Time_Cnt) ? ERROR_TIMEOUT : ERROR_SUCCEED;
51 1 }
52
53 #if (HARDWARE_AUTO)
54
C51 COMPILER V6.20c LCD_AUTO 04/15/2004 12:59:06 PAGE 2
55 void Wait_For_IVS(void)
56 {
57 1 unsigned char ucTimeOut;
58 1
59 1 ucTimeOut = 50;
60 1
61 1 RTDSetByte(STATUS1_1F, 0x00);
62 1 do
63 1 {
64 2 RTDRead(STATUS1_1F, 1, Y_INC);
65 2 Data[0] &= EVENT_IVS;
66 2
67 2 Delay_Xms(1);
68 2 }
69 1 while ((0 == Data[0]) && (--ucTimeOut));
70 1 }
71
72 #endif
73
74 //--------------------Measure Vertical Position---------------------//
75 // Return Message => ERROR_SUCCESS : Success //
76 // ERROR_INPUT : 1. IVS or IHS changed //
77 // 2. underflow or overflow //
78 // ERROR_TIMEOUT : Measure Time_Out //
79 // ERROR_NOTACTIVE : No Avtive Image //
80 //------------------------------------------------------------------//
81 unsigned char Measure_PositionV(unsigned char NM_V)
82 {
83 1 unsigned int usLBound, usRBound;
84 1
85 1 RTDRead(MEAS_HI_51, 0x02, Y_INC);
86 1 Data[2] = Data[1] & 0x0f;
87 1 Data[3] = Data[0];
88 1
89 1 usRBound = usADC_Clock + (unsigned int)stMUD.CLOCK - 128;
90 1 usLBound = (unsigned long)usRBound * ((unsigned int *)Data)[1] / usStdHS;
91 1
92 1 // Original formula :
93 1 // usRBound = usRBound - 2 - (PROGRAM_HDELAY - MEASURE_HDEALY) - (stMUD.H_POSITION - ucH_Min_Margin
-);
94 1 // usLBound = usLBound + 20 - (PROGRAM_HDELAY - MEASURE_HDEALY) - (stMUD.H_POSITION - ucH_Min_Margi
-n);
95 1
96 1 usRBound = usRBound - 2 + MEASURE_HDEALY - PROGRAM_HDELAY + ucH_Min_Margin - stMUD.H_POSITION;
97 1 usLBound = usLBound + 20 + ucH_Min_Margin + MEASURE_HDEALY;
98 1 usLBound = usLBound > ((unsigned int)stMUD.H_POSITION + PROGRAM_HDELAY) ? (usLBound - PROGRAM_HDELA
-Y - stMUD.H_POSITION) : 1;
99 1
100 1 NM_V = NM_V & 0xfc;
101 1
102 1 Data[0] = 6;
103 1 Data[1] = Y_INC;
104 1 Data[2] = H_BND_STA_L_75;
105 1 Data[3] = (unsigned char)usLBound;
106 1 Data[4] = (unsigned char)usRBound;
107 1 Data[5] = ((unsigned char)(usLBound >> 4) & 0x70) | ((unsigned char)(usRBound >> 8) & 0x0f);
108 1 Data[6] = 8;
109 1 Data[7] = Y_INC;
110 1 Data[8] = MARGIN_R_7B;
111 1 Data[9] = NM_V;
112 1 Data[10] = NM_V | PIXEL_1;
113 1 Data[11] = NM_V;
C51 COMPILER V6.20c LCD_AUTO 04/15/2004 12:59:06 PAGE 3
114 1 Data[12] = 0x00;
115 1 Data[13] = 0x01;
116 1 Data[14] = 0;
117 1 RTDWrite(Data);
118 1
119 1 Wait_Finish();
120 1
121 1 if (ERROR_SUCCEED != Data[0]) return Data[0];
122 1
123 1 RTDRead(VER_START_80, 4, Y_INC);
124 1
125 1 // Translate byte order : RTD little indian -> 8051 big indian
126 1 Data[6] = Data[1] & 0x0f;
127 1 Data[7] = Data[0];
128 1 Data[8] = Data[3] & 0x0f;
129 1 Data[9] = Data[2];
130 1
131 1 // V Start/End should subtract 1
132 1 usVer_Start = ((unsigned int *)Data)[3] ? ((unsigned int *)Data)[3] - 1 : 0;
133 1 usVer_End = ((unsigned int *)Data)[4] ? ((unsigned int *)Data)[4] - 1 : 0;
134 1
135 1 // Check all black
136 1 if (0x0000 == usVer_End) return ERROR_NOTACTIVE;
137 1
138 1 // To prevent from noise induced by VSYNC
139 1 if ((9 - PROGRAM_VDELAY) > usVer_Start)
140 1 {
141 2 ((unsigned int *)Data)[3] = 9 - PROGRAM_VDELAY;
142 2 }
143 1 else
144 1 {
145 2 if (usVer_End > (usVer_Start + usIPV_ACT_LEN - 1))
146 2 {
147 3 usVer_End = usVer_Start + usIPV_ACT_LEN - 1;
148 3
149 3 ((unsigned int *)Data)[4] = usVer_End;
150 3 }
151 2 }
152 1
153 1 // Update auto-tracking window vertical range
154 1 Data[0] = 6;
155 1 Data[1] = Y_INC;
156 1 Data[2] = V_BND_STA_L_78;
157 1 Data[3] = Data[7];
158 1 Data[4] = Data[9];
159 1 Data[5] = (Data[6] << 4) + Data[8];
160 1 Data[6] = 0;
161 1 RTDWrite(Data);
162 1
163 1 return ERROR_SUCCEED;
164 1 }
165
166 //--------------------Measure Horizontal Position-------------------//
167 // Return Message => ERROR_SUCCESS : Success //
168 // ERROR_INPUT : 1. IVS or IHS changed //
169 // 2. underflow or overflow //
170 // ERROR_TIMEOUT : Measure Time_Out //
171 // ERROR_NOTACTIVE : No Avtive Image //
172 //------------------------------------------------------------------//
173 unsigned char Measure_PositionH(unsigned char NM_H)
174 {
175 1 unsigned int usLBound, usRBound;
C51 COMPILER V6.20c LCD_AUTO 04/15/2004 12:59:06 PAGE 4
176 1
177 1 RTDRead(MEAS_HI_51, 0x02, Y_INC);
178 1 Data[2] = Data[1] & 0x0f;
179 1 Data[3] = Data[0];
180 1
181 1 usRBound = usADC_Clock + (unsigned int)stMUD.CLOCK - 128;
182 1 usLBound = (unsigned long)usRBound * ((unsigned int *)Data)[1] / usStdHS;
183 1
184 1 usRBound = usRBound - 2 + MEASURE_HDEALY - PROGRAM_HDELAY + ucH_Min_Margin - stMUD.H_POSITION;
185 1
186 1 usLBound = usLBound + 20 + ucH_Min_Margin + MEASURE_HDEALY;
187 1 usLBound = usLBound > ((unsigned int)stMUD.H_POSITION + PROGRAM_HDELAY) ? (usLBound - PROGRAM_HDELA
-Y - stMUD.H_POSITION) : 1;
188 1
189 1 NM_H = NM_H & 0xfc;
190 1
191 1 Data[0] = 6;
192 1 Data[1] = Y_INC;
193 1 Data[2] = H_BND_STA_L_75;
194 1 Data[3] = (unsigned char)usLBound;
195 1 Data[4] = (unsigned char)usRBound;
196 1 Data[5] = ((unsigned char)(usLBound >> 4) & 0x70) | ((unsigned char)(usRBound >> 8) & 0x0f);
197 1 Data[6] = 8;
198 1 Data[7] = Y_INC;
199 1 Data[8] = MARGIN_R_7B;
200 1 Data[9] = NM_H;
201 1 Data[10] = NM_H;
202 1 Data[11] = NM_H;
203 1 Data[12] = 0x00;
204 1 Data[13] = 0x01;
205 1 Data[14] = 0;
206 1 RTDWrite(Data);
207 1
208 1 Wait_Finish();
209 1
210 1 if (ERROR_SUCCEED != Data[0]) return Data[0];
211 1
212 1 RTDRead(HOR_START_84, 4, Y_INC);
213 1
214 1 // Translate byte order : RTD little indian -> 8051 big indian
215 1 Data[4] = Data[3] & 0x0f;
216 1 Data[5] = Data[2];
217 1 Data[2] = Data[1] & 0x0f;
218 1 Data[3] = Data[0];
219 1
220 1 if (0x07FF <= ((unsigned int *)Data)[1]) return ERROR_NOTACTIVE;
221 1
222 1 RTDRead(VGIP_CTRL_04, 1, N_INC);
223 1
224 1 //if (0x14 == (Data[0] & 0x1c))
225 1 if (0x08 == (Data[0] & 0x0c))
226 1 {
227 2 ((unsigned int *)Data)[1] += 0x03;
228 2 ((unsigned int *)Data)[2] += 0x03;
229 2 }
230 1
231 1 /*
232 1 usH_Start = MEAS_H_STA_OFFSET < ((unsigned int *)Data)[1] ? ((unsigned int *)Data)[1] - MEAS_H_STA_O
-FFSET : 0x0000;
233 1 usH_End = MEAS_H_END_OFFSET < ((unsigned int *)Data)[2] ? ((unsigned int *)Data)[2] - MEAS_H_END_O
-FFSET : 0x0fff;
234 1
C51 COMPILER V6.20c LCD_AUTO 04/15/2004 12:59:06 PAGE 5
235 1 if (0x0000 != usH_Start) usH_Start = usH_Start + stMUD.H_POSITION - 128;
236 1 if (0x0fff != usH_End) usH_End = usH_End + stMUD.H_POSITION - 128;
237 1 */
238 1
239 1 usH_Start = (((unsigned int *)Data)[1] + stMUD.H_POSITION) >= (128 + MEAS_H_STA_OFFSET)
240 1 ? (((unsigned int *)Data)[1] + stMUD.H_POSITION) - (128 + MEAS_H_STA_OFFSET) : 0x0000;
241 1 usH_End = (((unsigned int *)Data)[2] + stMUD.H_POSITION) >= (128 + MEAS_H_END_OFFSET)
242 1 ? (((unsigned int *)Data)[2] + stMUD.H_POSITION) - (128 + MEAS_H_END_OFFSET) : 0x0fff;
243 1
244 1 return ERROR_SUCCEED;
245 1 }
246
247 //---------------Measure Vertical & Horizontal Position-------------//
248 // Return Message => ERROR_SUCCESS : Success //
249 // ERROR_INPUT : 1. IVS or IHS changed //
250 // 2. underflow or overflow //
251 // ERROR_TIMEOUT : Measure Time_Out //
252 // ERROR_NOTACTIVE : No Avtive Image //
253 //------------------------------------------------------------------//
254 unsigned char Measure_PositionN(unsigned char NM)
255 {
256 1 unsigned char Result;
257 1
258 1 Result = Measure_PositionV(NM);
259 1
260 1 if (ERROR_SUCCEED == Result)
261 1 {
262 2 Result = Measure_PositionH(NM);
263 2 }
264 1
265 1 return Result;
266 1 }
267
268 /*
269 //------------------------------------------------------------------//
270 // Auto Clock //
271 //------------------------------------------------------------------//
272 unsigned char Auto_Clock(void)
273 {
274 unsigned char Result, Curr_PosH, Curr_PosV, Curr_Clock, Curr_Phase;
275
276 bAutoInProgress = 1;
277
278 Curr_PosH = stMUD.H_POSITION; // Save current stMUD.H_POSITION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -