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