📄 main.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"
#define __SRC_DEF__
#include "system.h"
#undef __SRC_DEF__
#include "twowire.h"
#include "filter.h"
#include "keypad.h"
#include "Nvram.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 "Tuner.h"
#ifdef T103
#include "T803OSD.h" // add by Sherman
#else
#include "T102OSD.h" // add by Sherman
#endif
#define __VBI_PARSING__
#include "VBI_Parser.h" // kenny 20060403
#include "OSDCtrl.h"
/*****************************************************************************
* Public Function Prototypes *
*****************************************************************************/
void Initial (void);
void SysInit (void);
void SysInterruptEnable (void);
/****************************************************************************
* Public Function *
****************************************************************************/
static uWORD AutoDetcTime=0;
void main(void)
{
Initial();
SysInterruptEnable();
//OSD Font Initial
OSDInit();
OSDTransfer(EepPublic.cOSDLang); // update the index '0x10 to 0x18'
twdDelay(NVRDELAY);
//RUBY EepPublic.cSource = I2CReadByte(EEPVIDEOBLOCK, idVIDEO_SOURCE_INDEX)&0x0f;
if((EepPublic.cSource==0)||(uiaSrcMux1[EepPublic.cSource].VideoType==itypeEND))
EepPublic.cSource=1;
SourceSelect();
twdDelay(50);
DetectSignalStd();
OSDShowSource();
// OpenPanel();
AdjGamma(); //Thomas, enable or disable gamma
//Main loop
while(1)
{
//detect key press
kyKeypad();
//handle ir event
if(ir_enable){
RemoteEvent();
ir_enable=0;
}
else if(!EX1){
EX1=1;
ir_data=0;
}
#ifdef lucy_editon
//OSD Timeout
if(m_bTimer0Overflow){
if(m_bOSDEnable)
OSDExit();
}
#endif
#ifdef VBI_CC
if ( VBI_ON )
{
twdDelay(10);
OSDEnable();
CC_Parsing();
}
#endif
#ifdef AUTO_DETECT
AutoDetcTime++;
if(AutoDetcTime>=0x4ff)
{
AutoDetcTime=0x00;
if (uiaSrcMux1[EepPublic.cSource].SourceRoute==isrcVIDEO)
DetectSignalStd();
Detect_Sig(0);
I2CWriteByte(TW803_P0, 0xE2, 0x11);
}
#endif
}
}
void Initial(void)
{
SysInit();
#ifdef TCON
TconInit();
#endif
//Ruby modify 2005-06-07
ClosePanel(0x00,0x40,0x8a);
OSDDisable();
LoadGammaTable(0);
OSDLogo();
}
void SysInit(void)
{
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
/*-------------------------------------------------------------------------
20060808 Phil added Sound
-------------------------------------------------------------------------*/
AV_AUDIO_SW1 = OFF;
TV_AUDIO_SW2 = OFF;
SV_AUDIO_SW3 = OFF;
AUDIO_STBY = OFF; //AUDIO_MUTE = OFF,AUDIO_STBY = ON means standby
AUDIO_MUTE = ON; //AUDIO_MUTE = ON, AUDIO_STBY = ON means standby
PWM = ON; //AUDIO_MUTE = ON, AUDIO_STBY = OFF means mute
//AUDIO_MUTE = OFF,AUDIO_STBY = OFF meams play,PWM controls the volume
/*-------------------------------------------------------------------------
20060808 Phil added Sound
-------------------------------------------------------------------------*/
//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;
twdDelay(10);
//ClosePanel(0x00,0x40,0x60);
#ifdef LOADFILTER
LoadFilter(3);//3
#endif
InitT803();
#ifdef NVRAM
#ifdef RESET_EEPROM
InitEEPRom();
#else
EEPLoadPubData();
OSDLoadALLData();
#endif
#endif
kyKeypadInit();
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=0;
#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 + -