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

📄 display.lst

📁 TFT LCD驱动芯片T100A+AU7" Source code
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   DISPLAY                                                               06/16/2005 10:05:42 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE DISPLAY
OBJECT MODULE PLACED IN F:\T100_C~1\HUI_CH~1\铁将军\SIMULA~2\DISPLAY.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE F:\T100_C~1\HUI_CH~1\铁将军\SIMULA~2\DISPLAY.C DB SB OE

stmt level    source

   1          //---------------------------------------------------------------------------
   2          // Terawins Inc. Company Confidential Strictly Private
   3          //
   4          // $Archive: Display.c 702 $
   5          // $Revision: 1.01 $
   6          // $Author: JoannW $
   7          // $Date: 2002/06/18 $
   8          //
   9          // --------------------------------------------------------------------------
  10          // >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  11          // --------------------------------------------------------------------------
  12          // Copyright 2002 (c) Terawins Inc.
  13          // This is an unpublished work.
  14          // --------------------------------------------------------------------------
  15          #include <reg51.h>
  16          #include <math.h>
  17          #include "common.h"
  18          #include "system.h"
  19          #include "Struct.h"
  20          #include "TwoWire.h"
  21          #include "TW101Reg.h"
  22          #include "CfgDsply.h"
  23          #include "Display.h"
  24          uDWORD m_dwTemp[2];
  25          
  26          uWORD m_wDWHSZ=DWHSZ;
  27          extern uCHAR idata m_cScaleratio;
  28          extern uCHAR idata m_cBuff[4];
  29          extern uWORD idata m_wBuff[3];
  30          extern uDWORD   m_dwBuff[2];
  31          extern uWORD m_wVRes;           //as computed, used in output and scaling
  32          extern uWORD m_wHRes;      //as computed, used in scaling
  33          extern uWORD idata m_wVTotal;
  34          extern uCHAR idata m_cModeStatus;
  35          extern uCHAR idata m_cSource;
  36          extern uCHAR idata m_cStandard;
  37          //---------------------------------------------------------------------------------
  38          //This is for Display clock set,
  39          //the minimum difference between input freq and out freq should be more than 5MHz
  40          //---------------------------------------------------------------------------------
  41          
  42          //----------------------------------------
  43          // Local Definitions for this module
  44          //----------------------------------------
  45          
  46          void DisplayProcess(void)
  47          {
  48   1                uWORD wDVTotal, wDHTotal,wVOffset;
  49   1                uWORD wDWVSZ, wDVFrac;
  50   1                uWORD wVibLeft;
  51   1                uWORD wDHBlk;
  52   1                float fDHTotalF;
  53   1              
  54   1                I2CWriteByte(TW101, 0xC2, I2CReadByte(TW101, 0xc2) & 0xFB);
  55   1                wDWVSZ = DWVSZ; //DWVSZ == Paneal output vertial line number
C51 COMPILER V7.06   DISPLAY                                                               06/16/2005 10:05:42 PAGE 2   

  56   1      /////////////////////////Ruby
  57   1                m_dwBuff[0]=GetInputVSyncXclkCnt();//Read whole frame XCLK counter
  58   1      
  59   1                      m_wBuff[0] =  I2CReadByte(TW101, 0x59);
  60   1                      
  61   1                m_wBuff[0] <<= 8;
  62   1                m_wBuff[0] += I2CReadByte(TW101, 0x58);
  63   1      
  64   1                m_wVTotal = m_dwBuff[0]*32/m_wBuff[0];
  65   1      
  66   1                m_dwBuff[1] =  I2CReadByte(TW101, 0x83);
  67   1                m_dwBuff[1] <<= 8;
  68   1                m_dwBuff[1] =  I2CReadByte(TW101, 0x82);
  69   1                m_dwBuff[1] <<= 8;
  70   1              m_dwBuff[1] |= I2CReadByte(TW101, 0x81);
  71   1      
  72   1                wVOffset = (m_dwBuff[1]*32+m_wBuff[0]/2)/m_wBuff[0];
  73   1      /////////////////////////////////////////////////////
  74   1      
  75   1                m_dwBuff[0]=DisplayGetXclkCnt(m_dwBuff[0]);
  76   1      
  77   1                fDHTotalF=DisplayGetHVTotal(&wDHTotal,&wDVTotal,&wDVFrac,wDWVSZ,m_dwBuff[0]);
  78   1                wVibLeft=DisplayVibration(fDHTotalF,wDHTotal, &wDVTotal,wDWVSZ,wDVFrac);
  79   1      
  80   1                wDHBlk = (wDHTotal - m_wDWHSZ - DISP_DFLT_HSWIDTH)/2; 
  81   1              wDHBlk += DISP_DFLT_HSWIDTH;
  82   1      
  83   1              m_wBuff[0] = (unsigned long)wVOffset*100 * wDWVSZ/m_wVRes - wDHBlk * 100 / wDHTotal;   
  84   1      #ifdef T100               
  85   1                DisplaySetPrefill(wDWVSZ,wDHTotal,wDVTotal);
  86   1      #else
                        DisplaySetPrefill();//m_wBuff[0],wDWVSZ,wVibLeft,wDHTotal);
              #endif
  89   1              DisplaySetTiming(wDHTotal,wDVTotal);
  90   1      }
  91          
  92          
  93          #ifdef T100  //Ruby test 2004-08-19
  94          void DisplaySetPrefill( uWORD wDWVSZ, uWORD wDHTotal,uWORD wDVTotal)//(uWORD wVBlk, uWORD wDWVSZ, uWORD wV
             -ibLeft, uWORD wDHTotal,uWORD wDVTotal)
  95          {
  96   1              uWORD wPrefill;
  97   1              //To get prefill value roughly  
  98   1                      wPrefill = 2450 - (unsigned long)m_wVRes*1000 / 2/wDWVSZ;
  99   1      //              wPrefill = 5450 - (unsigned long)m_wVRes*1000 / 2/wDWVSZ;               
 100   1              //ROUNDUP(x,2)
 101   1              if(wPrefill%10 > 4)
 102   1                      wPrefill=wPrefill/10+1;
 103   1              else
 104   1                      wPrefill=wPrefill/10; 
 105   1      
 106   1              //Prefill fraction 
 107   1                      wPrefill = wPrefill/100*100+wPrefill%100;
 108   1      
 109   1              wPrefill = wPrefill +(unsigned long)(wPrefill%100)*m_wHRes/wDHTotal;  //Ruby
 110   1              m_dwBuff[0] = I2CReadByte(TW101, 0x59);
 111   1              m_dwBuff[0] <<= 8;
 112   1              m_dwBuff[0] += I2CReadByte(TW101, 0x58);
 113   1      
 114   1              wPrefill = m_dwBuff[0] * wPrefill /32 / 100;
 115   1      
 116   1              if(!m_cStandard)
C51 COMPILER V7.06   DISPLAY                                                               06/16/2005 10:05:42 PAGE 3   

 117   1              {
 118   2              m_dwTemp[0]=(wDVTotal-m_wVRes-DWVSST-DISP_DFLT_VSWIDTH)*wDHTotal;
 119   2              m_dwTemp[1]=wPrefill/DNDIV_40;
 120   2              if(m_dwTemp[0]<m_dwTemp[1])
 121   2                I2CWriteByte(TW101, 0x70, I2CReadByte(TW101, 0x70)|0x20);
 122   2              else
 123   2                        I2CWriteByte(TW101, 0x70, I2CReadByte(TW101, 0x70)&0xDF);
 124   2                        wPrefill-=0x800;
 125   2          }
 126   1              else
 127   1              {
 128   2                        I2CWriteByte(TW101, 0x70, I2CReadByte(TW101, 0x70)|0x20);
 129   2                        #ifndef CPT_7
 130   2                        wPrefill+=0x400;
 131   2                        if(m_cScaleratio==ScaleFULL)wPrefill+=0x200;
 132   2                        #endif
 133   2              }
 134   1              I2CWriteByte(TW101, 0x84, (unsigned char)wPrefill);
 135   1              I2CWriteByte(TW101, 0x85, (unsigned char)(wPrefill>>8));
 136   1      }
 137          
 138          #else
              void DisplaySetPrefill(void)//uWORD wVBlk, uWORD wDWVSZ, uWORD wVibLeft, uWORD wDHTotal)
              {
                      uWORD wPrefill;
              
              #ifdef WVGA
                      if(m_cStandard)
                              wPrefill = 0x1000+(288-m_wVRes)*0x200/5;
                      else
                              wPrefill = 0x100+(240-m_wVRes)*0x300/5;
              #endif
              #ifdef WXGA
              
                      if(m_cStandard)
                      {
                              wPrefill = 0x4000+(288-m_wVRes)*0x200/5+DELAY_LINES*0x400;
                      }
                      else
                      {
                              wPrefill = 0x3800+(240-m_wVRes)*0x300/5+DELAY_LINES*0x400;
                      }
              
              #endif
              /*
              #ifdef WXGA
                      if(m_cStandard)
                          wPrefill=0x4949;
                      else
                              wPrefill=0x3949;
              #endif
              */
                  I2CWriteByte(TW101, 0x70, I2CReadByte(TW101, 0x70)|0x20);
                      I2CWriteByte(TW101, 0x84, (unsigned char)wPrefill);
                      I2CWriteByte(TW101, 0x85, (unsigned char)(wPrefill>>8));
              }
              #endif
 174          
 175          extern uCHAR cPAL_OFFSET,cNTSC_OFFSET;
 176          extern uCHAR cPAL_Dot,cNTSC_Dot;
 177          void DisplaySetTiming(uWORD wDHTotal, uWORD wDVTotal)
 178          {
C51 COMPILER V7.06   DISPLAY                                                               06/16/2005 10:05:42 PAGE 4   

 179   1              uWORD wTemp;
 180   1      
 181   1              if(wDHTotal>2400 || wDHTotal<600)       return; //unreasonable result
 182   1      
 183   1              wTemp = ((wDHTotal - m_wDWHSZ - DISP_DFLT_HSWIDTH)>>1)-2; 
 184   1              I2CWriteByte(TW101, 0xB0, wTemp);
 185   1              I2CWriteByte(TW101, 0xB1, wTemp>>8);
 186   1      
 187   1              I2CWriteByte(TW101, 0xB2,cPAL_OFFSET );   //DWVSST
 188   1      #ifdef KVGA
 189   1         if(!m_cStandard)//NTSC
 190   1                      I2CWriteByte(TW101, 0xB2, cNTSC_OFFSET);
 191   1      #ifdef LG_7
                              I2CWriteByte(TW101, 0xB2, cNTSC_OFFSET);
              #endif
 194   1      #endif
 195   1      #ifdef WVGA
              //Ruby test 2004-06-03
                 if(!m_cStandard)//NTSC
                              I2CWriteByte(TW101, 0xB2, DWVSST);
                 else //PAL
                              I2CWriteByte(TW101, 0xB2, DWVSST-2);
              /////
              #endif
 203   1      
 204   1              I2CWriteByte(TW101, 0xB3, 0);
 205   1      
 206   1              I2CWriteByte(TW101,0xB4,(uCHAR)(m_wDWHSZ));     //4:3
 207   1              I2CWriteByte(TW101,0xB5,(uCHAR)(m_wDWHSZ>>8));
 208   1      
 209   1      //      if(!m_cStandard)I2CWriteByte(TW101, 0xB8, (unsigned char) (wDHTotal-cNTSC_Dot));
 210   1      //      else
 211   1              I2CWriteByte(TW101, 0xB8, (unsigned char) (wDHTotal));
 212   1      
 213   1      
 214   1              I2CWriteByte(TW101, 0xB9, (unsigned char)(wDHTotal>>8));
 215   1              
 216   1              I2CWriteByte(TW101, 0xBA, (unsigned char) wDVTotal);
 217   1              I2CWriteByte(TW101, 0xBB, (unsigned char)(wDVTotal>>8));         
 218   1                    
 219   1              I2CWriteByte(TW101, 0xBC, (unsigned char) DISP_DFLT_HSWIDTH);
 220   1              I2CWriteByte(TW101, 0xBD, (unsigned char)(DISP_DFLT_HSWIDTH>>8));
 221   1              
 222   1              I2CWriteByte(TW101, 0xBE, (unsigned char) DISP_DFLT_VSWIDTH);
 223   1              I2CWriteByte(TW101, 0xBF, (unsigned char)(DISP_DFLT_VSWIDTH>>8));
 224   1      }
 225          
 226          float DisplayGetHVTotal(uWORD *wDHTotal, uWORD *wDVTotal, uWORD *wDVFrac, uWORD wDWVSZ, uDWORD dwFrameXclk
             -Cnt)
 227          {
 228   1              float fDHTotalF;
 229   1         
 230   1      //Ruby  fDHTotalF = (float)dwFrameXclkCnt * m_wVRes *2/ m_wVTotal / wDWVSZ;
 231   1      
 232   1              fDHTotalF = (float)dwFrameXclkCnt * m_wVRes/ m_wVTotal / wDWVSZ;
 233   1              *wDHTotal = (int)fDHTotalF/2 * 2;
 234   1      
 235   1      #ifdef KVGA
 236   1      /*
 237   1          if(!m_cStandard)//NTSC
 238   1                      *wDHTotal = ((int)fDHTotalF/2 * 2); 
 239   1          else
C51 COMPILER V7.06   DISPLAY                                                               06/16/2005 10:05:42 PAGE 5   

 240   1                      *wDHTotal = ((int)fDHTotalF/2 * 2);
 241   1      */
 242   1       /////
 243   1       
 244   1      
 245   1          if(!m_cStandard)//NTSC
 246   1                      *wDHTotal = (int)0x0266;      //0x0266 for LG_7 0x0265 for AU_7 //0x025E; v36    //0x026B; V34
 247   1          else
 248   1                      *wDHTotal = (int)0x02EC;   //0x02E7; v36   //0x02F1;  V34

⌨️ 快捷键说明

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