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

📄 main.i

📁 遥控代码,一种多用途的,用C51实现可以安装四十多种功能码
💻 I
📖 第 1 页 / 共 2 页
字号:
 { RCAP2L=0xff-0x78; RCAP2H=0xff-0x03; CACON_VALUE=0x03;  PCON=PCON|0X01;  } void sent_uint_rc6_hi(void) { RCAP2L=0xff-0xbc; RCAP2H=0xff-0x01;	 CACON_VALUE=0x07;  PCON=PCON|0X01;   } void sent_uint_rc6_low(void) { RCAP2L=0xff-0xbc; RCAP2H=0xff-0x01; CACON_VALUE=0x03;  PCON=PCON|0X01;  }      void sent_unit_rc5_hi_low(void)  {  sent_uint_rc5_hi();  sent_uint_rc5_low(); }  void sent_unit_rc5_low_hi(void) { sent_uint_rc5_low();  sent_uint_rc5_hi();  } void sent_unit_rc6_hi_low(void)  {  sent_uint_rc6_hi();  sent_uint_rc6_low(); }  void sent_unit_rc6_low_hi(void) { sent_uint_rc6_low();  sent_uint_rc6_hi();  }     void sent_n_bit_0_hl_1_lh(char n,char temp)  { unsigned char 			 idata 			reverse; unsigned char 			 idata 			m;	 if(n==8) { reverse=2; } else  { reverse=10; } for(m=0;m<n;m++) {  if(m==reverse)		 { if(toggle==0) { sent_unit_rc5_hi_low(); } else { sent_unit_rc5_low_hi(); }  } else { if((temp&0X80)==0)  { sent_unit_rc5_hi_low(); } else { sent_unit_rc5_low_hi(); } }  temp<<=1;  } }     void sent_n_bit_0_lh_1_hl(char n,char temp)  {  unsigned char 			 idata 			m;		 for(m=0;m<n;m++) {   if((temp&0X80)==0)  { sent_unit_rc6_low_hi(); } else { sent_unit_rc6_hi_low(); }    temp<<=1;   } }    void sent_rc6_head(void) { RCAP2L=0xff-0x68; RCAP2H=0xff-0x0a;	 CACON_VALUE=0x07;  PCON=PCON|0X01;   RCAP2L=0xff-0x78; RCAP2H=0xff-0x03; CACON_VALUE=0x03;  PCON=PCON|0X01;  }  void sent_DVB_uint(char n,char m) { RCAP2L=0xff-0xbe; RCAP2H=0xff-0x00;	 CACON_VALUE=0x07;  PCON=PCON|0X01;   RCAP2L=0xff-m; RCAP2H=0xff-n; CACON_VALUE=0x03;  PCON=PCON|0X01;  }        void sent_tail(char n,char m)  {  RCAP2L=0; RCAP2H=0;		 CACON_VALUE=0x03;  PCON=PCON|0X01;  RCAP2L=0xff-m; RCAP2H=0xff-n; CACON_VALUE=0x03;  PCON=PCON|0X01; }    void sent_rc5(void)  { CADATAL           =110; CADATAH           =222;   sent_n_bit_0_hl_1_lh(8,temp_system_value);    temp_key_value<<=2; sent_n_bit_0_hl_1_lh(6,temp_key_value);   sent_tail(0x52,0xe8);   }   void sent_rc6(void)  { unsigned char fix;  fix=0x08;	  CADATAL           =110; CADATAH           =222;  sent_rc6_head(); fix<<=4; sent_n_bit_0_lh_1_hl(4,fix);   if(toggle==0)  { sent_unit_rc5_low_hi();  } else { sent_unit_rc5_hi_low(); }  sent_n_bit_0_lh_1_hl(8,temp_system_value); sent_n_bit_0_lh_1_hl(8,temp_key_value);  sent_tail(0x3a,0xec);        }  void sent_dream_DVB(void)  { unsigned char 			 idata 	 hbit; unsigned char 			 idata 	 lbit;	  unsigned char 			 idata 	 temp;	  unsigned int 			 idata 	 time; unsigned int 			 idata 	 temp_key_value1; CADATAL           =103; CADATAH           =209;	 temp_key_value1=766+136*dvb[KEY1_OFFSET];  lbit=(unsigned char)temp_key_value1	; hbit=(unsigned char)(temp_key_value1>>8)	;  sent_DVB_uint(0x03,0x86);  sent_DVB_uint(0x09,0x5e);  sent_DVB_uint(0x03,0x86);  sent_DVB_uint(0x0a,0xf6);  sent_DVB_uint(0x05,0x1e);  sent_DVB_uint(0x05,0x1e);  sent_DVB_uint(0x04,0x0e);  sent_DVB_uint(0x07,0xc6);   sent_DVB_uint(0x32,0xf0);   sent_DVB_uint(0x03,0x86);  if(press==0) { sent_DVB_uint(hbit,lbit);		  sent_DVB_uint(0x02,0xfe);  } else { temp=8+dvb[KEY1_OFFSET]; if(temp>=16) { temp=temp-16;			 } time=766+136*temp; lbit=(unsigned char)time	; hbit=(unsigned char)(time>>8)	; sent_DVB_uint(hbit,lbit);		  sent_DVB_uint(0x07,0x3e);  } sent_DVB_uint(0x03,0x86);     temp=(temp_key_value&0x0f);  time=766+136*temp; lbit=(unsigned char)time	; hbit=(unsigned char)(time>>8)	; sent_DVB_uint(hbit,lbit);     temp=(temp_key_value&0xf0);  temp=(temp>>4);  time=766+136*temp; lbit=(unsigned char)time	; hbit=(unsigned char)(time>>8)	; sent_DVB_uint(hbit,lbit);   sent_DVB_uint(0x02,0xfe);  sent_DVB_uint(0x02,0xfe);     sent_DVB_uint(0x00,0x00);  sent_tail(0x36,0x14);	  }   void SEND_CODE(void)  {    if( ( (KEY1_OFFSET>=16) && (KEY1_OFFSET<=18) )&&((memory_channel[set]==13)||(memory_channel[set]==23)||(memory_channel[set]==25)) )  { flash_current_led=0X7F;  temp_set=0;			 } else { flash_current_led=last_led_value;  temp_set=set;	  }	  temp_key_value=channel[memory_channel[temp_set]][KEY1_OFFSET];  type=channel[memory_channel[temp_set]][37];					    temp_system_value=channel[memory_channel[temp_set]][38];	       if ( temp_key_value!=0xff )  { sent_flash++; if(sent_flash<=2) {		 turn_on_portb_led(flash_current_led);  } else {			 turn_off_portb_led();							 }  if(sent_flash>=4) { sent_flash=0; }																			 } else   { turn_off_portb_led(); delay_65ms(); delay_65ms(); return; }  sent_detail_code();  }  void sent_detail_code(void) {       switch(type) { case 0:  sent_rc5(); break;  case 1:  sent_rc6(); break;  case 2:  sent_dream_DVB(); break;  default: break;  }  }   void BIT_SCANKEY(void)  {  unsigned char  idata CYC_PB; unsigned char  idata CYC_PA; unsigned char  idata i;  unsigned char  idata j;    unsigned char  idata current_key_value;  unsigned char  idata pa_value;   last_pc=PORTC;    PAPUR = 0X00;					  PACONH = 0XAA; PACONL = 0XAA;					  PORTA = 0XFF;					   PACONH = 0X00;					  PACONL = 0X00;					  PAPUR = 0XFF;    PORTC=PORTC&0XFB;    LAST_KEY_VALUE=0; KEY1_OFFSET=255; KEY2_OFFSET=255;    KEY_COUNT=0;     current_key_value=0;   PORTB=0XFE; CYC_PB  =1;  for ( i = 0 ; i < 8 ; i++) {   DELAY_A();		     pa_value=PORTA; CYC_PA=1;  if ( pa_value != 0XFF )  {  for(j=0;j<8;j++) { if ( ( CYC_PA & pa_value ) == 0 ) {  KEY_COUNT++; current_key_value=i*8+j; if( KEY_COUNT==1 ) {   KEY1_OFFSET=current_key_value; LAST_KEY_VALUE=KEY1_OFFSET; } if( KEY_COUNT==2 ) {  KEY2_OFFSET=current_key_value;  } } CYC_PA<<=1;				  }			  }  CYC_PB<<=1; PORTB=~CYC_PB;    }    PORTB=last_pb;  PORTC=last_pc;     }    void DELAY_100MS(void)    { for (m = 0; m < 3000; m ++) { ; } }   void DELAY_12MS(void)    { for (m = 0; m < 1000; m ++) { ; } }  void DELAY_A (void)  {   for (m = 0; m < 30; m ++) { ; }  }  void delay_65ms(void)  {  TL2=0; TH2=0; TR2=1; ET2=1;								 CACON_VALUE=0x03;  PCON=PCON|0X01; TR2=0; ET2=0;  }   void pa_int_enable(void) {    PAPND = 0X00;  PAINT = 0XFF;  EX0=1;         }															   void pa_int_disenble(void) {															  PAPND = 0X00; PAINT = 0X00;															 EX0=0; }      void all_mode_led_light_3_second(void) {  unsigned char idata i;  PORTC=(PORTC|0x04);  PORTB = 0x0f; for(i=0;i<50;i++) { delay_65ms(); } PORTB = 0xff;   }  void turn_off_portb_led_2_second(void)  {  unsigned char idata i;  PORTC=(PORTC|0x04);  PORTB = 0xff; for(i=0;i<30;i++) { delay_65ms(); }    }    void turn_on_portb_led(char value)  { PORTC=(PORTC|0x04);  last_pb=value; PORTB = value;  } void turn_off_portb_led(void)  { PORTC=(PORTC|0x04);  last_pb=0xff; PORTB = 0xff;  }   void wait_for_key_release(void) { while(LAST_KEY_VALUE==KEY1_OFFSET)  { BIT_SCANKEY();	 delay_65ms();			 } }          void  main(void) {   #line 934 "FLASH\main.c" /1  #line 936 "FLASH\main.c" /0 SP	= 0xDF;    CHIP_MODE=0; #line 942 "FLASH\main.c" /1  #line 944 "FLASH\main.c" /0  #line 946 "FLASH\main.c" /1   #line 949 "FLASH\main.c" /0   DIVL	=	0x68; DIVH	=	0xA9;   DELAY_100MS();			  INIT_BEFORE_SCAN();     while(1) {			   loop:	turn_off_portb_led();  KEY_DETECTED=0;  PORTC=PORTC&0xFB;  PORTC=PORTC|0x01;  PORTB = 0X00;       TR2=0; ET2=0;  pa_int_enable();   if(CHIP_MODE==1)  {   while(KEY_DETECTED==0) {};   } else { PCON=02;  }   pa_int_disenble(); PORTC=PORTC|0X05;          BIT_SCANKEY();    if(KEY1_OFFSET==0)  {  turn_on_portb_led(last_led_value); wait_for_key_release(); for ( i = 0 ; i < 300 ; i++ )  {  DELAY_12MS();				   BIT_SCANKEY();    if(KEY1_OFFSET == 0)  {  i=0;  set++; if(set>=4) { set=0;			 }  first_set:	if(set==0) { if(memory_channel[0]==0) { set++; } else { last_led_value=0x7f; }	 }  if(set==1) { if(memory_channel[1]==0) { set++; } else { last_led_value=0xbf; }	 }  if(set==2) { if(memory_channel[2]==0) { set++; } else { last_led_value=0xdf; }	 }  if(set==3) { if(memory_channel[3]==0) { set++; if(set>=4) { set=0;	 goto first_set;  } } else { last_led_value=0xef; }	 }   turn_on_portb_led(last_led_value);  SRAM_TO_FLASH(10,set); SRAM_TO_FLASH(11,0x90);	  } else if((KEY1_OFFSET != 0)&&(KEY1_OFFSET != 255))  {										 goto sent; } wait_for_key_release();					 } goto loop; } else if(KEY1_OFFSET!=255) { sent:	press=0; toggle=~toggle; TH2=0xFAEC; TL2=0xFAEC; TR2=1; ET2=1;    sent_flash=0; press_time=0; end_flag=0; while(LAST_KEY_VALUE==KEY1_OFFSET) { if(KEY2_OFFSET!=255)  { turn_off_portb_led();  if(((KEY1_OFFSET==1)&&(KEY2_OFFSET==18))||((KEY1_OFFSET==18)&&(KEY2_OFFSET==1))) { for ( i = 0 ; i < 40 ; i++ )  {  delay_65ms();  BIT_SCANKEY(); if(((KEY1_OFFSET==1)&&(KEY2_OFFSET==18))||((KEY1_OFFSET==18)&&(KEY2_OFFSET==1))) {					 continue; } else { goto sent; }   } all_mode_led_light_3_second(); turn_off_portb_led();  wait_for_key_release();				 j=0; for ( i = 0,k=0 ; i < 150 ; i++,k++ )  {   delay_65ms();												 BIT_SCANKEY(); if(k<=4) {		 turn_on_portb_led(last_led_value);  } else {			 turn_off_portb_led();							 }  if(k>=8) { k=0; }			 if(j==3)  { valid_code=0; locate_channel=temp_number[0]*100+temp_number[1]*10+temp_number[2];	  if((set==0)&&((locate_channel>=101)&&(locate_channel<=111))) { valid_code=1; memory_channel[set]=locate_channel-101;  } else if((set==1)&&((locate_channel>=201)&&(locate_channel<=210))) { valid_code=1; memory_channel[set]=locate_channel-190;  }	 else if((set==2)&&((locate_channel>=301)&&(locate_channel<=302))) { valid_code=1; memory_channel[set]=locate_channel-280;  }	 else if((set==3)&&(locate_channel==401)) { valid_code=1; memory_channel[set]=locate_channel-378;  } else if(locate_channel==0)  { valid_code=1; memory_channel[set]=locate_channel;  } if(valid_code==1)  {  temp_data_flash=(unsigned char)memory_channel[set];						 SRAM_TO_FLASH(2*set,temp_data_flash);  temp_data_flash=(unsigned char)(memory_channel[set]>>8);						 SRAM_TO_FLASH(2*set+1,temp_data_flash);  SRAM_TO_FLASH(8,0x90);  turn_on_portb_led(last_led_value);    if((memory_channel[0]==0)&&(memory_channel[1]==0)&&(memory_channel[2]==0)&&(memory_channel[3]==0)) { memory_channel[0]=7; temp_data_flash=(unsigned char)memory_channel[0];						 SRAM_TO_FLASH(0,temp_data_flash);  temp_data_flash=(unsigned char)(memory_channel[0]>>8);						 SRAM_TO_FLASH(1,temp_data_flash); } for(i=0;i<150;i++) {  delay_65ms();												 BIT_SCANKEY(); if(KEY1_OFFSET==0)  {  goto repeat;  }																					 } goto loop;   }	 else  { turn_off_portb_led_2_second(); i=0; j=0; k=0;												 }     }   if(( KEY1_OFFSET>=2 ) && ( KEY1_OFFSET<=10 ) )  {  i=0;												 temp_number[j++]=KEY1_OFFSET-1;   }  else if(KEY1_OFFSET==12)    { i=0;											 temp_number[j++]=0; }	  else if(KEY1_OFFSET==0)  { repeat:					j=0;  i=0;  set++; if(set>=4) { set=0;			 }  get_last_led_value(); turn_on_portb_led(last_led_value);   } else if(KEY1_OFFSET!=255)  { i=0;  } wait_for_key_release();  } goto loop;  } while(KEY2_OFFSET!=255) { TR2=0; ET2=0;				 BIT_SCANKEY(); delay_65ms(); TR2=1; ET2=1;  }  } press_time++;					  SEND_CODE(); TR2=0; ET2=0;																 BIT_SCANKEY(); TR2=1; ET2=1;					  if(LAST_KEY_VALUE==KEY1_OFFSET)  { press=1;	 } if(press_time==300)  {   return; }		 } }   } }

⌨️ 快捷键说明

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