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

📄 lcd_auto.lst

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 LST
📖 第 1 页 / 共 5 页
字号:
 570   2              
 571   2              if (2 >= delta)     break;  // 1023,1024,1025,1026,1027
 572   2              
 573   2              delta   = (delta + (delta >> 2) + 2) & 0xfc;  // 4n number
 574   2      
 575   2              // Adjust Clock
 576   2              if (usH_End < usIPH_ACT_WID)    // delta < 0, Measure < Active
 577   2              {
 578   3                  ucResult    = (800 < usIPH_ACT_WID) ? 228 : 178;
 579   3      
 580   3                  if (ucResult < (unsigned int)delta + stMUD.CLOCK)    return ERROR_TOO_SMALL;
 581   3      
 582   3                  stMUD.CLOCK += delta;
 583   3              }
 584   2              else                            // delta >= 0, Measure >= Active
 585   2              {
 586   3                  ucResult    = (800 < usIPH_ACT_WID) ? 28 : 78;
 587   3      
 588   3                  if (stMUD.CLOCK < (unsigned int)delta + ucResult)     return ERROR_TOO_BIG;
 589   3      
 590   3                  stMUD.CLOCK -= delta;
 591   3              }
 592   2              Set_Clock();
 593   2          }
 594   1          while (--count);
 595   1      
 596   1          if (0 == count)     return ERROR_TIMEOUT;
 597   1      
 598   1          stop    = 0;
 599   1      
 600   1          while (1)
 601   1          {
 602   2              count   = 0x10;     // Phase 4 ~ 28 step 8 (4,12,20,28)
 603   2              delta   = 0x00;
 604   2      
 605   2              while (1)
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 11  

 606   2              {
 607   3                  Set_Phase(count);
 608   3                  
 609   3                  // Measure usH_Start & usH_End
 610   3                  ucResult    = Measure_PositionH(NM);
 611   3      
 612   3                  if (ERROR_SUCCEED != (ucResult & 0x80))
 613   3                  {
 614   4                      if (ERROR_NOTACTIVE == ucResult)
 615   4                      {
 616   5                          // Input pattern is black/white vertical lines.
 617   5                          if (0x70 == count)
 618   5                          {
 619   6                              Set_Phase(stMUD.PHASE); // Restore phase
 620   6                              break;
 621   6                          }
 622   5                          else
 623   5                          {
 624   6                              count += 0x20;
 625   6                              continue;
 626   6                          }
 627   5                      }
 628   4      
 629   4                      Set_Phase(stMUD.PHASE); // Restore phase
 630   4      
 631   4                      return ucResult;
 632   4                  }
 633   3                  
 634   3                  usH_End     = usH_End + 1 - usH_Start;
 635   3                  ucResult    = usH_End + 0x80 - usIPH_ACT_WID;
 636   3                  
 637   3                  if (ucResult > delta)
 638   3                  {
 639   4                      delta   = ucResult;     // Save the biggest width
 640   4                  }
 641   3      
 642   3                  if (0x70 == count)
 643   3                  {
 644   4                      Set_Phase(stMUD.PHASE); // Restore phase
 645   4                      break;
 646   4                  }
 647   3      
 648   3                  count += 0x20;
 649   3              }
 650   2      
 651   2              if (0x82 < delta)
 652   2              {
 653   3                  stMUD.CLOCK -= 4;
 654   3      
 655   3                  Set_H_Position();
 656   3                  Set_Clock();
 657   3      
 658   3                  stop    = 1;
 659   3              }
 660   2              else if (0x80 > delta)
 661   2              {
 662   3                  if (stop && (0x7f == delta))    break; 
 663   3      
 664   3                  stMUD.CLOCK += 4;
 665   3      
 666   3                  Set_Clock();
 667   3                  Set_H_Position();
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 12  

 668   3      
 669   3                  delta   += 3;
 670   3      
 671   3                  if (stop)   break;
 672   3              }
 673   2              else    
 674   2                  break;
 675   2          }
 676   1      
 677   1      #if (AUTO_CLOCK_STEP < 4)
 678   1      
 679   1          if (0x84 > delta && 0x7c < delta)
 680   1          {
 681   2              unsigned long   ulTemp0, ulMaxVal;
 682   2              unsigned char   ucPhase, ucDetect;
 683   2      
 684   2              if (ERROR_SUCCEED != Measure_PositionN(NM))    return ERROR_ABORT;
 685   2      
 686   2              // Set auto-tracking window
 687   2              Data[0]     = 6;
 688   2              Data[1]     = Y_INC;
 689   2              Data[2]     = H_BND_STA_L_75;
 690   2              Data[3]     = (unsigned char)(usH_Start + MEAS_H_STA_OFFSET - 2);
 691   2              Data[4]     = (unsigned char)(usH_End + MEAS_H_END_OFFSET + 1);
 692   2              Data[5]     = ((unsigned char)((usH_Start + MEAS_H_STA_OFFSET - 2) >> 4) & 0x70) | ((unsigned char
             -)((usH_End + MEAS_H_END_OFFSET + 1) >> 8) & 0x0f);
 693   2              Data[6]     = 0;
 694   2              RTDWrite(Data);
 695   2      
 696   2              RTDSetByte(DIFF_THRED_7E, 0x50);
 697   2              
 698   2              ulTemp0     = 0;
 699   2              ucDetect    = 0x7b;
 700   2              ucResult    = COLORS_BLUE;
 701   2              ucPhase     = COLORS_BLUE;
 702   2              do
 703   2              {
 704   3                  RTDSetByte(MARGIN_B_7D, ucPhase);
 705   3                  RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
 706   3      
 707   3                  Wait_Finish();
 708   3                  if (ERROR_SUCCEED != Data[0])   return Data[0];
 709   3      
 710   3                  Read_Auto_Info(1);
 711   3      
 712   3                  if (ulTemp0 < ((unsigned long *)Data)[1])
 713   3                  {
 714   4                      ulTemp0     = ((unsigned long *)Data)[1];
 715   4                      ucResult    = ucPhase;
 716   4      
 717   4                      if (0x10000 < ulTemp0)   break;
 718   4                  }
 719   3      
 720   3                  if (COLORS_BLUE == ucPhase)
 721   3                      ucPhase = COLORS_GREEN;
 722   3                  else if (COLORS_GREEN == ucPhase)
 723   3                      ucPhase = COLORS_RED;
 724   3                  else
 725   3                  {
 726   4                      if (0x10000 <= ulTemp0 || 0x77 == ucDetect)      break;
 727   4      
 728   4                      ulTemp0     = 0;
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 13  

 729   4                      ucDetect    = 0x77;
 730   4                      ucPhase     = COLORS_BLUE;
 731   4                      ucResult    = COLORS_BLUE;
 732   4      
 733   4                      RTDSetByte(DIFF_THRED_7E, 0x70);
 734   4                  }
 735   3              }
 736   2              while (1);
 737   2              
 738   2              // Abort if no suitable color is found
 739   2              if (0x8000 > ulTemp0)
 740   2              {
 741   3                  return (28 > stMUD.CLOCK) ? ERROR_TOO_BIG : (228 < stMUD.CLOCK) ? ERROR_TOO_SMALL : ERROR_SUCC
             -EED;
 742   3              }
 743   2      
 744   2              // Save 4N clock
 745   2              stop    = stMUD.CLOCK;
 746   2      
 747   2              if (0x81 > delta)
 748   2              {
 749   3                  stMUD.CLOCK = stMUD.CLOCK + 4;
 750   3                  Set_Clock();
 751   3                  Set_H_Position();
 752   3              }
 753   2      
 754   2              ulMaxVal    = 0;
 755   2              delta       = 4;    // Initial value must be (N * AUTO_CLOCK_STEP)
 756   2              do
 757   2              {		
 758   3                  if (ERROR_SUCCEED != Measure_PositionN(NM))    return ERROR_ABORT;
 759   3      
 760   3                  // Set auto-tracking window
 761   3                  Data[0] = 6;
 762   3                  Data[1] = Y_INC;
 763   3                  Data[2] = H_BND_STA_L_75;
 764   3                  Data[3] = (unsigned char)(usH_Start + MEAS_H_STA_OFFSET - 2);
 765   3                  Data[4] = (unsigned char)(usH_End + MEAS_H_END_OFFSET + 1);
 766   3                  Data[5] = ((unsigned char)((usH_Start + MEAS_H_STA_OFFSET - 2) >> 4) & 0x70) | ((unsigned char
             -)((usH_End + MEAS_H_END_OFFSET + 1) >> 8) & 0x0f);
 767   3                  Data[6] = 0;
 768   3                  RTDWrite(Data);
 769   3                  
 770   3                  // Select color for auto-phase tracking
 771   3                  RTDSetByte(MARGIN_B_7D, ucResult);
 772   3      
 773   3                  // Set threshold
 774   3                  RTDSetByte(DIFF_THRED_7E, (0x7b == ucDetect) ? 0x50 : 0x70);
 775   3      
 776   3                  ulTemp0 = 0;
 777   3                  ucPhase = 0x00;
 778   3                  do
 779   3                  {
 780   4                      Set_Phase(ucPhase);
 781   4      
 782   4                      RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
 783   4      
 784   4                      Wait_Finish();
 785   4                      if (ERROR_SUCCEED != Data[0])   return Data[0];
 786   4      
 787   4                      Read_Auto_Info(1);
 788   4                      if (ulTemp0 < ((unsigned long *)Data)[1])   ulTemp0 = ((unsigned long *)Data)[1];
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 14  

 789   4      
 790   4                      ucPhase += 0x20;
 791   4                  }
 792   3                  while (0x80 > ucPhase);
 793   3      
 794   3                  if (ulMaxVal < ulTemp0)
 795   3                  {
 796   4                      ulMaxVal    = ulTemp0;
 797   4                      count       = stMUD.CLOCK;
 798   4                  }
 799   3      
 800   3                  if (0x00 == delta)
 801   3                  {
 802   4                      if (128 < stMUD.CLOCK)
 803   4                      {
 804   5                          // See if default clock is the best
 805   5                          delta       = 0xff;
 806   5                          stMUD.CLOCK = 128;
 807   5                          Set_H_Position();
 808   5                          Set_Clock();
 809   5                          
 810   5                          continue;
 811   5                      }
 812   4                      else
 813   4                          break;
 814   4                  }
 815   3                  else if (0xff == delta)
 816   3                  {
 817   4                      // Finish searching after checking if default clock is suitable.
 818   4                      break;
 819   4                  }
 820   3      
 821   3                  delta       -= AUTO_CLOCK_STEP;
 822   3                  stMUD.CLOCK -= AUTO_CLOCK_STEP;
 823   3                  Set_H_Position();
 824   3                  Set_Clock();
 825   3              }
 826   2              while (1); 
 827   2      
 828   2              /*
 829   2              if (0x7b == ucDetect)
 830   2                  stMUD.CLOCK = ((unsigned long)0x38000 < ulMaxVal) ? count : stop;
 831   2              else
 832   2                  stMUD.CLOCK = ((unsigned long)0x48000 < ulMaxVal) ? count : stop;
 833   2              */
 834   2              if (0x7b == ucDetect)
 835   2                  stMUD.CLOCK = ((unsigned long)0x68000 < ulMaxVal) ? count : stop;
 836   2              else
 837   2                  stMUD.CLOCK = ((unsigned long)0xc8000 < ulMaxVal) ? count : stop;
 838   2      
 839   2              Set_Clock();
 840   2              Set_H_Position();
 841   2              Set_Clock();
 842   2          }
 843   1      
 844   1      #endif
 845   1      
 846   1          return (28 > stMUD.CLOCK) ? ERROR_TOO_BIG : (228 < stMUD.CLOCK) ? ERROR_TOO_SMALL : ERROR_SUCCEED;
 847   1      
 848   1      #else   // AUTO_CLOCK_METHOD = 1 (Forster Version)
              
                  unsigned char   Result;
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 15  

                  unsigned char   count, delta, stop, start;    
                  unsigned long   ulSum, ulCompare;
              
                  ulCompare   = 0;
                  ulSum       = 0;
                      
                  ///////////////////////////////
                  //  Measure (V) Start & End  //

⌨️ 快捷键说明

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