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

📄 lcd_auto.lst

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 LST
📖 第 1 页 / 共 5 页
字号:
 279              Curr_PosV   = stMUD.V_POSITION;     // Save current stMUD.V_POSITION
 280              Curr_Clock  = stMUD.CLOCK;          // Save current stMUD.CLOCK 
 281              Curr_Phase  = stMUD.PHASE;          // Save current stMUD.PHASE
 282          
 283              if (ucV_Max_Margin < stMUD.V_POSITION)
 284              {
 285                  stMUD.V_POSITION    = ucV_Max_Margin;
 286                  Set_V_Position();
 287              }
 288          
 289              RTDCodeW(ADC_DEFAULT);
 290          
 291              ///////////////////////////////
 292              //   Measure  NOISE_MARGIN   //
 293              ///////////////////////////////
 294              Result      = Min_Noise_Margin();   // Data[0] : Noise Margin
 295              
 296              if (ERROR_SUCCEED == (Result & 0x80))
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 6   

 297              {
 298                  Result  = Data[0];
 299          
 300                  stMUD.CLOCK &= 0xfc;    // stMUD.CLOCK must be times of 4
 301          
 302                  if (stMUD.CLOCK != Curr_Clock || 28 > stMUD.CLOCK || 228 < stMUD.CLOCK)
 303                  {
 304                      Set_Clock();
 305                  }
 306                  
 307                  ///////////////////////////////
 308                  //       Adjust Clock        //
 309                  ///////////////////////////////
 310                  Result  = Auto_Clock_Do(Result);
 311                  
 312                  if (ERROR_SUCCEED != (Result & 0x80))
 313                  {
 314                      if (stMUD.CLOCK != Curr_Clock)
 315                      {   
 316                          // Fail to find out suitable clock. Restore original clock and H position.
 317                          stMUD.CLOCK         = Curr_Clock;
 318                          stMUD.H_POSITION    = Curr_PosH;
 319          
 320                          Set_Clock();
 321                          Set_H_Position();
 322                      }
 323                  }
 324                  else
 325                  {
 326                      if (stMUD.CLOCK != Curr_Clock)
 327                      {
 328                          stMUD.H_POSITION    = usH_Start + 128 + 64 - usIPH_ACT_STA - (stMUD.CLOCK >> 1);
 329          
 330                          if (ucH_Max_Margin < stMUD.H_POSITION)
 331                              stMUD.H_POSITION    = ucH_Max_Margin;
 332                          else if (ucH_Min_Margin > stMUD.H_POSITION)
 333                              stMUD.H_POSITION    = ucH_Min_Margin;
 334          				
 335                          Set_H_Position();
 336          
 337                          Save_MUD(ucMode_Curr);
 338                      }
 339                  }
 340              }
 341          
 342              // Restore ADC Gain/Offset
 343              SetADC_GainOffset();
 344              
 345              // Restore ADC phase 
 346              stMUD.PHASE = Curr_Phase;
 347              Set_Phase(stMUD.PHASE);
 348          
 349              // Restore vertical position
 350              if (Curr_PosV != stMUD.V_POSITION)
 351              {
 352                  stMUD.V_POSITION    = Curr_PosV;
 353                  Set_V_Position();
 354              }
 355          
 356              bAutoInProgress = 0;
 357          
 358              return Result;
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 7   

 359          }
 360          */
 361          
 362          void Read_Auto_Info(unsigned char index)
 363          {
 364   1          if (index)
 365   1          {
 366   2              index   = index << 2;
 367   2      
 368   2              RTDRead(AUTO_PHASE0_88, 4, Y_INC);
 369   2              
 370   2              Data[index + 0] = Data[3];
 371   2              Data[index + 1] = Data[2];
 372   2              Data[index + 2] = Data[1];
 373   2              Data[index + 3] = Data[0];
 374   2          }
 375   1      }
 376          
 377          #if (AUTO_CLOCK_METHOD)
              
              unsigned char FindColor()
              {
                  unsigned long   ulTemp0;
                  unsigned char   ucDetect, ucResult, ucPhase;
              
                  RTDSetByte(DIFF_THRED_7E, 0x28);
              
                  ulTemp0     = 0;
                  ucDetect    = 0x77;
                  do
                  {
                      ucResult    = COLORS_BLUE;
                      ucPhase     = COLORS_BLUE;
                      do
                      {
                          RTDSetByte(MARGIN_B_7D, ucPhase);
                          RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
              
                          Wait_Finish();
                          if (ERROR_SUCCEED != Data[0])   return Data[0];
              
                          Read_Auto_Info(1);
              
                          if (ulTemp0 < ((unsigned long *)Data)[1])
                          {
                              ulTemp0     = ((unsigned long *)Data)[1];
                              ucResult    = ucPhase;
              
                              if (0x8000 < ulTemp0)   break;
                          }
              
                          if (COLORS_BLUE == ucPhase)
                              ucPhase = COLORS_GREEN;
                          else if (COLORS_GREEN == ucPhase)
                              ucPhase = COLORS_RED;
                          else
                              break;
                      }
                      while (1);
              
                      if (0 != ulTemp0 || 0x7b != ucDetect)   break;
              
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 8   

                      ucDetect    = 0x77;
                  }
                  while (1);
              
                  return ERROR_SUCCEED;
              }
              
              unsigned long GetMaxSum(unsigned char select)
              {
                  unsigned char   ucPhase, ucDetect;
                  unsigned long   ulTemp0;
                  
                  ulTemp0 = 0;
                  ucPhase = 0;    //0,8,16,24
              
                  Set_Phase(ucPhase);
              
                  ucDetect    = select ? 0x7b : 0x77;
                 
              #if (HARDWARE_AUTO)
              
                  RTDSetByte(HW_AUTO_PHASE_9E, 0x07);     // Step 8 auto phase
                  Wait_For_IVS();
                  RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect); // Auto start
                  Wait_For_IVS();
              
                  for (ucPhase = 0; ucPhase < 4; ucPhase++)
                  {
                      Wait_For_IVS();
                      Read_Auto_Info(1);
              
                      if (ulTemp0 < ((unsigned long *)Data)[1])
                      {
                          ulTemp0   = ((unsigned long *)Data)[1] & 0xffffff00;
                      }
                  }
                  RTDSetByte(HW_AUTO_PHASE_9E, 0x00);     // Switch back to software auto phase
                  Wait_Finish();
                  
                  if (ERROR_SUCCEED != Data[0])   return 0xffffffff;
                 
              #else
              
                  while(1)
                  {
                      RTDSetByte(AUTO_ADJ_CTRL_7F, ucDetect);
                      Wait_Finish();
                      
                      if (ERROR_SUCCEED != Data[0])   return 0xffffffff;;
              
                      Read_Auto_Info(1);
              
                      if (ulTemp0 < ((unsigned long *)Data)[1])
                      {
                          ulTemp0 = ((unsigned long *)Data)[1];
                      }
                      
                      ucPhase += 0x20;
              	   
                      if (ucPhase > 0x60)     break;
                      
                      Set_Phase(ucPhase);
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 9   

                  }
              
              #endif
              
                  return ulTemp0;
              }
              
              #endif
 491          
 492          
 493          //------------------------------------------------------------------//
 494          // Return Message => ERROR_SUCCESS   : Success                      //
 495          //                   ERROR_TOO_SMALL : Measure Result << ACT_WIDTH  //
 496          //                   ERROR_TOO_BIG   : Measure Result >> ACT_WIDTH  //
 497          //                   ERROR_INPUT     : 1. IVS or IHS changed        //
 498          //                                     2. underflow or overflow     //
 499          //                   ERROR_TIMEOUT   : Measure Time_Out             //
 500          //                                     Process Time_Out             //
 501          //                   ERROR_NOTACTIVE : No Avtive Image              //
 502          //------------------------------------------------------------------//
 503          unsigned char Auto_Clock_Do(unsigned char NM)
 504          {
 505   1      #if (AUTO_CLOCK_METHOD == 0)    // AUTO_CLOCK_METHOD = 0 (Issac Version)
 506   1      
 507   1          unsigned char   ucResult;
 508   1          unsigned char   count, delta, stop;    
 509   1              
 510   1          ///////////////////////////////
 511   1          //  Measure (V) Start & End  //
 512   1          ///////////////////////////////
 513   1          ucResult    = Measure_PositionV(NM);
 514   1      
 515   1          if (ERROR_SUCCEED != (ucResult & 0x80))
 516   1          {
 517   2              if (ERROR_NOTACTIVE == ucResult)
 518   2              {
 519   3                  if (0x80 != stMUD.CLOCK)
 520   3                  {
 521   4                      stMUD.CLOCK = 0x80;
 522   4                      Set_Clock();
 523   4                      Set_H_Position();
 524   4                  }
 525   3      
 526   3                  ucResult    = Measure_PositionV(NM);
 527   3                  
 528   3                  if (ERROR_SUCCEED != (ucResult & 0x80))     return ucResult;
 529   3              }
 530   2              else
 531   2                  return ucResult;
 532   2          }
 533   1      
 534   1          NM      = NM + 0x10;    // See Min_Noise_Margin(). Horizontal Measure Result is the same when applying
             - (NM + 0x10)
 535   1      
 536   1          count   = 10;
 537   1          do
 538   1          {
 539   2              ///////////////////////////////
 540   2              //  Measure (H) Start & End  //
 541   2              ///////////////////////////////
 542   2              ucResult    = Measure_PositionH(NM);
 543   2      
C51 COMPILER V6.20c  LCD_AUTO                                                              04/15/2004 12:59:06 PAGE 10  

 544   2              if (ERROR_SUCCEED != (ucResult & 0x80))     return ucResult;
 545   2              
 546   2              usH_End = usH_End + 1 - usH_Start;
 547   2                
 548   2              // H_Active Delta
 549   2              if (usH_End < usIPH_ACT_WID)
 550   2                  delta = (usIPH_ACT_WID - usH_End > 0x00ff) ? 0xff : (unsigned char)(usIPH_ACT_WID - usH_End);
 551   2              else 
 552   2                  delta = (usH_End - usIPH_ACT_WID > 0x00ff) ? 0xff : (unsigned char)(usH_End - usIPH_ACT_WID);
 553   2      
 554   2              if (0xc8 < delta)       // The difference is too large to fine-tune.
 555   2              {
 556   3                  if (10 == count)
 557   3                  {
 558   4                      if (0x80 != stMUD.CLOCK)
 559   4                      {
 560   5                          stMUD.CLOCK = 0x80;
 561   5                          Set_Clock();
 562   5                          //Set_H_Position();
 563   5                      }
 564   4      
 565   4                      continue;
 566   4                  }
 567   3                  else
 568   3                      return (usH_End < usIPH_ACT_WID) ? ERROR_TOO_SMALL : ERROR_TOO_BIG;
 569   3              }

⌨️ 快捷键说明

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