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

📄 main.lst

📁 用89C51SND1C实现的USB存储器的代码,包括USB通信和FLASH的读写操作.
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.23a  MAIN                                                                  11/27/2003 16:42:27 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: d:\SoftDev\Keil\C51\BIN\C51.EXE main.c LARGE BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /****************************************************************/
   2          /*                                      UP-MP3DIY100                                                            */
   3          /*              Beijing Universal Pioneering Technology Co., LTD                */
   4          /*              CopyRighted,All right Reserved  www.up-tech.com                 */
   5          /*                                              July,2003                                                               */
   6          /*                              010-62387873  62381842                                                  */
   7          /****************************************************************/
   8          
   9          #include <REGSND1.H>
  10          #include "uart.h"
  11          #include "atmelusbci.h"
  12          #include "main.h"
  13          #include "bulk_only.h"
  14          
  15          extern unsigned char bulk_state;
  16          extern unsigned char Bulk_Out_Buf[512];
  17          
  18          code unsigned char Device_Descriptor[18]={
  19                                                                                  0x12,                   //0x12
  20                                                                                           0x01,              //DEVICE descriptor
  21                                                                                           0x10,0x01,         //spec rev level (BCD) 1.0
  22                                                                                           0x0,              //device class
  23                                                                                           0x0,              //device subclass
  24                                                                                           0x0,              //device protocol
  25                                                                                           0x20,              //max packet size
  26                                                                                           0x05,0x82,         //National's vendor ID
  27                                                                                           0x00,0x11,         //National's product ID  
  28                                                                                           0x00,0x00,         //National's revision ID  
  29                                                                                           0,                 //index of manuf. string   
  30                                                                                           0,                 //index of prod.  string  
  31                                                                                           0,                 //index of ser. # string   
  32                                                                                           0x01               //number of configs.        
  33                                                                                  };
  34          
  35          code unsigned char Configuration_Descriptor_All[32]={
  36          
  37                                                                                      9,//Size of Descriptor in Bytes
  38                                                                                      2,//Configuration Descriptor (0x02)
  39                                                                                      0x20,//Total length in bytes of data returned  LSB
  40                                                                                          0x00,//MSB
  41                                                                                          1,//Number of Interfaces
  42                                                                                          1,//Value to use as an argument to select this configuration
  43                                                                                      0,//Index of String Descriptor describing this configuration
  44                                                                                          0x80,
  45                                                                                          0xfa,//Maximum Power Consumption in 2mA units 
  46                                                                                  
  47                                                                                      9,
  48                                                                                      4,
  49                                                                                      0,//the index of the interface descriptor Number of Interface
  50                                                                                      0,//Value used to select alternative setting
  51                                                                                          2,//EndPoint Number Used in this Descriptor
  52                                                                                          8,//Class Code (Assigned by USB Org)
  53                                                                                          6,      //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
  54                                                                                          0x50,//bulk 0nly Transport
  55                                                                                          0,//Index of String Descriptor Describing this interface
C51 COMPILER V6.23a  MAIN                                                                  11/27/2003 16:42:27 PAGE 2   

  56          
  57                                                                                           //Bulk-in Endpoint
  58                                                                                           0x07,              //length of this desc.   
  59                                                                                           0x05,              //ENDPOINT descriptor TYPE
  60                                                                                           0x81,              //address (IN) Endpoint 4 84
  61                                                                                           0x02,              //attributes  (BULK)    
  62                                                                                           0x40,0x00,         //max packet size (64)
  63                                                                                           0x0,              //Does not apply to Bulk endpoints
  64                                                                  
  65                                                                                           //Bulk-out Endpoint
  66                                                                                           0x07,              //length of this desc.   
  67                                                                                           0x05,              //ENDPOINT descriptor TYPE
  68                                                                                           0x02,              //address (OUT) Endpoint 5 05
  69                                                                                           0x02,              //attributes  (BULK)
  70                                                                                           0x40,0x00,         //max packet size (64)
  71                                                                                           0x0             //Does not apply to Bulk endpoints
  72                                                                                          };
  73          
  74          unsigned char ReadEp(unsigned char EpNum,unsigned char *Data)
  75          {
  76   1              unsigned char i=0,nLength;
  77   1              UEPNUM=EpNum;
  78   1      
  79   1              nLength=UBYCTX;
  80   1              while(nLength--) {Data[i++]=UEPDATX;/*printuf("%x ",Data[i]);*/}
  81   1      
  82   1              UEPSTAX&=~(RXOUTB0|RXOUTB1|RXSETUP);
  83   1              return(i);
  84   1      }
  85          
  86          void WriteEp(unsigned char EpNum,unsigned char nLength,unsigned char *Data)
  87          {
  88   1              unsigned char i=0;
  89   1              UEPNUM=EpNum;
  90   1              UEPSTAX|=DIR;//Set for status of a Control In transaction
  91   1              while(nLength--) UEPDATX=Data[i++];
  92   1              UEPSTAX|=TXRDY;//Sending the data,this action will switch between bank0 and bank1
  93   1              while(!(UEPSTAX&TXCMP)) ;
  94   1              UEPSTAX&=(~(TXCMP));//clear TXCMP
  95   1      }
  96          
  97          
  98          void Get_Status()
  99          {
 100   1              printu("Get_Status\n");
 101   1      }
 102          void Clear_Feature()
 103          {
 104   1              printu("Clear_Feature\n");
 105   1      }
 106          void Set_Feature()
 107          {
 108   1              printu("Set_Feature\n");
 109   1      }
 110          void Set_Address(unsigned char EpNum)
 111          {
 112   1              printu("Set_Address\n");
 113   1      //      unsigned char Test[]={0};
 114   1              WriteEp(0,0,0);//在Status阶段过后才能改变设备地址
 115   1      
 116   1              USBADDR|=EpNum;
 117   1              USBADDR|=FEN;
C51 COMPILER V6.23a  MAIN                                                                  11/27/2003 16:42:27 PAGE 3   

 118   1              USBCON|=FADDEN;
 119   1      
 120   1      //      printuf("\nSet_Address:%x\n",USBADDR);
 121   1      }
 122          void Get_Descriptor(unsigned char DesType,unsigned char nLength)
 123          {
 124   1              printu("Get_Descriptor\n");
 125   1              if(DesType==0x01) WriteEp(0,18,Device_Descriptor);
 126   1              if((DesType==0x02)&&(nLength==0x09)) WriteEp(0,9,Configuration_Descriptor_All);
 127   1              if((DesType==0x02)&&(nLength==0xff)) {WriteEp(0,32,Configuration_Descriptor_All);WriteEp(0,2,&Device_Desc
             -riptor[4]);}

⌨️ 快捷键说明

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