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

📄 sl811.lst

📁 本程序是基于单片机C8051F020上使用SL811 USB 总线接口实现检测U 盘的功能。插上U 盘
💻 LST
📖 第 1 页 / 共 5 页
字号:
 762                  return FALSE;
 763          }
 764          */
 765          //*****************************************************************************************
 766          // Indicate to EZUSB's endpoint #2 IN of a new device attach/detach
 767          //*****************************************************************************************
 768          /*
 769          void Set_ezDEV(BYTE chg)
 770          {
 771                  //if( (dsPoll) && (!(IN2CS & bmEPBUSY)) )
 772                  //{
 773                  //      IN2BUF[0] = chg;        // Arm endpoint #2, inform EZUSB host of attach/detatch
 774                  //      IN2BC = 1;
 775                  //}
 776          }
 777          */
 778          ///////////////////////////////////////////////////////////////////////////////////////////
 779          int hw_sof(void)
 780          {
 781   1              SL811Write(cDATASet,0xe0);
 782   1              SL811Write(cSOFcnt,0xae);
 783   1              SL811Write(CtrlReg,05);
 784   1              SL811Write(EP0Control,0x01);
 785   1      }
 786          unsigned char mem_test(void)
 787          {
 788   1              unsigned char data temp,i;
 789   1      
 790   1              for (i=0;i<255;i++)
 791   1              {       
 792   2                      SL811Write(i,i);
 793   2                      temp=SL811Read(i);
 794   2              }
 795   1      
 796   1              for (i=0;i<255;i++)
 797   1              {       
C51 COMPILER V7.06   SL811                                                                 04/30/2005 15:12:27 PAGE 14  

 798   2                      temp=SL811Read(i);
 799   2                      if (temp!=i)
 800   2                              return 0;
 801   2              }
 802   1              return 1;
 803   1      } 
 804          
 805          void sl811_init(void)
 806          {       
 807   1              SL811Write(cDATASet,0xe0);
 808   1              SL811Write(cSOFcnt,0xae);
 809   1              SL811Write(CtrlReg,0x5);
 810   1                              
 811   1              SL811Write(EP0Status,0x50);
 812   1              SL811Write(EP0Counter,0);
 813   1              SL811Write(EP0Control,0x01);
 814   1                              
 815   1              SL811Write(IntEna,0x20);                // USB-A, Insert/Remove, USB_Resume.
 816   1              SL811Write(IntStatus,INT_CLEAR);        // Clear Interrupt enable status
 817   1              
 818   1              //EnumUsbDev(1);
 819   1      }
 820          
 821          
 822          void sl811_disp(void)
 823          {
 824   1              unsigned char data temp;
 825   1      
 826   1      //      for (temp=0;temp<16;temp++)
 827   1      //              SL811Write(temp,0x55);
 828   1       
 829   1              Uart0_SendString("***********************\r\n");
 830   1              Uart0_SendString("SL811 reg list:\r\n");
 831   1      
 832   1              temp=SL811Read(IntStatus);
 833   1              Uart0_SendString("IntStatus[0d] = ");
 834   1              Uart0_SendByte(ASSII[temp/16]);
 835   1              Uart0_SendByte(ASSII[temp%16]);
 836   1              Uart0_SendString("\r\n");
 837   1      
 838   1              temp=SL811Read(EP0Control);
 839   1              Uart0_SendString("EP0Control[00] = ");
 840   1              Uart0_SendByte(ASSII[temp/16]);
 841   1              Uart0_SendByte(ASSII[temp%16]);
 842   1              Uart0_SendString("\r\n");
 843   1      
 844   1              temp=SL811Read(EP0Address);
 845   1              Uart0_SendString("EP0Address[01] = ");
 846   1              Uart0_SendByte(ASSII[temp/16]);
 847   1              Uart0_SendByte(ASSII[temp%16]);
 848   1              Uart0_SendString("\r\n");
 849   1      
 850   1      
 851   1              temp=SL811Read(EP0XferLen);
 852   1              Uart0_SendString("EP0XferLen[02] = ");
 853   1              Uart0_SendByte(ASSII[temp/16]);
 854   1              Uart0_SendByte(ASSII[temp%16]);
 855   1              Uart0_SendString("\r\n");
 856   1                      
 857   1              temp=SL811Read(EP0Status);
 858   1              Uart0_SendString("EP0Status[03] = ");
 859   1              Uart0_SendByte(ASSII[temp/16]);
C51 COMPILER V7.06   SL811                                                                 04/30/2005 15:12:27 PAGE 15  

 860   1              Uart0_SendByte(ASSII[temp%16]);
 861   1              Uart0_SendString("\r\n");
 862   1      
 863   1              temp=SL811Read(EP0Counter);
 864   1              Uart0_SendString("EP0Counter[04] = ");
 865   1              Uart0_SendByte(ASSII[temp/16]);
 866   1              Uart0_SendByte(ASSII[temp%16]);
 867   1              Uart0_SendString("\r\n");
 868   1      
 869   1      
 870   1      
 871   1              temp=SL811Read(EP1Control);
 872   1              Uart0_SendString("EP1Control[08] = ");
 873   1              Uart0_SendByte(ASSII[temp/16]);
 874   1              Uart0_SendByte(ASSII[temp%16]);
 875   1              Uart0_SendString("\r\n");
 876   1      
 877   1              temp=SL811Read(EP1Address);
 878   1              Uart0_SendString("EP1Address[09] = ");
 879   1              Uart0_SendByte(ASSII[temp/16]);
 880   1              Uart0_SendByte(ASSII[temp%16]);
 881   1              Uart0_SendString("\r\n");
 882   1      
 883   1      
 884   1              temp=SL811Read(EP1XferLen);
 885   1              Uart0_SendString("EP1XferLen[0a] = ");
 886   1              Uart0_SendByte(ASSII[temp/16]);
 887   1              Uart0_SendByte(ASSII[temp%16]);
 888   1              Uart0_SendString("\r\n");
 889   1                      
 890   1              temp=SL811Read(EP1Status);
 891   1              Uart0_SendString("EP1Status[0b] = ");
 892   1              Uart0_SendByte(ASSII[temp/16]);
 893   1              Uart0_SendByte(ASSII[temp%16]);
 894   1              Uart0_SendString("\r\n");
 895   1      
 896   1              temp=SL811Read(EP1Counter);
 897   1              Uart0_SendString("EP1Counter[0c] = ");
 898   1              Uart0_SendByte(ASSII[temp/16]);
 899   1              Uart0_SendByte(ASSII[temp%16]);
 900   1              Uart0_SendString("\r\n");
 901   1              
 902   1      
 903   1              Uart0_SendString("\r\n");
 904   1              Uart0_SendString("\r\n");
 905   1              Uart0_SendString("\r\n");
 906   1      
 907   1              temp=SL811Read(CtrlReg);
 908   1              Uart0_SendString("CtrlReg[05] = ");
 909   1              Uart0_SendByte(ASSII[temp/16]);
 910   1              Uart0_SendByte(ASSII[temp%16]);
 911   1              Uart0_SendString("\r\n");       
 912   1      
 913   1              temp=SL811Read(IntEna);
 914   1              Uart0_SendString("IntEna[06] = ");
 915   1              Uart0_SendByte(ASSII[temp/16]);
 916   1              Uart0_SendByte(ASSII[temp%16]);
 917   1              Uart0_SendString("\r\n");
 918   1      
 919   1              
 920   1              temp=SL811Read(IntStatus);
 921   1              Uart0_SendString("IntStatus[0d] = ");
C51 COMPILER V7.06   SL811                                                                 04/30/2005 15:12:27 PAGE 16  

 922   1              Uart0_SendByte(ASSII[temp/16]);
 923   1              Uart0_SendByte(ASSII[temp%16]);
 924   1              Uart0_SendString("\r\n");
 925   1      
 926   1              temp=SL811Read(cDATASet);
 927   1              Uart0_SendString("cDATASet[0e] = ");
 928   1              Uart0_SendByte(ASSII[temp/16]);
 929   1              Uart0_SendByte(ASSII[temp%16]);
 930   1              Uart0_SendString("\r\n");
 931   1      
 932   1              temp=SL811Read(cSOFcnt);
 933   1              Uart0_SendString("cSOFcnt[0f] = ");
 934   1              Uart0_SendByte(ASSII[temp/16]);
 935   1              Uart0_SendByte(ASSII[temp%16]);
 936   1              Uart0_SendString("\r\n");
 937   1      
 938   1                                     // 0x07 is reserved
 939   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2591    ----
   CONSTANT SIZE    =    302    ----
   XDATA SIZE       =   8192    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     36      30
   IDATA SIZE       =     45    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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