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

📄 main.c

📁 terawin的t103 LCD驱动程序
💻 C
字号:
/****************************************************************************
* File: MAIN.c                                                              *
* Description: main routine                                                 *
* History:     2005/08/12                                                   *
*                                                                           *
* 		Copyright 2005 (c) Terawins Inc.                                    *
****************************************************************************/

/****************************************************************************
*                               Include File                                *
****************************************************************************/

#include "reg51.h"
#include "math.h"
#include "common.h"
#include "struct.h"
#include "system.h"
#include "SRC_ctrl.h"
#include "twowire.h"
//#include "gamma.h"
#include "filter.h"
#include "keypad.h"
#include "Nvram.h"
//#include "Video.h"
#include "T803_Util.h"
#include "TW803Reg.h"
#include "remote.h"
//#include "osddraw.h"
#include "tuner.h"
#include "timer0.h"
#include "T515.h"
#include "ModeCtrl.h"
#include "Global.h"
#include "INIT.h"
#include "T803OSD.h"  // add by Sherman 
#include "VBI_Parser.h" // kenny 20060403
#include "serial.h"

/*****************************************************************************
*                  Public Function Prototypes		       		     *
*****************************************************************************/
void Initial            (void);
void SysInit	    	(void);
void SysInterruptEnable (void);

extern uCHAR 	NoSignal;
uCHAR m_c;

/****************************************************************************
*                              Public Function                              *
****************************************************************************/

void main(void)
{uCHAR x;
	Initial();
	twdDelay(NVRDELAY);
	m_cSource = I2CReadByte(EEPVIDEOBLOCK, idVIDEO_SOURCE_INDEX)&0x0f;

	if((m_cSource==0)||(m_cSource>=isrc_end))
		m_cSource=1;
	m_c=0xff;
    	m_cSource = 2;
	SourceSelect();
   	
    

	SetSignalStd();
	SetOPTiming();
	twdDelay1(50);
	DetectSignalStd();	
	OpenPanel();
   	serialIni();
	while(1)
	{  //	m_cSource=3;
	
       	serCommand(); 
#ifdef AUTO_DETECT
//		if(m_wBuff[2]>=0x4ff){
		if ((uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeRGB)||(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeRGB565))
		{    


            
			 I2CWriteByte(TW803_P0, 0x31,0x40);
             
             if((I2CReadByte(TW803_P0, 0x32)&0x03)==0x03)
               {  //SysInit();
                     
                     m_cSource=2; 
                     SourceSelect();
                     twdDelay1(50);
                    if(x==1){ x=0;
                  	Initial();
                    m_cSource=2;
                    SourceSelect();
                    SetSignalStd();
                    SetOPTiming();
	                twdDelay1(50);
                    DetectSignalStd();	
	                OpenPanel();
                  }                


               } 
              else{Detect_Sig(1);x=1;}  
        }
		else
		{   //I2CWriteByte(TW803_P0, 0x31,0x40);
           
            Detect_Sig(0);//NoSignal
	     	 if(NoSignal){
		     if(m_c<=0){m_cSource=1;}              
             if(m_c==1){m_cSource=2;} 
             if(m_c==2){m_cSource=1;}
             if(m_c==3){m_cSource=2;}
             if(m_c==4){m_cSource=1;}   
             if(m_c==5){m_cSource=3;}
             if(m_c>=6){m_c=0xff;}
             m_c=m_c+1;
             SourceSelect();
	     	}
        	DetectSignalStd();
        } 
		

#endif
	}
}


void Initial(void)
{
    SysInit();
#ifdef TCON
		TconInit();
#endif
//Ruby modify 2005-06-07
	ClosePanel(0x00,0x40,0x8a);

	LoadGammaTable(0);
}

void SysInit(void)
{
	P0=0xff;
	P1=0xff;
	P2=0xff;
	P3=0xff;
    
	//Chip Reset
	CHIP_RESET = 0;
    VIDEO_RESET=0;
	twdDelay(100);
	CHIP_RESET = 1;
	VIDEO_RESET=1;
	twdDelay(50);
	//8051Register Set
	IE    	= 0;   	// disable all interrupt
	TMOD 	= 0x11;  // Timer1 Mode 1, Timer0 Mode 1;
	//TMOD 	= 0x01; // Timer0 Mode 1;
  	EX0   	= 0;     // disable external interrupt 0, IE[0]
	EX1		= 0;
  	//ET0 	= 1;   	// enable bTimer 0
  	//IT0   = 1;     // falling endge generate interrupt, TCON[0]
  	INT0 	= 1;
	IT1   	= 1;     // falling endge generate interrupt, TCON[0]
  	INT1 	= 1;
  //  ADCTL=0x98;
  // 	cAdc=0;
    twdDelay(10);
  	//ClosePanel(0x00,0x40,0x60);
#ifdef LOADFILTER
 	LoadFilter(3);//3
#endif

	InitT803();
#ifdef NVRAM
	#ifdef RESET_EEPROM
		InitEEPRom();
	#else	
		EEPLoadPubData();
	#endif
#endif


	m_bPanelClose = 0;
	m_bBKPowerOn=0;
	m_bKyPowerOn=1;
	m_bChipPowerOn=1;
	LED_GREEN=0;
	m_cStandard=S_NTSC;	
	m_cChroma=S_NTSC;
	m_cScaleratio=ScaleFULL;
}

void SysInterruptEnable(void)
{
#ifdef TIMER1
//	Timer1Reset();
//	ET1 = 1;    // Enable Timer1 interrupt
	TR1=1;
#endif
#ifdef TIMER0
	Timer0Reset();
	ET0 = 1; 	// Enable Timer0 interrupt
	TR0 = 0;
#endif
#ifdef INTERRUPT1
	EX1 = 1;		// Enable INT1 (IR)
#endif
	EA	 = 1;		// Enable Interrupt
}

⌨️ 快捷键说明

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