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

📄 lcd_func.lst

📁 keil c51平台,此代码可用于学习TFT LCD 之TCON,SCALER,OSD,(本人自己修改)
💻 LST
字号:
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE LCD_FUNC
OBJECT MODULE PLACED IN .\REL_OUT\Lcd_func.obj
COMPILER INVOKED BY: D:\keil-701\C51\BIN\C51.EXE Lcd_func.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\REL_OUT\
                    -Lcd_func.lst) OBJECT(.\REL_OUT\Lcd_func.obj)

line level    source

   1          #define __FUNC__
   2          
   3          #include "reg52.h"
   4          #include "intrins.h"
   5          #include "string.h"
   6          
   7          #include "MAIN_DEF.H"
   8          #include "CONFIG.H"
   9          #include "ACCESS.H"
  10          
  11          #if(MENU_TYPE == MENU_REL)
  12          #include "OSD_REL.H"
  13          #endif
  14          #if(MENU_TYPE == MENU_KTC)
              #include "OSD_KTC.H"
              #endif
  17          
  18          #include "LCD_COEF.H"
  19          #include "LCD_MAIN.H"
  20          #include "LCD_AUTO.H"
  21          #include "LCD_FUNC.H"
  22          #include "LCD_OSD.H"
  23          
  24          #if (TV_CHIP != TV_NONE)
              #include "TUNER.H"
              #endif
  27          
  28          void SetVolume()
  29          {
  30   1          stGUD3.VOLUME   &= 0x1f;
  31   1      
  32   1      #if (AUDIO_TYPE == AUDIO_SC7313)
                  Data[0] = 10;
                  Data[1] = ADDR_SC7313;
                  Data[2] = 0x78;                           // Treble       - 0   dB  01111000b
                  Data[3] = 0x68;                           // Bass         - 0   dB  01101000b
              
              if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07) || SOURCE_DVI == (stGUD1.INPUT_SOURCE & 0x07))
                  Data[4] = 0x49;                           // Switch       - 7.5 dB  01001001b   chanel 2
              else if (SOURCE_TV == (stGUD1.INPUT_SOURCE & 0x07))
                  Data[4] = 0x48;                           // Switch       - 7.5 dB  01001000b   chanel 1
              else if(SOURCE_AV == (stGUD1.INPUT_SOURCE & 0x07) || SOURCE_SV == (stGUD1.INPUT_SOURCE & 0x07))
                  Data[4] = 0x4a;                           // Switch       - 7.5 dB  01001010b   chanel 3
              else
                  Data[4] = 0x4a;
                  
                  if (!bFreeRun)
                  {
                      Data[5] = 0xb4;                           // Front right  - mutedB  10110100b
                      Data[6] = 0x94;                           // Front left   - mutedB  10010100b
                  }
                  else
                  {
                      Data[5] = 0xbf;                           // Front right  - mutedB  10110100b
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 2   

                      Data[6] = 0x9f;                           // Front left   - mutedB  10010100b           
                  }   
                  Data[7] = 0xff;                           // back  right  - mutedB  11111111b
                  Data[8] = 0xdf;                           // back  right  - mutedB  11011111b
                  Data[9] = 0x00 | (stGUD3.VOLUME << 1);   // Volume       - 0   dB  00xxxxx0b
                  I2CWrite(Data);
              #endif
  62   1      
  63   1      #if (AUDIO_TYPE == AUDIO_62429)
                  
                  if (stGUD3.VOLUME != 31)
                  {    
                      Data[0] = 42 + (unsigned int) 45 * (31 - stGUD3.VOLUME) / 31;
                      bAUDIO_PD = 1;
                  }
                  else
                  {    
                      Data[0] = 0;
                      bAUDIO_PD = 0;
                  }    
                      
                  I2CWrite2(Data[0]);
              
              #endif
  79   1      }
  80          
  81          void WriteGamma(unsigned char code *arrayR, unsigned char code *arrayG, unsigned char code *arrayB)
  82          {
  83   1          unsigned char   n   = 0;
  84   1      
  85   1          RTDSetBit(COLOR_CTRL_5D, 0xfb, 0x10);   // Disable GAMMA & Enable Access Channel
  86   1          
  87   1          // GAMMA_RED
  88   1          bRTD_SCSB   = 0;
  89   1          RTDSendAddr(RED_GAMMA_64, WRITE, N_INC);
  90   1          do
  91   1          {
  92   2              RTDSendByte(arrayR[n]);
  93   2          }
  94   1          while (++n);    // if n is 0xff, then n will be 0x00 after increased.
  95   1      
  96   1          bRTD_SCLK   = 0; 
  97   1          bRTD_SCLK   = 1;           
  98   1          bRTD_SCSB   = 1;
  99   1      
 100   1          
 101   1          // GAMMA_GREEN
 102   1          bRTD_SCSB   = 0;
 103   1          RTDSendAddr(GRN_GAMMA_65, WRITE, N_INC);
 104   1          do
 105   1          {
 106   2              RTDSendByte(arrayG[n]);
 107   2          }
 108   1          while (++n);
 109   1      
 110   1          bRTD_SCLK   = 0; 
 111   1          bRTD_SCLK   = 1;           
 112   1          bRTD_SCSB   = 1;
 113   1      
 114   1          
 115   1          //GAMMA_BLUE
 116   1          bRTD_SCSB   = 0;
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 3   

 117   1          RTDSendAddr(BLU_GAMMA_66, WRITE, N_INC);
 118   1          do
 119   1          {
 120   2              RTDSendByte(arrayB[n]);
 121   2          }
 122   1          while (++n);
 123   1      
 124   1          bRTD_SCLK   = 0; 
 125   1          bRTD_SCLK   = 1;           
 126   1          bRTD_SCSB   = 1;
 127   1      
 128   1          RTDSetBit(COLOR_CTRL_5D, 0xef, 0x04);   // Enable GAMMA & Diable Access Channel
 129   1      }
 130          
 131          void WriteDither(unsigned char code *array)
 132          {
 133   1          unsigned char   n;
 134   1      
 135   1          RTDSetBit(COLOR_CTRL_5D, 0xb7, 0x68);   // Enable DITHER & Enable Access Channels
 136   1      
 137   1          bRTD_SCSB   = 0;
 138   1          RTDSendAddr(DITHER_PORT_67, WRITE, N_INC);
 139   1      
 140   1          for (n = 0; n < 8; n++)     RTDSendByte(array[n]);
 141   1      
 142   1          bRTD_SCLK   = 0; 
 143   1          bRTD_SCLK   = 1;           
 144   1          bRTD_SCSB   = 1;
 145   1      
 146   1          RTDSetBit(COLOR_CTRL_5D, 0x1f, 0x88);   // Enable DITHER & Disable Access Channels
 147   1      }
 148          
 149          void WriteSU_COEF(unsigned char code *arrayH, unsigned char code *arrayV)
 150          {
 151   1          unsigned char   n;
 152   1          
 153   1          RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x01);     // Enable H-Coeff access
 154   1      
 155   1          bRTD_SCSB   = 0;
 156   1          RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
 157   1          for (n = 0; n < 128; n++)    RTDSendByte(arrayH[n]);
 158   1      
 159   1          bRTD_SCLK   = 0; 
 160   1          bRTD_SCLK   = 1;           
 161   1          bRTD_SCSB   = 1;
 162   1      
 163   1          RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x03);     // Enable V-Coeff access
 164   1          
 165   1          bRTD_SCSB   = 0;
 166   1          RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
 167   1          for (n = 0; n < 128; n++)    RTDSendByte(arrayV[n]);
 168   1      
 169   1          bRTD_SCLK   = 0; 
 170   1          bRTD_SCLK   = 1;           
 171   1          bRTD_SCSB   = 1;
 172   1      
 173   1          RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0xc4);     // Disable filter coefficient access
 174   1      
 175   1      }
 176          
 177          void Set_H_Position(void)
 178          {
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 4   

 179   1      #if(AS_NON_FRAMESYNC)
                  RTDSetBit(ODD_CTRL_8E,0xef,0x00);
              #endif
 182   1      
 183   1          // if the backporch is far small then the standard one,
 184   1              // it is possibile that even IHS_Delay decrease to zero still can't correct the H position
 185   1              // so adjust the usIPH_ACT_STA first and turn back to original value later
 186   1      
 187   1          if(stMUD.H_POSITION < ucH_Min_Margin)
 188   1          {
 189   2             usIPH_ACT_STA = usIPH_ACT_STA - (ucH_Min_Margin - stMUD.H_POSITION);
 190   2             stMUD.H_POSITION = ucH_Min_Margin;
 191   2          }
 192   1      
 193   1          ((unsigned int*)Data)[4] = usIPH_ACT_STA + (stMUD.CLOCK >> 1) - 64;
 194   1      
 195   1      
 196   1          Wait_For_Event(EVENT_IEN_STOP);
 197   1              
 198   1          Data[0] = 5;
 199   1          Data[1] = Y_INC;
 200   1          Data[2] = IPH_ACT_STA_06;
 201   1          Data[3] = (unsigned char)((unsigned int*)Data)[4];
 202   1          Data[4] = (unsigned char)(((unsigned int*)Data)[4] >> 8);
 203   1          Data[5] = 0;    
 204   1          RTDWrite(Data);
 205   1      
 206   1          // Update IHS delay according to phase
 207   1      //    Set_Phase(stMUD.PHASE & 0x7c);
 208   1          //Data[0]     = PROGRAM_HDELAY + (stMUD.H_POSITION - ucH_Min_Margin);
 209   1           Data[12] = (stMUD.H_POSITION - ucH_Min_Margin) + PROGRAM_HDELAY;
 210   1              
 211   1              RTDSetByte(IHS_DELAY_8D, Data[12]);
 212   1      
 213   1      #if(AS_NON_FRAMESYNC)
                  if(bFrameSync && bStable)
                      RTDSetBit(ODD_CTRL_8E,0xef,0x10);
              #endif
 217   1      }
 218          
 219          void Set_V_Position(void)
 220          {
 221   1          unsigned int    usIV_Temp, usDV_Temp;
 222   1      
 223   1      #if(AS_NON_FRAMESYNC)
                  RTDSetBit(ODD_CTRL_8E,0xef,0x00);
              #endif
 226   1      
 227   1          if (ucV_Max_Margin < stMUD.V_POSITION)
 228   1          {
 229   2              RTDSetByte(IVS_DELAY_8C, (PROGRAM_VDELAY + stMUD.V_POSITION - ucV_Max_Margin));
 230   2              usIV_Temp   = usIPV_ACT_STA + ucV_Max_Margin - 128;
 231   2              usDV_Temp   = (unsigned int)ucDV_Delay + ucV_Max_Margin - 128;
 232   2          }
 233   1          else
 234   1          {
 235   2              RTDSetByte(IVS_DELAY_8C, PROGRAM_VDELAY);
 236   2              usIV_Temp   = usIPV_ACT_STA + stMUD.V_POSITION - 128;
 237   2              usDV_Temp   = (unsigned int)ucDV_Delay + stMUD.V_POSITION - 128;
 238   2          }
 239   1      
 240   1          Wait_For_Event(EVENT_IEN_START);
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 5   

 241   1          Data[0] = 4;
 242   1          Data[1] = N_INC;
 243   1          Data[2] = IV_DV_LINES_38;
 244   1          Data[3] = (unsigned char)usDV_Temp;
 245   1          Data[4] = 5;    
 246   1          Data[5] = Y_INC;
 247   1          Data[6] = IPV_ACT_STA_0A;
 248   1          Data[7] = (unsigned char)usIV_Temp;
 249   1          Data[8] = (unsigned char)(usIV_Temp >> 8);
 250   1          Data[9] = 0;
 251   1          RTDWrite(Data);
 252   1      
 253   1          Wait_For_Event(EVENT_IEN_START);
 254   1      
 255   1          RTDSetByte(STATUS0_01, 0x00);  // Clear status
 256   1          RTDSetByte(STATUS1_1F, 0x00);  // Clear status
 257   1      
 258   1      #if(AS_NON_FRAMESYNC)
                  if(bFrameSync && bStable)
                      RTDSetBit(ODD_CTRL_8E,0xef,0x10);
              #endif
 262   1      }
 263          
 264          
 265          #if ( BOARD_TYPE > 19  )                //LVDS BOARD
              void Set_Clock(void)
              {
                  unsigned char   ucM_Code, ucN_Code, ucTemp0, ucTemp1, ucResult;
              
                  // Issac :
                  // In this F/W, the frequency of PLL1 is fixed to 24.576*19/2=233.472MHz.
                  // Our goal is to find the best M/N settings of PLL2 according to the relationship below
                  // Best Fav = 233.472 * 32 / 31 = 241.003Mhz, and pixel rate = Fav * M / N
                  // Too small or large N code will cause larger jitter of ADC clock.
                  // In this F/W, I limite N code value between 16 and 31.
              
                  unsigned int    usClock = usADC_Clock + (unsigned int)stMUD.CLOCK - 128;    // Pixel clock number
                  unsigned long   ulRate  = (unsigned long)24576 * usClock / usStdHS;         // Pixel clock in kHz
              
              #if(AS_PLL_NONLOCK)
                  RTDSetBit(ODD_CTRL_8E,0xdf,0x00);
              #endif
              
              #if(AS_NON_FRAMESYNC)
                  RTDSetBit(ODD_CTRL_8E,0xef,0x00);
              #endif
              
              #if (TUNE_APLL)
                  RTDSetBit(DV_TOTAL_STATUS_3D, 0xdf, 0x00);//Disable PE Max Measurement
                  RTDSetByte(DV_TOTAL_STATUS_3D,0x40); //clear PE Max value
                  ucPE_Max = 0;
              #endif
              
                  ((unsigned int *)Data)[0]  = 500;
              
                  ucM_Code    = 0;
                  ucN_Code    = 0;
                  ucResult    = 0;
                  ucTemp0     = 7;
                  do
                  {
                      //Fav * PLL2_M / PLL2_N = ulRate
C51 COMPILER V7.50   LCD_FUNC                                                              07/28/2008 16:10:53 PAGE 6   

                      //PLL2_M = ulRate * PLL2_N / Fav;
                      ucTemp1 = ulRate * ucTemp0 / 253687;// (20/2 * 24.576 *32/31)
              
                      if (2 <= ucTemp1)
                      {   //Fav = ulRate * PLL2_N / PLL2_M
                          ((unsigned long *)Data)[2]  = ulRate * ucTemp0 / ucTemp1;
                                                                      //(20/2 * 24.576 * 16)
                                      ((unsigned int *)Data)[1]   = (unsigned long)393216000 / ((unsigned long *)Data)[2];
                          // > 31/2 = 15.5
                          if (1550 <= ((unsigned int *)Data)[1])
                          {
                              if (1570 >= ((unsigned int *)Data)[1])
                              {
                                  ucN_Code    = ucTemp0;
                                  ucM_Code    = ucTemp1;
                                  break;
                              }
              
                              ((unsigned int *)Data)[1]   = ((unsigned int *)Data)[1] - 1550;
                          }
                          else //

⌨️ 快捷键说明

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