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

📄 main.lst

📁 遥控代码,一种多用途的,用C51实现可以安装四十多种功能码
💻 LST
📖 第 1 页 / 共 5 页
字号:
 334   4                              }
 335   3                              else
 336   3                              {
 337   4                                      sent_unit_rc5_low_hi();
 338   4                              }
 339   3                              
 340   3                      }
 341   2                      else
 342   2                      {
 343   3                              if((temp&0X80)==0)//judge 0 or 1
 344   3                              {
 345   4                                      sent_unit_rc5_hi_low();
 346   4                              }
 347   3                              else
 348   3                              {
 349   4                                      sent_unit_rc5_low_hi();
 350   4                              }
 351   3                      }
 352   2                      
 353   2                      temp<<=1;
 354   2                              
 355   2              }
 356   1      }
 357          
C51 COMPILER V7.00  MAIN                                                                   08/06/2007 11:45:43 PAGE 20  

 358          
 359          
 360          
 361          void sent_n_bit_0_lh_1_hl(char n,char temp)//rc6码 0电平为低高,1电平为高低
 362          {
 363   1      
 364   1              unsigned char                    idata                  m;              
 365   1              for(m=0;m<n;m++)
 366   1              {
 367   2                      
 368   2                      
 369   2                              if((temp&0X80)==0)//judge 0 or 1
 370   2                              {
 371   3                                      sent_unit_rc6_low_hi();
 372   3                              }
 373   2                              else
 374   2                              {
 375   3                                      sent_unit_rc6_hi_low();
 376   3                              }
 377   2                      
 378   2      
 379   2                      
 380   2                              temp<<=1;
 381   2                      
 382   2                                      
 383   2              }
 384   1      }
 385          
 386          //#################################################//
 387          //###########################rc6头码###################//
 388          void sent_rc6_head(void)
 389          {
 390   1              RCAP2L=0xff-0x68;
 391   1              RCAP2H=0xff-0x0a;       
 392   1              CACON_VALUE=0x07;//00000111
 393   1              PCON=PCON|0X01;//bit 0 -> IDLE mode, assumed only waiting timer 2 interrupt
 394   1              
 395   1              RCAP2L=0xff-0x78;
 396   1              RCAP2H=0xff-0x03;
 397   1              CACON_VALUE=0x03;//00000011
 398   1              PCON=PCON|0X01;
 399   1      
 400   1      }
 401          //###########################dream_DVB固定码###################//
 402          void sent_DVB_uint(char n,char m)
 403          {
 404   1              RCAP2L=0xff-0xbe;
 405   1              RCAP2H=0xff-0x00;       
 406   1              CACON_VALUE=0x07;//00000111
 407   1              PCON=PCON|0X01;//bit 0 -> IDLE mode, assumed only waiting timer 2 interrupt
 408   1              
 409   1              RCAP2L=0xff-m;
 410   1              RCAP2H=0xff-n;
 411   1              CACON_VALUE=0x03;//00000011
 412   1              PCON=PCON|0X01;
 413   1      
 414   1      }
 415          
 416          
 417          //#################################################//
 418          //#################################################//
 419          
C51 COMPILER V7.00  MAIN                                                                   08/06/2007 11:45:43 PAGE 21  

 420          
 421          //###########################尾码###################//
 422          void sent_tail(char n,char m)//83ms      use a flag all tail with this function
 423          {
 424   1      
 425   1              RCAP2L=0;
 426   1              RCAP2H=0;               
 427   1              CACON_VALUE=0x03;//00000011
 428   1              PCON=PCON|0X01;
 429   1                              
 430   1              RCAP2L=0xff-m;
 431   1              RCAP2H=0xff-n;
 432   1              CACON_VALUE=0x03;//00000011
 433   1              PCON=PCON|0X01;
 434   1      }
 435          
 436          //####################################################//
 437          
 438          void sent_rc5(void)//13
 439          {
 440   1              CADATAL           =110;
 441   1              CADATAH           =222;
 442   1              
 443   1      
 444   1              sent_n_bit_0_hl_1_lh(8,temp_system_value);
 445   1      
 446   1              
 447   1      
 448   1              temp_key_value<<=2;
 449   1              sent_n_bit_0_hl_1_lh(6,temp_key_value);
 450   1              
 451   1              
 452   1              sent_tail(0x52,0xe8);//0x52e8=89.76-3-65.536
 453   1      
 454   1      }
 455          
 456          
 457          void sent_rc6(void)//13
 458          {
 459   1              unsigned char fix;
 460   1      
 461   1              fix=0x08;       
 462   1              
 463   1              CADATAL           =110;
 464   1              CADATAH           =222;
 465   1      
 466   1              sent_rc6_head();
 467   1              fix<<=4;
 468   1              sent_n_bit_0_lh_1_hl(4,fix);
 469   1              
 470   1              
 471   1              if(toggle==0)//toggle bit
 472   1              {
 473   2                      sent_unit_rc5_low_hi();
 474   2      
 475   2              }
 476   1              else
 477   1              {
 478   2                      sent_unit_rc5_hi_low();
 479   2              }
 480   1      
 481   1              sent_n_bit_0_lh_1_hl(8,temp_system_value);
C51 COMPILER V7.00  MAIN                                                                   08/06/2007 11:45:43 PAGE 22  

 482   1              sent_n_bit_0_lh_1_hl(8,temp_key_value);
 483   1      
 484   1              sent_tail(0x3a,0xec);//0x3aec=83-3-65.536
 485   1      
 486   1              
 487   1      
 488   1              
 489   1      
 490   1      
 491   1      }
 492          
 493          void sent_dream_DVB(void)//系统码9244F1C1
 494          {
 495   1              unsigned char                    idata   hbit;
 496   1              unsigned char                    idata   lbit;   
 497   1              unsigned char                    idata   temp;   
 498   1              unsigned int                     idata   time;
 499   1              unsigned int                     idata   temp_key_value1;
 500   1              CADATAL           =103;
 501   1              CADATAH           =209; 
 502   1              temp_key_value1=766+136*dvb[KEY1_OFFSET];//键码 
 503   1              lbit=(unsigned char)temp_key_value1     ;
 504   1              hbit=(unsigned char)(temp_key_value1>>8)        ;
 505   1      
 506   1              sent_DVB_uint(0x03,0x86);//1---902us
 507   1              sent_DVB_uint(0x09,0x5e);//c---2398us
 508   1              sent_DVB_uint(0x03,0x86);//1---902us
 509   1              sent_DVB_uint(0x0a,0xf6);//f---2806us
 510   1              sent_DVB_uint(0x05,0x1e);//4---1310us
 511   1              sent_DVB_uint(0x05,0x1e);//4---902us
 512   1              sent_DVB_uint(0x04,0x0e);//2---1038us
 513   1              sent_DVB_uint(0x07,0xc6);//9---1990us
 514   1              
 515   1              sent_DVB_uint(0x32,0xf0);//间隔码,13040us
 516   1              
 517   1              sent_DVB_uint(0x03,0x86);//1---902us
 518   1              if(press==0)
 519   1              {
 520   2                      sent_DVB_uint(hbit,lbit);               //一位变量
 521   2                      sent_DVB_uint(0x02,0xfe);//0---766us
 522   2              }
 523   1              else
 524   1              {
 525   2                      temp=8+dvb[KEY1_OFFSET];
 526   2                      if(temp>=16)
 527   2                      {
 528   3                              temp=temp-16;                   
 529   3                      }
 530   2                      time=766+136*temp;
 531   2                      lbit=(unsigned char)time        ;
 532   2                      hbit=(unsigned char)(time>>8)   ;
 533   2                      sent_DVB_uint(hbit,lbit);               //一位变量
 534   2                      sent_DVB_uint(0x07,0x3e);//0---1854us
 535   2              }
 536   1              sent_DVB_uint(0x03,0x86);//1---902us
 537   1      
 538   1      //*************变量的低四位*************//
 539   1      
 540   1              temp=(temp_key_value&0x0f);//取低四位
 541   1              time=766+136*temp;
 542   1              lbit=(unsigned char)time        ;
 543   1              hbit=(unsigned char)(time>>8)   ;
C51 COMPILER V7.00  MAIN                                                                   08/06/2007 11:45:43 PAGE 23  

 544   1              sent_DVB_uint(hbit,lbit);//两位键码
 545   1      
 546   1      //*************变量的高四位*************//      
 547   1      
 548   1              temp=(temp_key_value&0xf0);//
 549   1              temp=(temp>>4);//取高四位
 550   1              time=766+136*temp;
 551   1              lbit=(unsigned char)time        ;
 552   1              hbit=(unsigned char)(time>>8)   ;
 553   1              sent_DVB_uint(hbit,lbit);//两位键码
 554   1                      
 555   1              sent_DVB_uint(0x02,0xfe);//0---766us
 556   1              sent_DVB_uint(0x02,0xfe);//0---766us
 557   1      
 558   1              
 559   1      
 560   1              sent_DVB_uint(0x00,0x00);//低电平
 561   1              sent_tail(0x36,0x14);   //高电平0x3aec=83-3-65.536
 562   1      }
 563          
 564          
 565          void SEND_CODE(void)//send code,new code and repeat code diffrent in code_length and code_list
 566          {
 567   1      
 568   1              
 569   1              
 570   1                      if( ( (KEY1_OFFSET>=16) && (KEY1_OFFSET<=18) )&&((memory_channel[set]==13)||(memory_channel[set]==23)||(
             -memory_channel[set]==25)) )//SAT的203发TV的码,遇到声音的三个键
 571   1                      {
 572   2                                      flash_current_led=0X7F;//1011 1111 light tv led
 573   2                                      temp_set=0;                     
 574   2                      }
 575   1                      else
 576   1                      {
 577   2                              flash_current_led=last_led_value;//指示灯地址赋值
 578   2                              temp_set=set;   //当前套变量赋值        
 579   2                      }       
 580   1                      
 581   1                      temp_key_value=channel[memory_channel[temp_set]][KEY1_OFFSET];//键码    
 582   1                      type=channel[memory_channel[temp_set]][37];                                       //类型代号    
 583   1                      temp_system_value=channel[memory_channel[temp_set]][38];          //系统码
 584   1                      
 585   1      
 586   1              
 587   1              if ( temp_key_value!=0xff )//有健值的闪烁1S闪烁5次
 588   1              {
 589   2                      sent_flash++;
 590   2                      if(sent_flash<=2)
 591   2                      {               
 592   3                              turn_on_portb_led(flash_current_led);//在键盘扫描处关闭了指示灯,故该处再次打开                                         
 593   3                      }
 594   2                      else
 595   2                      {                       
 596   3                              turn_off_portb_led();                                                   
 597   3                      }
 598   2                      
 599   2                      if(sent_flash>=4)
 600   2                      {
 601   3                              sent_flash=0;
 602   3                      }                                                                                                                                                       
 603   2              }
 604   1              else //无码键
C51 COMPILER V7.00  MAIN                                                                   08/06/2007 11:45:43 PAGE 24  

 605   1              {
 606   2                      turn_off_portb_led();
 607   2                      delay_65ms();
 608   2                      delay_65ms();
 609   2                      return;
 610   2              }
 611   1      
 612   1              sent_detail_code();
 613   1                                                                                                                                                              
 614   1      }
 615          
 616          void sent_detail_code(void)
 617          {
 618   1      
 619   1              
 620   1      //      rotate_flag=0;//

⌨️ 快捷键说明

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