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

📄 fq1216.h

📁 NXP UV1236高频头 C51驱动程序
💻 H
字号:
//fq1216 driver

#define fq1216_rf   0xc0
#define fq1216_if   0x86

#define UP_IF   3890  //4575 for fq1236 //3890 for fq1216 
#define DN_IF   3890

#define BG_H_L_I_IF   3890
#define LP_IF   3340
#define IP_IF   3950
#define DK_IF   3800

#define IF3340    3340
#define IF3390    3390
#define IF3800    3800
#define IF3890    3890
#define IF3950    3950
#define IF4575    4575
#define IF5875    5875

#define MIN_IPF   4800    // 48 MHZ
#define MAX_IPF   140000  // 1400 MHZ

#define MAX_CH_NO   51 //50     

#define PAL_I       0
#define PAL_DK      1
#define PAL_L       2   
#define PAL_LP      3
#define PAL_BG      4
#define PAL_IP      5

unsigned char pdivider_lo;
unsigned char pdivider_hi;

unsigned long in_freq = 18425;
unsigned long lo_freq;

unsigned char digit5;
unsigned char digit4;
unsigned char digit3;
unsigned char digit2;
unsigned char digit1;
unsigned char digit0;
unsigned char fine_value = 20;
unsigned char digit_pos = 20;
unsigned char tv_format = PAL_I;

void init_fq1216(void)
{
    lo_freq = in_freq + fine_value*5 - 100;
	digit5  = lo_freq/100000 + 0x30;
	lo_freq = lo_freq%100000;
    digit4  = lo_freq/10000 + 0x30;
	lo_freq = lo_freq%10000;
    digit3  = lo_freq/1000 + 0x30;
	lo_freq = lo_freq%1000;
    digit2  = lo_freq/100 + 0x30;
	lo_freq = lo_freq%100;
    digit1  = lo_freq/10 + 0x30;
	lo_freq = lo_freq%10;
    digit0  = (lo_freq&0xff) + 0x30;

tcom_data(0x0d);    //for trace
tcom_data(0x0a);    //for trace
tcom_data(digit5);    //for trace
tcom_data(digit4);    //for trace
tcom_data(digit3);    //for trace
tcom_data(digit2);    //for trace
tcom_data(digit1);    //for trace
tcom_data(digit0);    //for trace
tcom_data(0x20);    //for trace
//tcom_data(0x0d);    //for trace
//tcom_data(0x0a);    //for trace

}


void wr_fq1216_if(void)
{  

	if(tv_format==PAL_I)
	{
        i2c_data = 0x16;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x70;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x4A;
        i2c_write(fq1216_if,0x02);
    }
	else if(tv_format==PAL_DK)
	{
        i2c_data = 0x16;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x70;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x4B;
        i2c_write(fq1216_if,0x02);
    }
	else if(tv_format==PAL_LP)
	{
        i2c_data = 0x86;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x50;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x53;
        i2c_write(fq1216_if,0x02);
    }
	else if(tv_format==PAL_L) 
	{
        i2c_data = 0x06;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x50;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x4B;
        i2c_write(fq1216_if,0x02);
    }
	else if(tv_format==PAL_BG) 
	{
        i2c_data = 0x16;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x70;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x49;
        i2c_write(fq1216_if,0x02);
    }
	else //if(tv_format==PAL_IP) 
	{
        i2c_data = 0x16;
        i2c_write(fq1216_if,0x00);
        i2c_data = 0x70;
        i2c_write(fq1216_if,0x01);
        i2c_data = 0x4A;
        i2c_write(fq1216_if,0x02);
    }
    
	
}


void wr_fq1216_rf(void)
{ 
	if(tv_format==PAL_IP)
      lo_freq = in_freq + IF3950;	   
	else if(tv_format==PAL_DK)
      lo_freq = in_freq + IF3800;	   
	else if(tv_format==PAL_LP)
      lo_freq = in_freq + IF3340;	   
	else //if(tv_format==PAL_L) //PAL_BG PAL_IP PAL_H PAL_I
      lo_freq = in_freq + IF3890;	   
	
	lo_freq = lo_freq + fine_value*5 - 100;
	lo_freq = lo_freq*16/100;   
    pdivider_lo = lo_freq&0xff;
    pdivider_hi = ((lo_freq>>8)&0xff);
	i2c_data = pdivider_lo;	
	i2c_write(fq1216_rf,pdivider_hi);

    if(in_freq < 15400)
	{
       i2c_data = 0xa1;
    }
    else if(in_freq < 44600)
	{
       i2c_data = 0x92;
    }
	else
	{
       i2c_data = 0x34;
    }
//   i2c_write(fq1216_rf,0x86);
   i2c_write(fq1216_rf,0x8e);

}



void rd_fq1216_if(void)
{
    i2c_data = 0xff;
//	i2c_read_without_subaddr(fq1216_if,0x00);
	i2c_read_without_subaddr(fq1216_if);
}

/*
void rd_tuner_status(void)
{
    i2c_data = 0xff;
//	i2c_read_without_subaddr(fq1216_if,0x00);
	i2c_read_without_subaddr(fq1216_rf);
}
*/

⌨️ 快捷键说明

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