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

📄 main.lst

📁 用89C51SND1C实现的USB存储器的代码,包括USB通信和FLASH的读写操作.
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.23a  MAIN                                                                  11/27/2003 16:46:09 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          #include "fat16.h"
  15          
  16          extern unsigned char bulk_state;
  17          extern unsigned char Bulk_Out_Buf[512];
  18          
  19          code unsigned char Device_Descriptor[18]={
  20                                                                                  0x12,                   //0x12
  21                                                                                           0x01,              //DEVICE descriptor
  22                                                                                           0x10,0x01,         //spec rev level (BCD) 1.0
  23                                                                                           0x0,              //device class
  24                                                                                           0x0,              //device subclass
  25                                                                                           0x0,              //device protocol
  26                                                                                           0x20,              //max packet size
  27                                                                                           0x05,0x82,         //National's vendor ID
  28                                                                                           0x00,0x11,         //National's product ID  
  29                                                                                           0x00,0x00,         //National's revision ID  
  30                                                                                           0,                 //index of manuf. string   
  31                                                                                           0,                 //index of prod.  string  
  32                                                                                           0,                 //index of ser. # string   
  33                                                                                           0x01               //number of configs.        
  34                                                                                  };
  35          
  36          code unsigned char Configuration_Descriptor_All[32]={
  37          
  38                                                                                      9,//Size of Descriptor in Bytes
  39                                                                                      2,//Configuration Descriptor (0x02)
  40                                                                                      0x20,//Total length in bytes of data returned  LSB
  41                                                                                          0x00,//MSB
  42                                                                                          1,//Number of Interfaces
  43                                                                                          1,//Value to use as an argument to select this configuration
  44                                                                                      0,//Index of String Descriptor describing this configuration
  45                                                                                          0x80,
  46                                                                                          0xfa,//Maximum Power Consumption in 2mA units 
  47                                                                                  
  48                                                                                      9,
  49                                                                                      4,
  50                                                                                      0,//the index of the interface descriptor Number of Interface
  51                                                                                      0,//Value used to select alternative setting
  52                                                                                          2,//EndPoint Number Used in this Descriptor
  53                                                                                          8,//Class Code (Assigned by USB Org)
  54                                                                                          6,      //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
  55                                                                                          0x50,//bulk 0nly Transport
C51 COMPILER V6.23a  MAIN                                                                  11/27/2003 16:46:09 PAGE 2   

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

 118   1      }
 119          void Set_Address(unsigned char EpNum)
 120          {
 121   1      //      printu("Set_Address\n");
 122   1      //      unsigned char Test[]={0};
 123   1              WriteEp(0,0,0);//在Status阶段过后才能改变设备地址
 124   1      
 125   1              USBADDR|=EpNum;
 126   1              USBADDR|=FEN;
 127   1              USBCON|=FADDEN;
 128   1      
 129   1      //      printuf("\nSet_Address:%x\n",USBADDR);
 130   1      }
 131          void Get_Descriptor(unsigned char DesType,unsigned char nLength)
 132          {
 133   1      //      printu("Get_Descriptor\n");
 134   1              if(DesType==0x01) WriteEp(0,18,Device_Descriptor);
 135   1              if((DesType==0x02)&&(nLength==0x09)) WriteEp(0,9,Configuration_Descriptor_All);
 136   1              if((DesType==0x02)&&(nLength==0xff)) {WriteEp(0,32,Configuration_Descriptor_All);WriteEp(0,2,&Device_Desc
             -riptor[4]);}
 137   1              if((DesType==0x02)&&(nLength==0x20)) {WriteEp(0,32,Configuration_Descriptor_All);}
 138   1      
 139   1      //              printu("Get_Descriptor\n");
 140   1      }

⌨️ 快捷键说明

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