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

📄 mainloop.lst

📁 这是一个89c52的USB固件系统的源码 使用keilc 生成hex文件 可直接烧录
💻 LST
📖 第 1 页 / 共 5 页
字号:
 556   3                delay1();
 557   3                    WR8253 = 1;
 558   3                delay1();
 559   3      
 560   3                P2 = cur_jing/256;
 561   3                A8253 = 0;
 562   3                WR8253 = 1;
 563   3                delay1();
 564   3                    WR8253 = 0;
 565   3                delay1();
 566   3                    WR8253 = 1;
 567   3                delay1();
 568   3      
 569   3                    GATE = 1;
 570   3                delay1();
 571   3                CS8253 = 1;
 572   3                    RAMCS = 0;
 573   3                ENABLE;
 574   3                      }
 575   2                      else if (read_jing_flag == 1){            
 576   3                        cur_jing = GenEpBuf[3]*256;
 577   3                        read_jing_flag ++;
 578   3                      }
 579   2                      else if (read_prog_flag > 0){
 580   3                        if (read_prog_flag != 12+2*4*6)
 581   3                          mask_cc ^= GenEpBuf[3];
 582   3                        if (read_prog_flag == 1){
 583   4                          if (XBYTE[xytype(e_order)] == 0)
 584   4                            w_p = e_order;
 585   4                  else
 586   4                            w_p = (e_order+1)%MAX_ORDER;
 587   4                              if (XBYTE[xytype(w_p)] != 0){
 588   5                                w_p = -1;
 589   5                              }
 590   4                              if (w_p != -1)
 591   4                          XBYTE[xytype(w_p)] = GenEpBuf[3];
 592   4                          read_prog_flag ++;
 593   4                        }
 594   3                        else if (read_prog_flag == 2){
 595   4                              if (w_p != -1)
 596   4                          XBYTE[uvtype(w_p)] = GenEpBuf[3];
 597   4                          read_prog_flag ++;
 598   4                        }
 599   3                        else if (read_prog_flag == 3){
 600   4                              if (w_p != -1)
 601   4                          XBYTE[xy(w_p)] = GenEpBuf[3];
 602   4                          read_prog_flag ++;
 603   4                        }
 604   3                        else if ((read_prog_flag > 3)&&(read_prog_flag <=7)){
 605   4                              if (w_p != -1)
 606   4                          XBYTE[counterlen(w_p)+read_prog_flag-4] = GenEpBuf[3];
 607   4                          read_prog_flag ++;
 608   4                        }
 609   3                        else if ((read_prog_flag > 7)&&(read_prog_flag <=11)){
 610   4                              if (w_p != -1)
 611   4                          XBYTE[ncorder(w_p)+read_prog_flag-8] = GenEpBuf[3];
C51 COMPILER V7.09   MAINLOOP                                                              10/14/2004 20:25:36 PAGE 11  

 612   4                          read_prog_flag ++;
 613   4                        }
 614   3                        else if ((read_prog_flag > 11)&&(read_prog_flag <=11+4*6)){
 615   4                          cc = (read_prog_flag-12)/4;
 616   4                              if (w_p != -1)
 617   4                          XBYTE[lpdata(w_p,cc)+read_prog_flag-12-cc*4] = GenEpBuf[3];
 618   4                          read_prog_flag ++;
 619   4                        }
 620   3                        else if ((read_prog_flag > 11+4*6)&&(read_prog_flag <=11+2*4*6)){
 621   4                          cc = (read_prog_flag-12-4*6)/4;
 622   4                              if (w_p != -1)
 623   4                          XBYTE[lpdata1(w_p,cc)+read_prog_flag-12-4*6-cc*4] = GenEpBuf[3];
 624   4                          read_prog_flag ++;
 625   4                        }
 626   3                        else if (read_prog_flag == 12+2*4*6){
 627   4                          if (mask_cc == GenEpBuf[3]){
 628   5                                if (w_p != -1)
 629   5                      e_order = w_p;
 630   5                              }
 631   4                  read_prog_flag = 0;
 632   4                        }
 633   3                else
 634   3                  read_prog_flag = 0;
 635   3                      }
 636   2                      else if (GenEpBuf[3] == 1){//自动开高频继续加工但判断是否是启动态
 637   3                        if (io_wrong_flag == 0){
 638   4                          if (work_status != 2){
 639   5                            if ((XBYTE[xytype(cur_order)] == 0)&&(cur_order == 0)){
 640   6                              work_status = 2;
 641   6                    }
 642   5                    else{
 643   6                              work_status = 1;
 644   6                      open_gao_pin();
 645   6                    }
 646   5                              }
 647   4                        }
 648   3                      }
 649   2                      else if (GenEpBuf[3] == 2){
 650   3                        if (work_status != 2){
 651   4                          work_status = 0;
 652   4                }
 653   3                close_gao_pin();
 654   3                      }
 655   2                      else if (GenEpBuf[3] == 3){
 656   3                    gaopzt = GAOPIN_KAI;
 657   3                open_gao_pin();
 658   3                      }
 659   2                      else if (GenEpBuf[3] == 4){
 660   3                    gaopzt = GAOPIN_GUAN;
 661   3                close_gao_pin();
 662   3                      }
 663   2                      else if (GenEpBuf[3] == 5){
 664   3                    dianjzt = MOT_RUN;
 665   3                open_mot();
 666   3                      }
 667   2                      else if (GenEpBuf[3] == 6){
 668   3                    dianjzt = MOT_CLOSE;
 669   3                close_mot();
 670   3                      }
 671   2                      else if (GenEpBuf[3] == 7){
 672   3                        read_jing_flag = 1;
 673   3                      }
C51 COMPILER V7.09   MAINLOOP                                                              10/14/2004 20:25:36 PAGE 12  

 674   2                      else if (GenEpBuf[3] == 8){
 675   3                      }
 676   2                      else if (GenEpBuf[3] == 9){
 677   3                read_jing_flag = 0;
 678   3                    diand_flag = 0;
 679   3                    diand_axis = 0;
 680   3                    diandbz = 0;
 681   3                read_prog_flag = 0;
 682   3                read_max_loop_flag = 0;
 683   3                send_req_flag = 0;
 684   3                        read_nc_num_flag = 0;
 685   3                    io_wrong_flag = 0;
 686   3                    cur_order1 = 0;
 687   3                e_order = cur_order = 0;                
 688   3                        work_status = 0;
 689   3                        cur_off = 0;
 690   3                        XBYTE[xytype(0)] = 0;
 691   3                        XBYTE[xytype(1)] = 0;
 692   3                        XBYTE[xytype(2)] = 0;
 693   3                        XBYTE[xytype(3)] = 0;
 694   3                        XBYTE[xytype(4)] = 0;
 695   3                        if (dianjzt == MOT_RUN){
 696   4                          XBYTE[xytype(0)] = 1;
 697   4                  (long)(*((long *)(&(XBYTE[lpdata(cur_order,2)])))) = cur_x;
 698   4                  (long)(*((long *)(&(XBYTE[lpdata(cur_order,3)])))) = cur_y;
 699   4                  (long)(*((long *)(&(XBYTE[lpdata(cur_order,4)])))) = 0;
 700   4                  (long)(*((long *)(&(XBYTE[lpdata(cur_order,5)])))) = 0;
 701   4                              work_status = 1;
 702   4                        }
 703   3                        else{
 704   4                  cur_x = cur_y = cur_u = cur_v  = cur_seg = cur_off = 0;
 705   4                          cur_x_step_order = cur_y_step_order = cur_u_step_order = cur_v_step_order = 0;
 706   4                        }
 707   3                        stop_flag = 0;
 708   3                        stop_byte = 0;
 709   3                      }
 710   2                      else if (GenEpBuf[3] == 10){
 711   3                        io_wrong_flag = 0;
 712   3                        read_prog_flag = 1;
 713   3                        mask_cc = 0;
 714   3                      }
 715   2                      else if (GenEpBuf[3] == 11){
 716   3                        read_max_loop_flag = 1;
 717   3                      }
 718   2                      else if (GenEpBuf[3] == 12){
 719   3                        if (gaopzt == GAOPIN_KAI){
 720   4                          if (dianjzt == MOT_RUN)
 721   4                    cc = 0x86;
 722   4                              else
 723   4                    cc = 0x87;
 724   4                        }
 725   3                        else{
 726   4                          if (dianjzt == MOT_RUN)
 727   4                    cc = 0x88;
 728   4                              else
 729   4                    cc = 0x89;
 730   4                        }
 731   3                RAMCS = 1;
 732   3                MCU_D12CS = 0;
 733   3                D12_WriteEndpoint(3, 1, &cc);  
 734   3                      }
 735   2                      else if (GenEpBuf[3] == 13){
C51 COMPILER V7.09   MAINLOOP                                                              10/14/2004 20:25:36 PAGE 13  

 736   3                        read_nc_num_flag = 1;
 737   3              }
 738   2                      else if (GenEpBuf[3] == 14){
 739   3                read_jing_flag = 0;
 740   3                read_prog_flag = 0;
 741   3                read_max_loop_flag = 0;
 742   3                send_req_flag = 0;
 743   3                        read_nc_num_flag = 0;
 744   3                    io_wrong_flag = 0;
 745   3                    cur_order1 = 0;
 746   3                e_order = cur_order = 0;                
 747   3                        work_status = 0;
 748   3                        cur_off = 0;
 749   3                        XBYTE[xytype(0)] = 0;
 750   3                        XBYTE[xytype(1)] = 0;
 751   3                        XBYTE[xytype(2)] = 0;
 752   3                        XBYTE[xytype(3)] = 0;
 753   3                        XBYTE[xytype(4)] = 0;
 754   3                      }
 755   2                      else if (GenEpBuf[3] == 20){
 756   3                RAMCS = 1;
 757   3                        MCU_D12CS = 0;
 758   3                    MCU_D12CS = 0x1;
 759   3                    CKCON = 0x00;
 760   3                    D12_DATA = 0xff02;                        //定义数据地址
 761   3                    D12_COMMAND = 0xff03;             //定义命令地址
 762   3                    MCU_D12CS = 0x0;
 763   3      //            D12SUSPD = 0x0;
 764   3                    IT0 = 0;//初始化中断
 765   3                    EX0 = 1;
 766   3                    PX0 = 0;
 767   3                    EA = 1;
 768   3                    MCU_D12CS = 0x1;
 769   3                    MCU_D12CS = 0x0;
 770   3                    bEPPflags.value = 0;
 771   3                    reconnect_USB();//联接USB总线
 772   3                      }
 773   2                      else if (GenEpBuf[3] == 30){
 774   3                    diand_flag = 1;
 775   3                    diand_axis = 1;             
 776   3                      }
 777   2                      else if (GenEpBuf[3] == 31){
 778   3                    diand_flag = 1;
 779   3                    diand_axis = 2;             
 780   3                      }
 781   2                      else if (GenEpBuf[3] == 32){
 782   3                    diand_flag = 1;
 783   3                    diand_axis = 3;             
 784   3                      }
 785   2                      else if (GenEpBuf[3] == 33){
 786   3                    diand_flag = 1;
 787   3                    diand_axis = 4;             
 788   3                      }
 789   2                      else if (GenEpBuf[3] == 40){//回退
 790   3                    anti_work_flag = 1;
 791   3                    old_cur_jing = cur_jing;
 792   3                        cur_jing = 200;
 793   3                        if (cur_off == 0){
 794   4                          cur_order --;
 795   4                              if (cur_order == -1){
 796   5                        cur_order1 = 0;
 797   5                                cur_order = 0;
C51 COMPILER V7.09   MAINLOOP                                                              10/14/2004 20:25:36 PAGE 14  

 798   5                    cc = 0x8e;
 799   5                    RAMCS = 1;
 800   5                    MCU_D12CS = 0;
 801   5                    D12_WriteEndpoint(3, 1, &cc);
 802   5                              }
 803   4                              else{
 804   5                                cur_off = (long)(*((long *)(&(XBYTE[counterlen(cur_order)]))));
 805   5                            work_status = 1;
 806   5                              }
 807   4                        }
 808   3                        else
 809   3                          work_status = 1;
 810   3                      }
 811   2                      else if (GenEpBuf[3] == 60){//五相十拍
 812   3                        xiangxlx = 0;
 813   3                      }
 814   2                      else if (GenEpBuf[3] == 61){//三相六拍
 815   3                        xiangxlx = 1;
 816   3                      }
 817   2                      else if (GenEpBuf[3] == 62){//方向电平
 818   3                        xiangxlx = 2;
 819   3                      }
 820   2                      else if (GenEpBuf[3] == 70){//不自动开高频继续加工
 821   3                        work_status = 1;
 822   3                      }
 823   2                      else if (GenEpBuf[3] == 80){//自动开高频继续加工
 824   3                        if (io_wrong_flag == 0){
 825   4                          work_status = 1;
 826   4                  open_gao_pin();
 827   4                        }
 828   3                      }
 829   2              }
 830   1      }
 831          
 832          void send_a_step(void)
 833          {
 834   1        char bz;
 835   1      
 836   1        MCU_D12CS = 1;
 837   1        RAMCS = 0;
 838   1        bx = (long)(*((long *)(&(XBYTE[lpdata(cur_order,2)]))));
 839   1        by = (long)(*((long *)(&(XBYTE[lpdata(cur_order,3)]))));

⌨️ 快捷键说明

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