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