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

📄 tuner.c

📁 NT68521源代码
💻 C
字号:

//TNF8532

#include "IIC.H"
#include "OSD.H"
#include "MCU.H"
#include "RAM.H"
#include "MyDef.H"
#include "TUNER.H"
#include "F63REG.H"
#include "SAA7114.H"

/**************************************************************************/
/***		vnf variable in Main filse define							***/
/***		ass();  //slow search										***/
/***		ass1(KeyFlag, NotarizeFlag);  //slender adjust				***/
/***		ChannelPlus();   //TV Channel Plus 1						***/
/***		ChannelMinus();   //TV	Channel  Minus 1					***/
/***		IntoTvMode();     //into TV mode								***/
/***		EEPROM	address		from  0x380 to 0x4ff					***/
/**************************************************************************/


unsigned char vnf,cf0,df1,rtf1,SearchChannel;
char channel;
unsigned int guage;
unsigned short StorePointer,InterruptCount;

code unsigned int Fix_Freq[] =
{
	0x58A, 0x60A, 0x68A, 0x742, 0x7C2, 0x972, 0x9F2, 0xA72, 0xAF2, 0xB72,//z5
	0xBF2, 0xC72, 0xCF2, 0xD72, 0xDF2, 0xE72, 0xef2, 0xf72, 0xFF2, 0x1072,//z8
	0x10F2,0x1172,0x11F2,0x1272,0x12F2,0x1372,0x13F2,0x1472,0x14F2,0x1572,//z18
	0x15F2,0x1672,0x16F2,0x1772,0x17F2,0x1872,0x18F2,0x1972,0x19F2,0x1A72,//z28
	0x1AF2,0x1B72,0x1BF2,0x1C72,0x1CF2,0x1D72,0x1DF2,0x1E72,0x1EF2,0x1F72,//z38
	0x1FE2,0x2062,0x20E2,0x2162,0x21E2,0x2262,0x22E2,0x2362,0x23E2,0x2462,//c22
	0x24E2,0x2562,0x2862,0x28e2,0x2962,0x29e2,0x2a62,0x2ae2,0x2b62,0x2be2,//c32
	0x2c62,0x2ce2,0x2d62,0x2de2,0x2e62,0x2ee2,0x2f62,0x2fe2,0x3062,0x30e2,//c42
	0x3162,0x31e2,0x3262,0x32e2,0x3362,0x33e2,0x3462,0x34e2,0x3562,0x35e2,//c52
	0x3662,0x36e2,0x3762,0x37e2,0x3862	
};

void AutoSet(unsigned char CF0,unsigned char CF1)
{
	if(CF0 < 0x0c)
	{SetTuner(CF0,CF1,CONTROLBYTE0,CONTROLBYTE1);}
	if(CF0 == 0x0c)
	{
		if (CF1 < 0xf2)
		{SetTuner(CF0,CF1,CONTROLBYTE0,LOWBAND);}
		else
		{SetTuner(CF0,CF1,CONTROLBYTE0,MIDBAND);}
	}
	if(CF0 > 0x0c && CF0<0x1f)
	{
		SetTuner(CF0,CF1,CONTROLBYTE0,MIDBAND);
	}
	if(CF0 == 0x1f)
	{
		if (CF1 < 0xe2)
		{SetTuner(CF0,CF1,CONTROLBYTE0,MIDBAND);}
		else
		{SetTuner(CF0,CF1,CONTROLBYTE0,HIGHBAND);}
	} 
	if(CF0 > 0x1f)
	{
		SetTuner(CF0,CF1,CONTROLBYTE0,HIGHBAND);
	}
}

void Plus_1()
{
unsigned char  t1,Fre_H,Fre_L;

	Fre_H = cf0;
	Fre_L = df1;
     while(rtf1 !=0x02 && t1 <5)
     {
       	if (Fre_L == 0xff)
          { Fre_L=0; Fre_H+=1; }
        else
          Fre_L += 1;
        AutoSet(Fre_H,Fre_L);
        Sleep(150);
        rtf1 = ReadIIC_Tuner();
        rtf1 = rtf1 & 0x07;        
		if(rtf1 == 0x02)
			Save_Channel();
        t1++;
      }
}
void Minus_1()
{
unsigned char  t1,Fre_H,Fre_L;

	Fre_H = cf0;
	Fre_L = df1;
	
    while(rtf1!=0x02 && t1 <5)
    {
         if (Fre_L == 0x0)
           {Fre_L = 0xff;Fre_H-=1;} 
         else
           Fre_L--;
        AutoSet(Fre_H,Fre_L);
        Sleep(150);
        rtf1 = ReadIIC_Tuner();
        rtf1 = rtf1 & 0x07;        
		if(rtf1 == 0x02)
			Save_Channel();
        t1++;
     }	
}

void Save_Channel(void)
{
	Write24C16(StorePointer,cf0);
	StorePointer++;
	Sleep(12);  //delay 5ms
	Write24C16(StorePointer,df1);
	StorePointer++;
	Sleep(12);  //delay 5ms
	SearchChannel++;
}

void ass(void)   //slow search
{
unsigned char s;

	InitTuner();
	SearchChannel=0;
	StorePointer = StaChanAddr;
	AUDIO_MUTE();
	SelVideoMenu = 5;
	cf0 = Fix_Freq[0]/256;
	df1 = Fix_Freq[0]%256;
	guage = cf0 * 256 + df1;
	VideoMenu0();
	for(s=0;s<95;s++)
	{
			cf0 = Fix_Freq[s]/256;
			df1 = Fix_Freq[s]%256;
			AutoSet(cf0,df1);
			ScanKeyPad();
			if(KeyBuffer==PowerKey || KeyBuffer==UpKey || KeyBuffer==DownKey || KeyBuffer==MenuKey || KeyBuffer==SourceKey)
				 goto EXIT;
			Sleep(150);     //delay 150ms
			rtf1 = ReadIIC_Tuner();
			rtf1 = rtf1 & 0x07;
			CLRWDT = 0x55;
			if(rtf1 == 0x02)
				Save_Channel();
			Minus_1();
			Plus_1();
			guage = cf0 * 256 + df1;
			ShowNum(1,8,3,SearchChannel);
			ShowSliderBar(1,2,(unsigned char)((guage-0x058a)/130.16));  //show Search Menu
	}
	Write24C16(LatChanAddr,(char)((StorePointer-StaChanAddr)/2));
	Sleep(50);
	CLRWDT = 0x55;
EXIT:
	channel = Read24C16(CurChanAddr);
	if(channel==0) {channel=1;}
	AutoSet(Read24C16(channel*2+0x37e),Read24C16(channel*2+0x37f));
	u1=4;
	ChannelNumber = Read24C16(CurChanAddr);
	ShowChannel();
	CLRWDT = 0x55;
	if(Volume != 0)   //CANCEL AUDIO MUTE
		AUDIO_On();
}

void ChannelPlus(void)   //TV Channel Plus 1
{
	if (TunerMode)
	{
		AUDIO_MUTE();
	  	channel++;
		if(channel>Read24C16(LatChanAddr))
			{channel=1;}
		cf0 = Read24C16(channel*2+0x37e);
		df1 = Read24C16(channel*2+0x37f);
 		AutoSet(cf0,df1);
		if(channel<10)
			{u1=0;ShowChannel();}
		else
			{u1=5;ShowChannel();}
		Write24C16(CurChanAddr,channel);
		Sleep(5);  //delay 5ms
		if(Volume !=0)   //CANCEL AUDIO MUTE
		{	if(!MuteFlag)
			 AUDIO_On();
		}
	}
}

void ChannelMinus(void)   //TV	Channel  Minus 1
{
	if (TunerMode)
	{
		AUDIO_MUTE();
	  	channel--;
		if(channel<1)
			{channel=Read24C16(LatChanAddr);}
		cf0 = Read24C16(channel*2+0x37e);
		df1 = Read24C16(channel*2+0x37f);
 		AutoSet(cf0,df1);
		if(channel<10)
			{u1=0;ShowChannel();}
		else
			{u1=5;ShowChannel();}
		Write24C16(CurChanAddr,channel);
		Sleep(5);  //delay 5ms
		if(Volume !=0)   //CANCEL AUDIO MUTE
		{	if(!MuteFlag)
			 AUDIO_On();
		}
	}
}

void IntoTvMode(void)
{
	CLRWDT = 0x55;
	Sleep(200);
	CLRWDT = 0x55;
	InitTuner();
	channel = Read24C16(CurChanAddr);
	if(channel==0 || channel==0xff) {channel=1;}
	AutoSet(Read24C16(channel*2+0x37e),Read24C16(channel*2+0x37f));
	u1=4;
	ChannelNumber = Read24C16(CurChanAddr);
	ShowChannel();
}

⌨️ 快捷键说明

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