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

📄 lcd_main.lst

📁 keil c51平台,此代码可用于学习TFT LCD 之TCON,SCALER,OSD,(本人自己修改)
💻 LST
📖 第 1 页 / 共 5 页
字号:
1058   5      
1059   5                          bVpole_Curr = 1;
1060   5                          bHpole_Curr = 1;
1061   5                          ucSync_Type = SYNC_CS;
1062   5                      }
1063   4      
1064   4                  }
1065   3              }
1066   2          }
1067   1          else
1068   1          {
1069   2              if (ucMode_Found != ucMode_Temp)
1070   2              {
1071   3                  ucMode_Times    = 1;
1072   3                  ucMode_Found    = ucMode_Temp;
1073   3      
1074   3                  // To prevent from mistaking CS (with VS) for SS, we check SYNC type once when finding a mode 
             -in SS.
1075   3                  if (SYNC_SS == ucSync_Type)
1076   3                  {           
1077   4                      RTDSetByte(SYNC_CTRL_4B, 0x55);
1078   4      
1079   4                      RTDSetByte(SYNC_POR_4C, 0x22);
1080   4      
1081   4                      m   = (MODE_DETECT_FREQ + 1) * 20;       
1082   4                      do
1083   4                      {   
1084   5                          Delay_Xms(1);
1085   5                          RTDRead(SYNC_POR_4C, 0x05, Y_INC);
1086   5                      }
1087   4                      while ((Data[0] & 0x02) && (--m));
1088   4       
C51 COMPILER V7.50   LCD_MAIN                                                              07/28/2008 16:10:53 PAGE 19  

1089   4                      Data[5] = Data[3];
1090   4                      Data[4] = Data[4] & 0x87;
1091   4                      Data[3] = Data[1];
1092   4                      Data[2] = Data[2] & 0x8f;
1093   4      
1094   4                      if ((0 == ((unsigned int *)Data)[1]) || (0x07ff <= ((unsigned int *)Data)[1]) ||
1095   4                          (0 == ((unsigned int *)Data)[2]) || (0x07ff <= ((unsigned int *)Data)[2]) ||
1096   4                          (0 == m))
1097   4                      {
1098   5                          ucSync_Type = SYNC_SS;
1099   5      
1100   5                          RTDSetByte(SYNC_CTRL_4B, 0x14);
1101   5                      }
1102   4                      else
1103   4                      {
1104   5                          ucSync_Type = SYNC_CS;
1105   5      
1106   5                          RTDCodeW(VGA_SET_CS);
1107   5      
1108   5                          bVpole_Curr = 1;
1109   5                          bHpole_Curr = 1;
1110   5                      }
1111   4                  }
1112   3                  else if (SYNC_SOG == ucSync_Type)
1113   3                  {
1114   4                      RTDSetByte(SYNC_CTRL_4B, 0x14);
1115   4                      Delay_Xms(8);
1116   4      
1117   4                      RTDSetByte(SYNC_POR_4C, 0x00);
1118   4                      RTDSetByte(SYNC_POR_4C, 0x02);
1119   4      
1120   4                      m   = (MODE_DETECT_FREQ + 1) * 20;       
1121   4                      do
1122   4                      {   
1123   5                          Delay_Xms(1);
1124   5                          RTDRead(SYNC_POR_4C, 0x05, Y_INC);
1125   5                      }
1126   4                      while ((Data[0] & 0x02) && (--m));
1127   4       
1128   4                      Data[5] = Data[3];
1129   4                      Data[4] = Data[4] & 0x87;
1130   4                      Data[3] = Data[1];
1131   4                      Data[2] = Data[2] & 0x8f;
1132   4      
1133   4                      if ((0 == ((unsigned int *)Data)[1]) || (0x07ff <= ((unsigned int *)Data)[1]) ||
1134   4                          (0 == ((unsigned int *)Data)[2]) || (0x07ff <= ((unsigned int *)Data)[2]) ||
1135   4                          (0 == m))
1136   4                      {
1137   5                          ucSync_Type = SYNC_SOG;
1138   5      
1139   5                          RTDSetByte(SYNC_CTRL_4B, 0x57);
1140   5                          Delay_Xms(8);
1141   5                          
1142   5                          RTDSetByte(SYNC_POR_4C, 0x00);
1143   5                      }
1144   4                      else
1145   4                      {
1146   5                          ucSync_Type = SYNC_SS;
1147   5      
1148   5                          RTDCodeW(VGA_SET_SS);
1149   5      
1150   5                          bVpole_Curr = 1;
C51 COMPILER V7.50   LCD_MAIN                                                              07/28/2008 16:10:53 PAGE 20  

1151   5                          bHpole_Curr = 1;
1152   5                      }
1153   4                  }
1154   3              }
1155   2              else
1156   2              {   
1157   3                  if (VGA_SEARCH_TIMES > ucMode_Times)
1158   3                  {
1159   4                      ucMode_Times ++;
1160   4                  }
1161   3                  else
1162   3                  {
1163   4                      
1164   4                      bLIGHT_PWR  = LIGHT_OFF;        // Turn off BackLight for reset display
1165   4                      
1166   4                      RTDSetByte(HOSTCTRL_02, 0x40);  // Wake RTD up
1167   4                      RTDCodeW(OSD_Reset);            // Clear OSD
1168   4      
1169   4                      ucMode_Curr     = ucMode_Found; // Supported mode found
1170   4                      ucMode_Times    = 0;            // Reset mode timer
1171   4                      bStable         = 0;            // bStable must be cleared when mode changed
1172   4      
1173   4                      Display_VGA_Set();              // Set VGA Mode registers
1174   4      
1175   4      #if (RTDDEBUG)
                              if (ucMode_PrevAct == ucMode_Curr)
                              {
                                  if (0xff > ucMode_QuitCnt)      ucMode_QuitCnt += 1;
                              }
                              else
                              {
                                  ucMode_PrevAct  = ucMode_Curr;
                                  ucMode_QuitCnt  = 0;
                                  ucDebug         = 0;
                              }
              #endif                
1187   4                  }
1188   3              }
1189   2          }
1190   1      }
1191          
1192          //-------------------  Check VGA Mode  -------------------//
1193          void Check_VGA_Mode(void)
1194          {    
1195   1          RTDRead(SYNC_POR_4C, 0x05, Y_INC);
1196   1      
1197   1          if (Data[0] & 0x02)
1198   1          {
1199   2              RTDSetByte(SYNC_POR_4C, 0x20);          // Input signal time-out. Reset sync-processor
1200   2      
1201   2              ucMode_Found    = MODE_NOSUPPORT;
1202   2          }
1203   1          else                        
1204   1          {
1205   2              bVpole_Curr = (bit)(Data[0] & 0x08);    // Current usVsync polarity
1206   2              bHpole_Curr = (bit)(Data[0] & 0x04);    // Current usHsync polarity
1207   2      
1208   2              Data[5] = Data[3];
1209   2              Data[4] = Data[4] & 0x87;
1210   2              Data[3] = Data[1];
1211   2              Data[2] = Data[2] & 0x8f;
1212   2              usHsync = ((unsigned int *)Data)[1];    // Current usHsync timing
C51 COMPILER V7.50   LCD_MAIN                                                              07/28/2008 16:10:53 PAGE 21  

1213   2              usVsync = ((unsigned int *)Data)[2];    // Current usVsync timing
1214   2      
1215   2              // Polarity must be correct
1216   2              if ((bVpole_Curr != bVpole_Prev) || (bHpole_Curr != bHpole_Prev))
1217   2              {
1218   3                  RTDRead(VGIP_SIGINV_05, 0x01, N_INC);
1219   3                  
1220   3                  Data[0] &= 0xd7;    // HS_RAW & VS positive
1221   3      
1222   3                  if (!bHpole_Curr)   Data[0] |= 0x20;
1223   3      
1224   3                  if (!bVpole_Curr && SYNC_SS == ucSync_Type)     Data[0] |= 0x08;    // Seperate sync
1225   3                  
1226   3                  RTDSetByte(VGIP_SIGINV_05, Data[0]);
1227   3      
1228   3                  ucMode_Found    = MODE_NOSUPPORT;
1229   3              }
1230   2              else
1231   2              {
1232   3                  if (0x07ff <= usHsync || 0x07ff <= usVsync || 0 == usHsync || 0 == usVsync)     // Check overf
             -low
1233   3                  {
1234   4                      ucMode_Found    = MODE_NOSUPPORT;
1235   4                  }
1236   3                  else
1237   3                  {
1238   4                      if ((usHsync < (usStdHS - 1)) || (usHsync > (usStdHS + 3)) ||
1239   4                          (usVsync < (usStdVS - 1)) || (usVsync > (usStdVS + 3)))
1240   4                      {   
1241   5                          ucMode_Found    = MODE_NOSUPPORT;
1242   5                      }
1243   4                      else
1244   4                      {
1245   5                          ucMode_Found    = ucMode_Curr;
1246   5                      }
1247   4                  }
1248   3              }
1249   2          }
1250   1          
1251   1          if (MODE_NOSUPPORT == ucMode_Found)
1252   1          {
1253   2              Reset_Mode();
1254   2          }   
1255   1          else
1256   1          {
1257   2              bStable = 1;    // Set bStable to 1 when signal timing is stable.
1258   2              LED_GREEN = 0X00;
1259   2              LED_RED = 0X01; 
1260   2      
1261   2      #if(AS_NON_FRAMESYNC)
                      RTDSetByte(STATUS0_01, 0x00);  // Clear status
                      RTDSetByte(STATUS1_1F, 0x00);  // Clear status
              
                      if(bFrameSync)
                         RTDSetBit(ODD_CTRL_8E,0xef,0x10);
              #endif
1268   2          }
1269   1      
1270   1      }
1271          
1272          
1273          /////////////////////////////////////////////////////////
C51 COMPILER V7.50   LCD_MAIN                                                              07/28/2008 16:10:53 PAGE 22  

1274          //------------------ Detect VIDEO Mode ----------------//
1275          /////////////////////////////////////////////////////////
1276          #if (VIDEO_CHIP == TW_9905)
              void Reset_TW9905(void)
              {
                  Delay_Xms(2);
                  bVDC_RESET=0;
                  Delay_Xms(20);
                  bVDC_RESET=1;
              }
              void I2CWrite_TW990X(unsigned char address,unsigned char wdata)
              {
                  Data[0] = 4;
                  Data[1] = 0x8c;
                  Data[2] = address;
                  Data[3] = wdata; 
                  I2CWrite(Data);
              }
              #endif
1293          
1294          #if(TV_NONE != TV_CHIP || VIDEO_CHIP == TW_9905)
              unsigned char I2CRead_TW990X(unsigned char address)
              {
                  unsigned char rdata;
                  I2CSendAddr(0x8c, address, 0);
                  I2CSendAddr(0x8c, 0, 1);
                  rdata = I2CGetByte(1);
                  I2CSendStop();
                  return rdata;
              }
              #endif
1305          
1306          #if(TV_CHIP != TV_NONE)
              void Detect_TV_Mode(void)
              {
                
                  ucAV_Mode = 0x02;     //PAL 50HZ
                  ucMode_Curr = MODE_VIDEO50HZ;
                  Delay_Xms(20);
                  RTDCodeW(RTD_VIDEO_50);
                  Delay_Xms(10);
                  ucMode_Times=0;
                  bStable         = 0; 
                  Display_Video_Set(); 
                  Set_Panel(1); 
              }
              void Check_TV_Mode(void)
              {
                RTDRead(VDIS_CTRL_20, 1, N_INC);
                if (0 == (Data[0] & 0x08))
                 {
                      // Change to Frame-sync display
                  RTDSetBit(VDIS_CTRL_20, 0xf6, 0

⌨️ 快捷键说明

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