📄 r_w.c.bak
字号:
I_init();
I_start();
if(I_send(0x87))
{
read_reg=I_receive();
I_stop();
printf("\nthe IF Part Status Byte is %x", read_reg);
}
}
void delay_time(unsigned int waitnop)
{
unsigned int i;
for(i=0;i<waitnop;i++)
{
}
}
void main()
{
unsigned int gl_tndb1,gl_tndb2,gl_tncb,gl_tnbb,gl_tnab;
unsigned int gl_ifb,gl_ifc,gl_ife;
unsigned int I;
unsigned int byte_number;
SCON = 0x52;
TMOD = 0x20;
TCON = 0x69;
TH1 = 0xfd;
delay_time(1000);
I_init();
REDLED = 1;
BLUELED = 1;
RES_7115=0;
RES_6752=0;
delay_time(1000);
//以下配置高频头寄存器
write_tuner(0x0c,0xf2,0x86,0x42,0xa0);
write_IF(0x16,0x70,0x4b);
delay_time(1000);
read_tuner();
read_IF();
delay_time(1000);
read_tuner();
read_IF();
REDLED = 0;
//以下为SAA7115配置
RES_7115=1;
delay_time(1000);
write_7115_single_byte( 0x01, 0x08);
write_7115_single_byte( 0x02, 0xC5);
write_7115_single_byte( 0x03, 0x20);
write_7115_single_byte( 0x04, 0x90);
write_7115_single_byte( 0x05, 0x90);
write_7115_single_byte( 0x06, 0xEB);
write_7115_single_byte( 0x07, 0xE0);
write_7115_single_byte( 0x08, 0xB0);
write_7115_single_byte( 0x09, 0x40);
write_7115_single_byte( 0x0A, 0x80);
write_7115_single_byte( 0x0B, 0x44);
write_7115_single_byte( 0x0C, 0x40);
write_7115_single_byte( 0x0D, 0x00);
write_7115_single_byte( 0x0E, 0x85);
write_7115_single_byte( 0x0F, 0x2a);
write_7115_single_byte( 0x10, 0x06);
write_7115_single_byte( 0x11, 0x00);
write_7115_single_byte( 0x12, 0x00);
write_7115_single_byte( 0x13, 0x00);
write_7115_single_byte( 0x14, 0x01);
write_7115_single_byte( 0x15, 0x11);
write_7115_single_byte( 0x16, 0xFE);
write_7115_single_byte( 0x17, 0xd8);
write_7115_single_byte( 0x18, 0x40);
write_7115_single_byte( 0x19, 0x80);
write_7115_single_byte( 0x1A, 0x77);
write_7115_single_byte( 0x1B, 0x42);
write_7115_single_byte( 0x1C, 0xA9);
write_7115_single_byte( 0x1D, 0x01);
/*
write_7115_single_byte( 0x30, 0xbc);
write_7115_single_byte( 0x31, 0xdf);
write_7115_single_byte( 0x32, 0x02);
write_7115_single_byte( 0x33, 0x00);
write_7115_single_byte( 0x34, 0xcd);
write_7115_single_byte( 0x35, 0xcc);
write_7115_single_byte( 0x36, 0x3a);
write_7115_single_byte( 0x37, 0x00);
write_7115_single_byte( 0x38, 0x03);
write_7115_single_byte( 0x39, 0x10);
write_7115_single_byte( 0x3a, 0x00);
*/
write_7115_single_byte( 0x41, 0x40);
write_7115_single_byte( 0x42, 0x00);
write_7115_single_byte( 0x43, 0x00);
write_7115_single_byte( 0x44, 0x00);
write_7115_single_byte( 0x45, 0x00);
write_7115_single_byte( 0x46, 0x00);
write_7115_single_byte( 0x47, 0x00);
write_7115_single_byte( 0x48, 0x00);
write_7115_single_byte( 0x49, 0x00);
write_7115_single_byte( 0x4a, 0x00);
write_7115_single_byte( 0x4b, 0x00);
write_7115_single_byte( 0x4c, 0x00);
write_7115_single_byte( 0x4d, 0x00);
write_7115_single_byte( 0x4e, 0x00);
write_7115_single_byte( 0x4f, 0x00);
write_7115_single_byte( 0x50, 0x00);
write_7115_single_byte( 0x51, 0x00);
write_7115_single_byte( 0x52, 0x00);
write_7115_single_byte( 0x53, 0x00);
write_7115_single_byte( 0x54, 0x4f);
write_7115_single_byte( 0x55, 0x00);
write_7115_single_byte( 0x56, 0x00);
write_7115_single_byte( 0x57, 0x00);
write_7115_single_byte( 0x58, 0x00);
write_7115_single_byte( 0x59, 0x47);
write_7115_single_byte( 0x5a, 0x03);
write_7115_single_byte( 0x5b, 0x03);
write_7115_single_byte( 0x5c, 0x00);
write_7115_single_byte( 0x5d, 0x0c);
write_7115_single_byte( 0x5e, 0x00);
// write_7115_single_byte( 0x80, 0x90);
// write_7115_single_byte( 0x81, 0x00);
// write_7115_single_byte( 0x84, 0x00);
// write_7115_single_byte( 0x85, 0x00);
// write_7115_single_byte( 0x86, 0xc5);
write_7115_single_byte( 0x83, 0x31);
write_7115_single_byte( 0x87, 0x10);
write_7115_single_byte( 0x88, 0x8a);
//以下配置6752寄存器
RES_6752=1;
delay_time(1000);
if(mode_transition(soft_reset))
printf("\n reset SAA6752 success !");
else
printf("\n reset SAA6752 fail !");
read_6752_single_byte(0x10);
delay_time(1000);
if(read_6752_single_byte(0x10)) //get running mode
{
switch(read_reg)
{
case 1: printf("\nthe current mode is IDLE!");
break;
case 2: printf("\nthe current mode is ENCODING!");
break;
case 4: printf("\nthe current mode is STOPPED!");
break;
case 8: printf("\nthe current mode is PAUSED!");
break;
case 16: printf("\nthe current mode is RESERVED!");
break;
case 32: printf("\nthe current mode is BUSY FLAG!");
break;
default: printf("\nthe current mode is unkowned! x%", read_reg);
}
}
else
printf("\nread_6752_single_byte( 0x10 ) error!\n");
write_6752_single_byte( 0x08, 0x00);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0x11, 2);
write_6752_single_byte( 0x20, 0x02);
write_6752_single_byte( 0x30, 0x01);
write_6752_single_byte( 0x31, 0x00);
write_6752_single_byte( 0x32, 0x00);
write_6752_single_byte( 0x33, 0x01);
write_6752_single_byte( 0x34, 0x00);
write_6752_single_byte( 0x40, 0x00);
write_6752_single_byte( 0x41, 0x00);
write_6752_single_byte( 0x42, 0x00);
write_6752_single_byte( 0x43, 0x00);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0x44, 2);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0x45, 2);
write_6752_single_byte( 0x46, 0x00);
write_6752_single_byte( 0x47, 0x00);
write_6752_single_byte( 0x50, 0x00);
reg_buffer[0]=0x33;
reg_buffer[1]=0x20;
reg_buffer[2]=0x16;
reg_buffer[3]=0x0d;
write_6752_multi_byte( 0x51, 4);
reg_buffer[0]=0x0A;
reg_buffer[1]=0x0F;
reg_buffer[2]=0x14;
write_6752_multi_byte( 0x52, 3);
write_6752_single_byte( 0x53, 0x00);
reg_buffer[0]=0x00;
reg_buffer[1]=0x01;
reg_buffer[2]=0x00;
reg_buffer[3]=0x00;
write_6752_multi_byte( 0x54, 16);
write_6752_single_byte( 0x55, 0x08);
write_6752_single_byte( 0x61, 0x00);
write_6752_single_byte( 0x63, 0x00);
write_6752_single_byte( 0x65, 0x00);
write_6752_single_byte( 0x70, 0x00);
write_6752_single_byte( 0x71, 0x01);
reg_buffer[0]=0x03;
reg_buffer[1]=0x0a;
write_6752_multi_byte( 0x72, 2);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0x73, 64);
write_6752_single_byte( 0x74, 0x00);
write_6752_single_byte( 0x75, 0x00);
write_6752_multi_byte( 0x76, 64);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0x77, 2);
write_6752_single_byte( 0x78, 0x20);
write_6752_single_byte( 0x7B, 0x00);
write_6752_single_byte( 0x7C, 0x00);
write_6752_single_byte( 0x7D, 0x00);
reg_buffer[0]=0x07;
reg_buffer[1]=0xd0;
write_6752_multi_byte( 0x80, 2);
reg_buffer[0]=0x0f;
reg_buffer[1]=0xa0;
write_6752_multi_byte( 0x81, 2);
write_6752_single_byte( 0x82, 0x04);
write_6752_single_byte( 0x83, 0x0C);
write_6752_single_byte( 0x84, 0x80);
write_6752_single_byte( 0x90, 0x00);
write_6752_single_byte( 0x91, 0x00);
write_6752_single_byte( 0x92, 0x00);
write_6752_single_byte( 0x93, 0x00);
write_6752_single_byte( 0x94, 0x00);
write_6752_single_byte( 0x95, 0x00);
write_6752_single_byte( 0x96, 0x00);
write_6752_single_byte( 0xA4, 0x00);
write_6752_single_byte( 0xB0, 0x05);
reg_buffer[0]=0x12;
reg_buffer[1]=0xc0;
write_6752_multi_byte( 0xB1, 2);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte( 0xB2, 2);
write_6752_single_byte( 0xB3, 0xE0);
write_6752_single_byte( 0xB4, 0xC0);
write_6752_single_byte( 0xB5, 0x00);
write_6752_single_byte( 0xB6, 0x12);
write_6752_single_byte( 0xB7, 0x00);
write_6752_single_byte( 0xB9, 0x00);
reg_buffer[0]=0x01;
reg_buffer[1]=0x00;
write_6752_multi_byte(0xC0,2);
reg_buffer[0]=0x01;
reg_buffer[1]=0x03;
write_6752_multi_byte(0xC1,2);
write_6752_PAT();
write_6752_PMT();
write_6752_SIT();
write_6752_single_byte(0xC3,0x00);
reg_buffer[0]=0x01;
reg_buffer[1]=0x04;
write_6752_multi_byte(0xC4,2);
write_6752_single_byte(0xD0,0x01);
reg_buffer[0]=0x00;
reg_buffer[1]=0x00;
write_6752_multi_byte(0xF6,2);
while(1)
{
REDLED = ~REDLED;
printf("\nplease select 1,2,3,4,5,6,7,8,9,10:\n");
printf(" 1:write the FQ1216 Tuner Part.\n");
printf(" 2:Read the FQ1216 Tuner Part.\n");
printf(" 3:write the FQ1216 IF Part.\n");
printf(" 4:Read the FQ1216 IF Part.\n");
printf(" 5:Read the single register in saa6752.\n");
printf(" 6:write the single register in saa6752.\n");
printf(" 7:Read the single register in saa7115.\n");
printf(" 8:write the single register in saa7115.\n");
printf(" 9:Read the multi-byte register in saa6752.\n");
printf(" 10:mode transtion to saa6752: \n");
scanf("%u",&option);
if(option==1)
{
printf("\nplease input db1:\n");
scanf("%x",&gl_tndb1);
printf("\nplease input db2:\n");
scanf("%x",&gl_tndb2);
printf("\nplease input cb:\n");
scanf("%x",&gl_tncb);
printf("\nplease input bb:\n");
scanf("%x",&gl_tnbb);
printf("\nplease input ab:\n");
scanf("%x",&gl_tnab);
write_tuner(gl_tndb1,gl_tndb2,gl_tncb,gl_tnbb,gl_tnab);
}
else if(option==2)
{
read_tuner();
}
else if (option==3)
{
printf("\nplease input b:\n");
scanf("%x",&gl_ifb);
printf("\nplease input c:\n");
scanf("%x",&gl_ifc);
printf("\nplease input e:\n");
scanf("%x",&gl_ife);
write_IF(gl_ifb,gl_ifc,gl_ife);
}
else if (option==4)
{
read_IF();
}
else if(option==5)
{
printf("\nplease input the register address you wanna read:\n");
scanf("%x",®_addr);
if(read_6752_single_byte(reg_addr))
printf("\nsuccess and the register value is: %x ",read_reg);
else
printf("\nfail to read saa6752.");
}
else if(option==6)
{
printf("\nplease input the register address you wanna write:\n");
scanf("%x",®_addr);
printf("\nplease input the register value you wanna write:\n");
scanf("%x",&write_reg);
if(write_6752_single_byte(reg_addr,write_reg))
printf("\nsuccess to write saa6752.\n");
else
printf("fail to write saa6752.\n");
}
else if(option==10)
{
printf("\nplease input the mode transition:\n");
scanf("%x",®_addr);
if(mode_transition(reg_addr))
printf("transition success!");
else printf("transition error!");
}
else if(option==9)
{
printf("\nplease input the register address you wanna read:\n");
scanf("%x",®_addr);
printf("\nplease input the register byte number:\n");
scanf("%u",&byte_number);
if(read_6752_multi_byte( reg_addr , byte_number ))
printf("read saa6752 success and the register value is:\n");
for(I=0;I<byte_number;I++)
printf(" %x \n", reg_buffer[I]);
}
else if(option==7)
{
printf("\nplease input the register address you wanna read:\n");
scanf("%x",®_addr);
if(read_7115_single_byte(reg_addr))
printf("\nsuccess and the register value is: %x ",read_reg);
else
printf("\nfail to read saa7115.\n");
}
else if(option==8)
{
printf("\nplease input the register address you wanna write:\n");
scanf("%x",®_addr);
printf("\nplease input the register value you wanna write:\n");
scanf("%x",&write_reg);
if(write_7115_single_byte(reg_addr,write_reg))
printf("\nsuccess to write saa7115.\n");
else
printf("\nfail to write saa7115.\n");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -