⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_auto.lst

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 LST
📖 第 1 页 / 共 5 页
字号:
1151          
1152              bAutoInProgress = 0;
1153          
1154              return Result;
1155          }
1156          */
1157          
1158          //------------------------------------------------------------------//
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 20  

1159          // Return Message => ERROR_SUCCESS   : Success                      //
1160          //                   ERROR_SUCCESS_1 : Vertical Start > Max         //
1161          //                   ERROR_SUCCESS_2 : Vertical Start < Min         //
1162          //                   ERROR_SUCCESS_4 : Vertical Start/End Fail      //
1163          //                   ERROR_SUCCESS_8 : Horizontal Start > Max       //
1164          //                   ERROR_SUCCESS_16: Horizontal Start < Min       //
1165          //                   ERROR_SUCCESS_32: Horizontal Start/End Fail    //
1166          //                   ERROR_INPUT     : 1. IVS or IHS changed        //
1167          //                                     2. underflow or overflow     //
1168          //                   ERROR_TIMEOUT   : Measure Time_Out             //
1169          //                   ERROR_NOTACTIVE : No Avtive Image              //
1170          //------------------------------------------------------------------//
1171          unsigned char Auto_Position_Do(unsigned char NM)
1172          {
1173   1          unsigned char   Result;
1174   1          
1175   1          Result  = Measure_PositionN(NM);
1176   1      
1177   1          if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1178   1          
1179   1          Result  = ERROR_SUCCEED;
1180   1      
1181   1          /////////////////////////////////
1182   1          // Calculate Vertical Position //
1183   1          /////////////////////////////////
1184   1          NM  = 1;
1185   1          while (1)
1186   1          {
1187   2              if ((usIPV_ACT_STA + ucV_Max_Margin - 128) >= usVer_Start)
1188   2              {
1189   3                  if ((usIPV_ACT_STA + ucV_Min_Margin - 128) <= usVer_Start)
1190   3                  {
1191   4                      stMUD.V_POSITION = (usVer_Start + 128) - usIPV_ACT_STA;
1192   4                      Set_V_Position();
1193   4      
1194   4                      break;  // Success
1195   4                  }
1196   3                  else
1197   3                      Result  |= ERROR_SUCCESS_2;
1198   3              }
1199   2              else
1200   2                  Result  |= ERROR_SUCCESS_1;
1201   2      
1202   2              // If we can't align upper bound, we try to align lower bound.
1203   2              if (NM && usVer_End > usIPV_ACT_LEN)
1204   2              {
1205   3                  usVer_Start = usVer_End - usIPV_ACT_LEN + 1;
1206   3                  NM          = 0;
1207   3              }
1208   2              else
1209   2              {
1210   3                  Result  |= ERROR_SUCCESS_4;
1211   3                  break;
1212   3              }
1213   2          }
1214   1          
1215   1          ///////////////////////////////////
1216   1          // Calculate Horizontal Position //
1217   1          ///////////////////////////////////
1218   1          NM  = 1;
1219   1          while (1)
1220   1          {
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 21  

1221   2              if ((usIPH_ACT_STA + ucH_Max_Margin) >= (usH_Start + 128))
1222   2              {
1223   3                  if ((usIPH_ACT_STA + ucH_Min_Margin) <= (usH_Start + 128))
1224   3                  {
1225   4                      //usH_Start is the actual distance from Hsync to active image
1226   4                      stMUD.H_POSITION    = usH_Start + 128 - usIPH_ACT_STA;
1227   4                      Set_H_Position();
1228   4                      
1229   4                      break;  // Success
1230   4                  }
1231   3                  else
1232   3                      Result  |= ERROR_SUCCESS_16;
1233   3              }
1234   2              else
1235   2                  Result  |= ERROR_SUCCESS_8;
1236   2      
1237   2              // If we can't align upper bound, we try to align lower bound.
1238   2              if (NM && usH_End > usIPH_ACT_WID)
1239   2              {
1240   3                  usH_Start   = usH_End - usIPH_ACT_WID + 1;
1241   3                  NM          = 0;
1242   3              }
1243   2              else
1244   2              {
1245   3                  Result  |= ERROR_SUCCESS_32;
1246   3                  break;
1247   3              }
1248   2          }
1249   1          
1250   1          return Result;
1251   1      }
1252          
1253          unsigned char Min_Noise_Margin(void)
1254          {
1255   1          unsigned char   Result, Noise;
1256   1          unsigned int    Curr_StartH, Curr_EndH;
1257   1      
1258   1          Result  = Measure_PositionV(VERTICAL_MARGIN);
1259   1          
1260   1          if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1261   1      	    
1262   1          if (0 == usVer_Start)
1263   1          {
1264   2              Result  = Measure_PositionV(VERTICAL_MARGIN + 0x20);
1265   2              if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1266   2          }
1267   1          
1268   1          Noise   = 0x00;
1269   1          Result  = Measure_PositionH(Noise);
1270   1          if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1271   1              
1272   1          Curr_StartH = usH_Start;    // Save H start position at noise margin = 0
1273   1          Curr_EndH   = usH_End;      // Save H end position at noise margin = 0
1274   1      
1275   1          do
1276   1          {
1277   2              Noise   = Noise + 0x10;
1278   2              Result  = Measure_PositionH(Noise);
1279   2      
1280   2              if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1281   2          
1282   2              if (Curr_StartH >= usH_Start)
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 22  

1283   2              {
1284   3                  Curr_StartH = usH_Start;
1285   3              }
1286   2              else if (0x08 < (usH_Start - Curr_StartH))
1287   2              {
1288   3                  break;  // A large gap of H start position is found.
1289   3              }
1290   2          }
1291   1          while (0x90 > Noise);
1292   1      
1293   1          if (0x80 < Noise)   return ERROR_NOISE_TOO_BIG;      
1294   1      
1295   1          while (1)
1296   1          {   
1297   2              Curr_StartH = usH_Start;
1298   2              Curr_EndH   = usH_End;
1299   2      
1300   2              Result  = Measure_PositionH(Noise + 0x28);
1301   2              
1302   2              if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1303   2      
1304   2              if ((Curr_EndH - Curr_StartH) == (usH_End - usH_Start) || (Curr_EndH - Curr_StartH) >= (usH_End - 
             -usH_Start + 3))
1305   2              {
1306   3                  break;  // We got noise margin with stable horizontal start/end position.
1307   3              }
1308   2              
1309   2              if (0xa0 <= Noise)
1310   2              {
1311   3                  break;  // No stable horizontal start/end position are found.
1312   3              }
1313   2      
1314   2              Noise   = Noise + 0x10;        
1315   2              Result  = Measure_PositionH(Noise);
1316   2      
1317   2              if (ERROR_SUCCEED != (Result & 0x80))   return Result;
1318   2          };
1319   1      
1320   1          Data[0] = Noise + 0x10;
1321   1      
1322   1          return ERROR_SUCCEED;
1323   1      }
1324          
1325          /*
1326          unsigned char Auto_Phase(void)
1327          {
1328              unsigned char   Result, Curr_PosV;
1329          
1330              bAutoInProgress = 1;
1331          
1332              Curr_PosV   = stMUD.V_POSITION;     // Save current stMUD.V_POSITION
1333          
1334              if (ucV_Max_Margin < stMUD.V_POSITION)
1335              {
1336                  stMUD.V_POSITION    = ucV_Max_Margin;
1337                  Set_V_Position();
1338              }
1339          
1340              // Set ADC to default
1341              RTDCodeW(ADC_DEFAULT);
1342          
1343              ///////////////////////////////
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 23  

1344              //   Measure  NOISE_MARGIN   //
1345              ///////////////////////////////
1346              Result  = Min_Noise_Margin();
1347          
1348              if (ERROR_SUCCEED == (Result & 0x80))
1349              {   
1350                  Result  = Auto_Phase_Do(Data[0]);   // Noise margin returned by Min_Noise_Margin() is saved in Dat
             -a[0];
1351              }
1352          
1353              if (ERROR_SUCCEED != (Result & 0x80))
1354              {
1355                  // Restore Phase
1356                  Set_Phase(stMUD.PHASE);
1357              }
1358              else
1359              {
1360                  Save_MUD(ucMode_Curr);
1361              }
1362          
1363              // Restore ADC Gain/Offset
1364              SetADC_GainOffset();
1365          
1366              // Restore vertical position
1367              if (Curr_PosV != stMUD.V_POSITION)
1368              {
1369                  stMUD.V_POSITION    = Curr_PosV;
1370                  Set_V_Position();
1371              }
1372          
1373              bAutoInProgress = 0;
1374          
1375              return Result;
1376          }
1377          */
1378          
1379          unsigned char Auto_Phase_Do(unsigned char NM)
1380          {
1381   1          unsigned char idata ucDetect, ucPhase, ucResult;
1382   1          unsigned long idata ulTemp0, ulTemp1, ulTemp2;
1383   1      
1384   1          if (ERROR_SUCCEED != Measure_PositionN(NM))    return ERROR_ABORT;
1385   1      
1386   1          // Set auto-tracking window
1387   1          Data[0]     = 6;
1388   1          Data[1]     = Y_INC;
1389   1          Data[2]     = H_BND_STA_L_75;
1390   1          Data[3]     = (unsigned char)(usH_Start + MEAS_H_STA_OFFSET - 2);
1391   1          Data[4]     = (unsigned char)(usH_End + MEAS_H_END_OFFSET + 1);
1392   1          Data[5]     = ((unsigned char)((usH_Start + MEAS_H_STA_OFFSET - 2) >> 4) & 0x70) | ((unsigned char)((u
             -sH_End + MEAS_H_END_OFFSET + 1) >> 8) & 0x0f);
1393   1          Data[6]     = 0;
1394   1          RTDWrite(Data);
1395   1      
1396   1          RTDSetByte(DIFF_THRED_7E, 0x30);
1397   1      
1398   1          ulTemp0     = 0;
1399   1          ucDetect    = 0x7b;
1400   1          do
1401   1          {
1402   2              ucResult    = COLORS_GREEN;
1403   2              ucPhase     = COLORS_GREEN;
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 24  

1404   2              do
1405   2              {
1406   3                  RTDSetByte(MARGIN_B_7D, ucPhase);
1407   3                  RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
1408   3      
1409   3                  Wait_Finish();
1410   3                  if (ERROR_SUCCEED != Data[0])   return Data[0];
1411   3      
1412   3                  Read_Auto_Info(1);
1413   3      
1414   3                  if (ulTemp0 < ((unsigned long *)Data)[1])
1415   3                  {
1416   4                      ulTemp0     = ((unsigned long *)Data)[1];
1417   4                      ucResult    = ucPhase;
1418   4      
1419   4                      if (0x8000 < ulTemp0)   break;
1420   4                  }
1421   3      
1422   3                  if (COLORS_GREEN == ucPhase)
1423   3                      ucPhase = COLORS_BLUE;
1424   3                  else if (COLORS_BLUE == ucPhase)
1425   3                      ucPhase = COLORS_RED;
1426   3                  else
1427   3                      break;
1428   3              }
1429   2              while (1);
1430   2      
1431   2              if (0 != ulTemp0 || 0x7b != ucDetect)   break;
1432   2      
1433   2              ucDetect    = 0x77;
1434   2          }
1435  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -