一个车载音响控制程序,包括高保真立体收部分,VFD驱动显示,4路音频电子切换, 红外遥控控制 采用51单片机

源代码在线查看: radio.i

软件大小: 244 K
上传用户: horse2000
关键词: VFD 控制 车载音响
下载地址: 免注册下载 普通下载 VIP

相关代码

								#line 1 "radio.c" /0																				 				 				 				 				  				#line 1 "E:\KEIL\C51\INC\REG52.H" /0																												 				 				 				 				 				 				 sfr P0    = 0x80;				 sfr P1    = 0x90;				 sfr P2    = 0xA0;				 sfr P3    = 0xB0;				 sfr PSW   = 0xD0;				 sfr ACC   = 0xE0;				 sfr B     = 0xF0;				 sfr SP    = 0x81;				 sfr DPL   = 0x82;				 sfr DPH   = 0x83;				 sfr PCON  = 0x87;				 sfr TCON  = 0x88;				 sfr TMOD  = 0x89;				 sfr TL0   = 0x8A;				 sfr TL1   = 0x8B;				 sfr TH0   = 0x8C;				 sfr TH1   = 0x8D;				 sfr IE    = 0xA8;				 sfr IP    = 0xB8;				 sfr SCON  = 0x98;				 sfr SBUF  = 0x99;				 				 				 sfr T2CON  = 0xC8;				 sfr RCAP2L = 0xCA;				 sfr RCAP2H = 0xCB;				 sfr TL2    = 0xCC;				 sfr TH2    = 0xCD;				 				 				 				 				 sbit CY    = PSW^7;				 sbit AC    = PSW^6;				 sbit F0    = PSW^5;				 sbit RS1   = PSW^4;				 sbit RS0   = PSW^3;				 sbit OV    = PSW^2;				 sbit P     = PSW^0;  				 				 				 sbit TF1   = TCON^7;				 sbit TR1   = TCON^6;				 sbit TF0   = TCON^5;				 sbit TR0   = TCON^4;				 sbit IE1   = TCON^3;				 sbit IT1   = TCON^2;				 sbit IE0   = TCON^1;				 sbit IT0   = TCON^0;				 				 				 sbit EA    = IE^7;				 sbit ET2   = IE^5;  				 sbit ES    = IE^4;				 sbit ET1   = IE^3;				 sbit EX1   = IE^2;				 sbit ET0   = IE^1;				 sbit EX0   = IE^0;				 				 				 sbit PT2   = IP^5;				 sbit PS    = IP^4;				 sbit PT1   = IP^3;				 sbit PX1   = IP^2;				 sbit PT0   = IP^1;				 sbit PX0   = IP^0;				 				 				 sbit RD    = P3^7;				 sbit WR    = P3^6;				 sbit T1    = P3^5;				 sbit T0    = P3^4;				 sbit INT1  = P3^3;				 sbit INT0  = P3^2;				 sbit TXD   = P3^1;				 sbit RXD   = P3^0;				 				 				 sbit SM0   = SCON^7;				 sbit SM1   = SCON^6;				 sbit SM2   = SCON^5;				 sbit REN   = SCON^4;				 sbit TB8   = SCON^3;				 sbit RB8   = SCON^2;				 sbit TI    = SCON^1;				 sbit RI    = SCON^0;				 				 				 sbit T2EX  = P1^1;  				 sbit T2    = P1^0;  				 				 				 sbit TF2    = T2CON^7;				 sbit EXF2   = T2CON^6;				 sbit RCLK   = T2CON^5;				 sbit TCLK   = T2CON^4;				 sbit EXEN2  = T2CON^3;				 sbit TR2    = T2CON^2;				 sbit C_T2   = T2CON^1;				 sbit CP_RL2 = T2CON^0;				 				 				#line 9 "radio.c" /0				 				  				#line 1 "E:\KEIL\C51\INC\ABSACC.H" /0																												 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				#line 24 "E:\KEIL\C51\INC\ABSACC.H" /1				  				  				  				  				 				#line 29 "E:\KEIL\C51\INC\ABSACC.H" /0				 				 				 				 				 				 				 				#line 10 "radio.c" /0				 				  				#line 1 "mylib.h" /0				 extern void inidelay();				 extern void sys_ini();				 extern bit re_re;				 extern unsigned long rddata(void);				 extern wrdata(unsigned long x);				 extern unsigned int swdata(unsigned int dat);				 extern void wr1(void);				 extern void mack();				 extern void wrone();				 extern bit wrnbyt(unsigned char add,unsigned char start,unsigned char num,unsigned char a[]);				 extern bit rdnbyt(unsigned char add,unsigned char num,unsigned char start,unsigned char a[]);				 extern void delay50();				 extern void radio();				 extern void iniband1(unsigned char a);				 extern void iniband();				 extern unsigned char remkey2;				 extern unsigned char delay_num;				 extern unsigned long stepserch(bit a,unsigned int b);				 extern vfddigit(unsigned int ch);				 extern void display(void);				 extern void wrvfd(unsigned char addr,unsigned char dat);				 extern unsigned long rdkey();				 extern void inivfd(void);				 extern void band_step(bit direction);				 extern void band_change(void);				 extern void station_search(bit,bit);				 extern void station_change(bit direction);				 extern void vfd_clean();				 extern void volcheack(void);				 extern void delaytime(unsigned int time);				 extern void vfd_test();				 extern void display();				 extern void sub_vol(unsigned char dirc);				 extern void channel(unsigned char fun);				 extern void wr_pt2313(unsigned char com);				 extern void vfd_volume(unsigned char fun);				 extern bit repeat();				 extern unsigned char volume;				 extern unsigned char trb_vol;				 extern unsigned char bas_vol;				 extern unsigned char band;				 extern unsigned char delay_fun;				 extern void trb_vol_ct(bit dirc);				 extern void bas_vol_ct(bit dirc);				 extern void flash_eras(unsigned int band);				 extern void flash_read(unsigned char add,unsigned int band,unsigned char a[]);				 extern void flash_prog(unsigned char add,unsigned int band,unsigned char b[]);				 extern bit key_sta;				 extern bit key_long;				 extern bit key();				 extern void taiwei();				 extern void mute_(bit fun);				 extern void radio_change();				 extern void band_change(void);				 extern void eqchange();				 extern void eq_vfd(unsigned char eq);				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 				 extern union  				 {				  unsigned long all;				 struct				 {				  unsigned char addr    :8;   				  unsigned int frq      :16;  				  unsigned char cankao  :4;   				  unsigned char xs      :1;   				  unsigned char cte     :1;   				  unsigned char inp     :2;   				 }in0;				 }in0;				 extern union 				 {				  unsigned long da;				 struct				 {				  unsigned char addr    :8;   				  unsigned char bnc     :1;   				  unsigned char stmo    :1;   				  unsigned char ifen    :1;   				  unsigned char band    :1;   				  unsigned char io      :2;   				  unsigned char  ioc     :2;   				  unsigned char dz      :2;   				  unsigned char ul      :2;   				  unsigned char doc     :3;   				  unsigned char dnc     :1;   				  unsigned char test    :3;   				  unsigned char ifs     :1;   				  unsigned char dlc     :1;   				  unsigned char tbc     :1;   				  unsigned char gt      :2;   				 }in1;				 }in1;				#line 11 "radio.c" /0				 				 				 				 				 				 				 				 				 				 				 				 sbit vold=P0^0; 				 sbit voli=P0^1; 				 sbit funp=P0^2; 				 sbit next=P2^4; 				 sbit pre=P2^5; 				 sbit tuni=P2^6; 				 sbit tund=P2^7; 				 sbit fun_vfd=P1^4; 				 sbit fun_power=P3^3; 				 sbit mute_key=P0^5;				 sbit memory_key=P0^7;				 sbit band_key=P0^6;				 sbit power_key=P0^4;				 sbit tape_p=P3^1;				 sbit eq=P0^3;				 sbit mute=P3^5;				 sbit power_led=P1^0;				 bit key_sta;				 bit key_long;				 bit start=0;				 extern bit mute_l=0;				 extern bit power_l=0;				 bit key();				  unsigned char ab_am=0;				  unsigned char ab_fm=0;				 void pub();				 				 				 extern unsigned char eq_l;				  unsigned char u;				  unsigned char k;				  unsigned char fun=0;				  unsigned char code dx58[3] _at_ 0x3b;				 extern unsigned char remkey;	  				  unsigned char tai;				  				  unsigned char band; 				 bit int_power_off=0;				 static bb;				 extern unsigned char ab=0;	  				  unsigned long e=4;				 				  unsigned char i=4;								  unsigned char b[2]={2,3};			   	 				  unsigned char a[2];			     				 main()				 { 				 remkey=0x99;				 fun_power=0; 				 m:  				 key_long=key();				 sys_ini();				 tape_p=1;				 while(1)				 {				 if(!int_power_off)				 {				 remkey=0x99;				 power_l=1;				 }				 				 				 volcheack();				 if(remkey==0x99) 				 {				 fun_power=0; 				 fun_vfd=0;     				 vfd_clean();				 remkey=0;				 power_led=1;				 mute_(1);				 int_power_off=1;				 }				 if(remkey==0x98) 				 {				 remkey=0;				 mute_(0);				 power_led=0;				 int_power_off=1;				 goto 	m;				 }				 if(!power_l)				 {				 if(remkey==0x97)				 eqchange();	 				 if(remkey==0xdf)				 				 band_change();		                 				 if(band==0||band==1)				 {				 if(remkey==0x78)				 				 radio_change();				 else if(remkey==0xB5)				 station_search(0,1);	 				 else if(remkey==0xef)				 {				 if(TR0)				 {				 if(ab				 ab++;				 else				 ab=0;				 taiwei();				 remkey=0x00; 				 }				 else				 station_change(1); 				 }				 else if(remkey==0x85)				 {				 if(TR0)				 {				 if(ab>=1)				 ab--;				 taiwei();				 remkey=0x00;       				 }				 else				 station_change(0); 				 }				 else if(remkey==0x33)				 station_search(1,1);	 				 else if(remkey==0x34)				 station_search(1,0);	 				 else if(remkey==0x55)				 band_step(1);	     				 else if(remkey==0x77)				 band_step(0);	 				 }				 if(remkey==0x64) 				 sub_vol(1);				 else if(remkey==0x65) 				 sub_vol(0);				 else if(remkey==0x47) 				 {				 bb=~bb;				 if(bb)				 TR0=1;				 else				 { 				 TR0=0;				 if(band==0)				 in0.in0.frq=swdata(swdata(in0.in0.frq)-1);				 if(band==1)				 in0.in0.frq=swdata(swdata(in0.in0.frq)-0x10);				 b[0]=in0.in0.frq>>8;				 b[1]=in0.in0.frq;				 if(band==0)				 wrnbyt(0xa0,ab*2,2,b);				 else if(band==1)				 wrnbyt(0xa0,ab*2+120,2,b);				 taiwei();				 }				 remkey=0x00;				 }				 }}				 }				 void display()		 				 {				 if(in1.in1.band==1)				 vfddigit(swdata(in0.in0.frq				 else				 vfddigit(swdata(in0.in0.frq)/2-107);	  				 }				 void band_step(bit direction)				  				 {				 iniband();				 iniband1(band);				 pub();				 e=stepserch(direction,in0.in0.frq);	 				 vfd_clean();				 display();				 remkey=0x00;				 }				 void band_change(void)					   				 {  				 TR0=0;  				 fun++;				 if(band==3)				 {				 band=2;				 vfd_clean();				 wrvfd(0x05,0x5f); 				 wrvfd(0x04,0x24);				 wrvfd(0x07,0x5e);				 fun_power=1; 				 fun_vfd=1;     				 channel(1);				 remkey=0x00;				 return;				 }				 else if(band==2)				 {				 band=0;				 fun_power=0; 				 fun_vfd=0;     				 channel(0);				 vfd_clean();        				 if(band==0)				 ab=ab_fm;				 else				 ab=ab_am;				 if(band==0)				 rdnbyt(0xa0,ab*2,2,a);			  				 else				 rdnbyt(0xa0,ab*2+120,2,a);				 in0.in0.frq=a[0];					 				 in0.in0.frq=(in0.in0.frq				 iniband1(band);					   				 e=stepserch(1,in0.in0.frq);		   				 display();							   				 remkey=0x00;				 }				 else if((band==0)||(band==1))				 {				 band=3;				 fun_power=0; 				 fun_vfd=0;     				 channel(2);				 vfd_clean();        				 wrvfd(0x06,0x40);				 wrvfd(0x07,0xfd);				 wrvfd(0x04,0xfa);				 wrvfd(0x05,0xb6);				 remkey=0x00;				 }				 }				 				 void station_change(bit direction)		  				 {	 				 if(direction)				 {				 if(ab				 ab++;				 else				 ab=0;				 }				 else				 {				 if(ab>=1)				 ab--;				 }				 if(band==0)				 rdnbyt(0xa0,ab*2,2,a);			  				 else				 rdnbyt(0xa0,ab*2+120,2,a);				 in0.in0.frq=a[0];					 				 in0.in0.frq=(in0.in0.frq				 iniband();				 iniband1(band);				 e=stepserch(1,in0.in0.frq);				 vfd_clean();				 display();				 remkey=0x00;				 if(band==0)				 ab_fm=ab;				 else				 ab_am=ab;				 }				 void station_search(bit reuse,bit dir)			   				 {				 mute_(1);				 pub();				 if(band==1)				 {				 iniband();				 iniband1(band); 				 if(reuse==0)								 in0.in0.frq=0x0a30;			 				 ab=0;				 remkey=0x00;				 while((in0.in0.frq!=0x0230)&(in0.in0.frq!=0x0d98))		     				 { 	 				 e=(stepserch(dir,in0.in0.frq)&0x0000ffff);				 display();				 if((e0x3800)) 				 {				 b[0]=in0.in0.frq>>8;				 b[1]=in0.in0.frq;				 if(reuse==1)				 {				 				 goto likai;               				 }				 wrnbyt(0xa0,ab*2+120,2,b);  				 				 ab=ab+1;				 }				 if(tund&&tuni)				 key_long=1;				 if(key_long)				 if(!tund||!tuni)				 {				 key_long=0;				 goto likai;				 }				 if(remkey==0xed)				 {				 remkey=0;				 goto likai;				 }				 if(remkey==0xb5)				 {				 remkey=0x27;				 mute_(0);				 return;				 }				 }				 }				 else if(band==0)				 {				 iniband();				 iniband1(band); 				 ab=0;				 remkey=0x00;					 if(reuse==0)					 in0.in0.frq=0x35e0;			 				 while((in0.in0.frq!=0x85e0)&(in0.in0.frq!=0x6290))			     				 { 					 e=(stepserch(dir,in0.in0.frq)&0x000fffff);				 display();				 if((e0x53880)) 				 {				 b[0]=in0.in0.frq>>8;				 b[1]=in0.in0.frq;				 if(reuse==1)				 {				 goto likai;               				 }				 wrnbyt(0xa0,ab*2,2,b);  				 				 ab=ab+1;				 }				 if(tuni&&tund)				 key_long=1;				 if(key_long)				 if(!tuni||!tund)				 {				 key_long=0;				 goto likai;				 }				 if(remkey==0xed||remkey==0x1d)				 {				 remkey=0;				 goto likai;				 }				 if(remkey==0xb5)				 {				 remkey=0x27;				 mute_(0);				 return;				 }				 				 }					 				 }				 likai:				 remkey=0x00;				 tai=0x00;				 mute_(0);				 if (reuse==0)				 {				 ab=0;				 remkey=0xef;				 }				 }				 void volcheack(void)				 {  				  unsigned char a;				 voli=1;				 vold=1;				 if(!funp)				 {				 while(!funp);				 remkey=0xdf;				 return;				 }      				 if((band!=2)&&(band!=3))				 {				 if(!next)				 {				 while(!next);				 remkey=0xef;				 return;				 }      				 if(!pre)				 {				 delaytime(10);				 while(!pre);				 remkey=0x85;				 return;				 }      				 if(!memory_key)				 {				 delaytime(400);				 while(!memory_key);				 remkey=0x47;				 return;				 }      				 if(!band_key)				 {				 delaytime(400);				 while(!band_key);				 remkey=0x78;				 return;				 }      				 				 }       					 if(!power_key)				 {				 delaytime(400);				 while(!power_key);				 power_l=~power_l;				 if(power_l)				 remkey=0x99;				 else				 remkey=0x98;				 return;				 }      				 if(!eq)				 {				 delaytime(400);				 while(!eq);				 remkey=0x97;				 return;				 }      				 if(!mute_key)				 {				 delaytime(400);				 while(!mute_key);				 if(!mute_l)				 {				 mute_l=~mute_l;				 mute_(1);				 }				 else				 {				 mute_l=~mute_l;				 mute_(0);				 remkey=0x00;				 }				 return;				 }   				 if(tuni&&tund)				 key_sta=0; 				 if(band!=2&&band!=3)				 {				 if(!key_sta)				 {				 if(!tuni) 				 {				 delaytime(400);				 key_sta=key();				 if(key_sta)				 remkey=0x34; 				 else				 remkey=0x77; 				 }				 if(!tund) 				 {				 delaytime(400);				 key_sta=key();				 if(key_sta)				 remkey=0x33; 				 else				 remkey=0x55; 				 }				 }				 }				 if(voli&&vold) 				 {				 for(a=0;a				 {				 if(!(voli&&vold))				 {				 start=0;				 return;				 }				 }				 start=1;				 return;				 }				 if(start)				 {				 start=0;				 delaytime(100);				 if(voli==0)				 {				 remkey=0x65;				 return;				 }				 				 delaytime(100);				 if				 (vold==0)				 {				 				 remkey=0x64;				 return;				 }				 } 				 				 }				 void sys_ini()				 {  				 delaytime(50000);				 inidelay();         				 band=3;		    				 inivfd();		    				 vfd_clean();        				 fun_power=0; 				 fun_vfd=0;     				 mute=0;				 mute_(0);				 volume=39;				 channel(0);				 band_change();				 sub_vol(1);				 wr_pt2313(0x80);				 wr_pt2313(0xa0);				 wr_pt2313(0xc0);				 wr_pt2313(0xe0);				 }				 void pub()				 {				 if(in0.in0.frq==0x0230)				 in0.in0.frq=0x0a30;				 if(in0.in0.frq==0x0398)				 in0.in0.frq=0x0d98;				 if(in0.in0.frq==0x85e0)				 in0.in0.frq=0x45e0;				 if(in0.in0.frq==0xe290)				 in0.in0.frq=0x6290;				 }				 bit key()				 {				  unsigned int b;				  unsigned char a;				 for(a=0;a				 for(b=0;b				 {				 if((tuni)&&(tund))				 return(0);				 }				 return(1);				 }				 void mute_(bit fun)				 {				 if(fun==1)				 {				 wr_pt2313(0xdf);				 wr_pt2313(0xff);				 }				 else if(fun==0)				 {				 wr_pt2313(0x80);				 wr_pt2313(0xa0);				 wr_pt2313(0xc0);				 wr_pt2313(0xe0);				 wr_pt2313((0x3f&(63-volume)));				 }				 } 				 void radio_change()				 {				 if((band==1)||(band==0))				 {				 if(band==0)				 band=1;				 else if(band==1)				 band=0;				 fun_power=0; 				 fun_vfd=0;     				 channel(0);				 vfd_clean();        				 if(band==0)				 ab=ab_fm;				 else				 ab=ab_am;				 iniband();							  				 if(band==0)				 rdnbyt(0xa0,ab*2,2,a);			  				 else				 rdnbyt(0xa0,ab*2+120,2,a);				 in0.in0.frq=a[0];					 				 in0.in0.frq=(in0.in0.frq				 iniband1(band);					   				 e=stepserch(1,in0.in0.frq);		   				 display();							   				 remkey=0x00;				 remkey=0;				 }				 remkey=0;				 }  				 				 																																																								 							

相关资源