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

📄 main.c

📁 PHILIPS FQ1286高频头c51驱动程序
💻 C
字号:
#include <reg52.h>
#include <intrins.h>
#include <main.h>
#include <i2c.h>
#include <fq1216.h>
#include <lcd.h>

unsigned char togglebit = 0;
unsigned char in_data = 0x26;
unsigned char auto_scan = 0;

unsigned char in_select = 0;
unsigned char i;
unsigned char tune_coarse;
unsigned char tune_fine;
unsigned char total_ch_no=0;
unsigned char cur_ch_no = MAX_CH_NO;
unsigned char tv_format=0;



void store_ch_freq(void)
{
	if(total_ch_no >= MAX_CH_NO)
		return;
    lo_freq = (in_freq + UP_IF)*16/100;
    pdivider_lo = lo_freq&0xff;
    pdivider_hi = ((lo_freq>>8)&0xff);
    i2c_data = pdivider_lo;
	i2c_write(x2402dev,total_ch_no*2);
	delay30ms();
	i2c_data = pdivider_hi;
	i2c_write(x2402dev,(total_ch_no*2)+1);
	total_ch_no++;
}

void restore_ch_freq(void)
{
     i2c_read(x2402dev,cur_ch_no*2);
     pdivider_lo = i2c_data;
     i2c_read(x2402dev,cur_ch_no*2+1);
     pdivider_hi = i2c_data;
	 tcom_data(0x0a);
	 tcom_data(0x0d);
	 dis_data(cur_ch_no);
	 tcom_data(0x20);
	 dis_data(pdivider_hi);//for trace 
	 tcom_data(0x20);
	 dis_data(pdivider_lo);//for trace
	 tcom_data(0x20);
     lo_freq = (unsigned long)(pdivider_hi<<8) + (unsigned long)pdivider_lo;
	 lo_freq = lo_freq*25l;
	 lo_freq = lo_freq/4l;	 
     in_freq = lo_freq - UP_IF;
	 fine_value = 20;                        
     wr_fq1216_rf();	
}


void skip_next_ch(void)
{
       if( tune_coarse == 0)
			 in_freq = 5750;
       else if( tune_coarse == 1)
  		     in_freq = 6550;
       else if( tune_coarse == 2)
			 in_freq = 7700;
       else if( tune_coarse == 3)
			 in_freq = 8500;
  	   else if(tune_coarse > 3 && tune_coarse < 48)
	  	     in_freq = (unsigned long) (tune_coarse*800l) +8000l;//11200-3200 = 8000
  	   else if(tune_coarse > 47 && tune_coarse < 61)
			 in_freq = (unsigned long) (tune_coarse*800l) + 7900l; //46300-38400 = 7900
	   else if(tune_coarse > 60  && tune_coarse < 94)
			 in_freq = (unsigned long) (tune_coarse*800l) + 11900l; //60675-48800 = 11900
       else
	   {
	         i2c_data = total_ch_no;
	         i2c_write(x2402dev,120);
             delay30ms();
			 auto_scan = 0;
			 cur_ch_no = 0;
	         restore_ch_freq();
			 init_fq1216();
		     dis_freq();
	   }
	   tune_coarse++;
	   tune_fine = 0;
}


/*
void skip_next_ch(void)
{
       if( tune_coarse == 0)
			 in_freq = 6100;
       else if( tune_coarse == 1)
  		     in_freq = 6700;
       else if( tune_coarse == 2)
			 in_freq = 7300;
       else if( tune_coarse == 3)
			 in_freq = 7700;
       else if( tune_coarse == 4)
			 in_freq = 8300;
       else if( tune_coarse == 5)
			 in_freq = 9100;
  	   else if(tune_coarse > 5 && tune_coarse < 124)
	  	     in_freq = (unsigned long) (tune_coarse*600l) + 6100l;//9700 - 3600 = 6100
       else
	   {
	         i2c_data = total_ch_no;
	         i2c_write(x2402dev,120);
             delay30ms();
			 auto_scan = 0;
			 cur_ch_no = 0;
	         restore_ch_freq();

		     //TMOD = 0x21; 
             //TH1 = 0xfd;
		     //TL1 = 0xfd;
			 
			 init_fq1216();
		     dis_freq();
	   }
	   tune_coarse++;
	   tune_fine = 0;

}
*/

void main()
{   
  unsigned char key;
  unsigned char oldkey;
    
  main_init();
  init_lcd();
  i2c_init();
  
  i2c_read(x2402dev,120);
  if(i2c_data > 50)
	  total_ch_no = 50;
  else
	  total_ch_no = i2c_data;


  tcom_data(0x6c); //l
  tcom_data(0x6f); //o
  tcom_data(0x63); //c
  tcom_data(0x6b); //k
  tcom_data(0x65); //e
  tcom_data(0x64); //d
  tcom_data(0x20);
  test_lcd();
  init_fq1216();
  wr_fq1216_rf();
  wr_fq1216_if_i();
  dis_freq();

  while(1);

} 

⌨️ 快捷键说明

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