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

📄 32musb.lst

📁 这个是一个完整的MP3项目
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.20   32MUSB                                                                03/21/2007 13:33:19 PAGE 1   


C51 COMPILER V7.20, COMPILATION OF MODULE 32MUSB
OBJECT MODULE PLACED IN 32MUSB.OBJ
COMPILER INVOKED BY: C:\Program Files\keil\C51\BIN\C51.EXE 32MUSB.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*
   2          * Copyright (c) 2004,北京博创兴业科技有限公司
   3          * All rights reserved.
   4          * 
   5          * 文件名称:32MUSB.c
   6          * 文件标识:32MUSB
   7          * 摘    要:主函数
   8          * 
   9          * 当前版本:2.0
  10          * 作    者:Kent
  11          * 完成日期:2004年5月20日
  12          *
  13          * 取代版本:1.1 
  14          * 原作者  :Frank
  15          * 完成日期:2003年8月10日
  16          */
  17          
  18          #include "REGSND1.H"
  19          #include "atmelusbci.h"
  20          #include "uart.h"
  21          #include "usbdisk.h"
  22          #include "bulk_only.h"
  23          #include "fat16.h"
  24          #include "flash.h"
  25          
  26          //int m=0;
  27          extern unsigned char bulk_CSW[];
  28          extern unsigned char bulk_state;//记录USB传输过程中传输状态
  29          //extern unsigned char Bulk_Out_Buf[];//Bulk-Out端点缓存区
  30          extern unsigned char Page_Buf[];//页(扇区)缓存区 
  31          extern unsigned char FirstTransaction;
  32          extern unsigned char *BulkPoint;
  33          extern unsigned char *BulkStartPoint;
  34          //设备描述符
  35          code unsigned char Device_Descriptor[18] = {
  36                                                                                   0x12,                  //0x12
  37                                                                                           0x01,              //DEVICE descriptor
  38                                                                                           0x10, 0x01,         //spec rev level (BCD) 1.0
  39                                                                                           0x0,              //device class
  40                                                                                           0x0,              //device subclass
  41                                                                                           0x0,              //device protocol
  42                                                                                           0x20,              //max packet size
  43                                                                                           0x05, 0x82,         //National's vendor ID
  44                                                                                           0x00, 0x11,         //National's product ID  
  45                                                                                           0x00, 0x00,         //National's revision ID  
  46                                                                                           0,                 //index of manuf. string   
  47                                                                                           0,                 //index of prod.  string  
  48                                                                                           0,                 //index of ser. # string   
  49                                                                                           0x01               //number of configs.        
  50                                                                                  };
  51          //配置描述符
  52          code unsigned char Configuration_Descriptor_All[32] = {
  53          
  54                                                                                      9,//Size of Descriptor in Bytes
  55                                                                                      2,//Configuration Descriptor (0x02)
C51 COMPILER V7.20   32MUSB                                                                03/21/2007 13:33:19 PAGE 2   

  56                                                                                      0x20,//Total length in bytes of data returned  LSB
  57                                                                                          0x00,//MSB
  58                                                                                          1,//Number of Interfaces
  59                                                                                          1,//Value to use as an argument to select this configuration
  60                                                                                      0,//Index of String Descriptor describing this configuration
  61                                                                                          0x80,
  62                                                                                          0xfa,//Maximum Power Consumption in 2mA units 
  63                                                                                  
  64                                                                                      9,
  65                                                                                      4,
  66                                                                                      0,//the index of the interface descriptor Number of Interface
  67                                                                                      0,//Value used to select alternative setting
  68                                                                                          2,//EndPoint Number Used in this Descriptor
  69                                                                                          8,//Class Code (Assigned by USB Org)
  70                                                                                          6,      //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
  71                                                                                          0x50,//bulk 0nly Transport
  72                                                                                          0,//Index of String Descriptor Describing this interface
  73          
  74                                                                                           //Bulk-in Endpoint
  75                                                                                           0x07,              //length of this desc.   
  76                                                                                           0x05,              //ENDPOINT descriptor TYPE
  77                                                                                           0x81,              //address (IN) Endpoint 4 84
  78                                                                                           0x02,              //attributes  (BULK)    
  79                                                                                           0x40, 0x00,         //max packet size (64)
  80                                                                                           0x0,              //Does not apply to Bulk endpoints
  81                                                                  
  82                                                                                           //Bulk-out Endpoint
  83                                                                                           0x07,              //length of this desc.   
  84                                                                                           0x05,              //ENDPOINT descriptor TYPE
  85                                                                                           0x02,              //address (OUT) Endpoint 5 05
  86                                                                                           0x02,              //attributes  (BULK)
  87                                                                                           0x40, 0x00,         //max packet size (64)
  88                                                                                           0x0             //Does not apply to Bulk endpoints
  89                                                                                          };
  90          
  91          //用于存放歌曲列表的数组
  92          unsigned char SONG[88] = {'M', 'O', 'O', 'N', ' ', ' ', ' ', ' ', 'T', 'X', 'T'};
  93          
  94          //MP3有关的变量*********************
  95          #define VOLUME          1
  96          #define EFFECTION       2
  97          #define SELECTSONG      3
  98          #define PLAY            1
  99          #define STOP            0
 100          unsigned char CurrentFun = SELECTSONG;
 101          unsigned char PlayState = STOP;
 102          unsigned char ChangeSong = 0;
 103          
 104          unsigned char NowPlaying = 0;
 105          unsigned char NumofSong = 0;
 106          extern long int DataRead;
 107          //***************************
 108          
 109          //USB DISK 
 110          //读端点数据
 111          unsigned char ReadEp(unsigned char EpNum, unsigned char *Data)
 112          {
 113   1              unsigned char i = 0, nLength;
 114   1              UEPNUM = EpNum;//指向相应端点
 115   1              BulkStartPoint = Data;
 116   1              nLength = UBYCTX;//读取端点数据长度
 117   1      
C51 COMPILER V7.20   32MUSB                                                                03/21/2007 13:33:19 PAGE 3   

 118   1              while (nLength--) 
 119   1              { 
 120   2                      if (UEPNUM == 2) 
 121   2                      {
 122   3                              *(BulkPoint++) = UEPDATX;
 123   3                              i++;
 124   3                      }
 125   2                      else
 126   2                      {
 127   3                              Data[i++] = UEPDATX;//*printuf("%x ",Data[i]);*/}//依次读取端点收到的数据
 128   3                      }
 129   2              }
 130   1      
 131   1              UEPSTAX &= ~(RXOUTB0 | RXOUTB1 | RXSETUP);//清中断标志
 132   1              return (i);//返回读取到的数据的长度
 133   1      }
 134          
 135          //向端点0写数据
 136          void WriteEp(unsigned char EpNum, unsigned char nLength, unsigned char *Data)
 137          {
 138   1              unsigned char i=0;
 139   1      
 140   1              UEPNUM = EpNum;//指向相应端点
 141   1              UEPSTAX |= DIR;//设置方向为写
 142   1      
 143   1              while (nLength--) 
 144   1              {
 145   2                      UEPDATX = Data[i++];//将数据写入端点
 146   2              }
 147   1      
 148   1              UEPSTAX |= TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
 149   1      
 150   1              while (!(UEPSTAX & TXCMP)) ;//等待发送完成
 151   1      
 152   1              UEPSTAX &= (~(TXCMP));//清中断标志clear TXCMP
 153   1      }
 154          
 155          //写Bulk端点
 156          void WriteEpBulk(unsigned char EpNum, unsigned char nLength, unsigned char *Data)
 157          {
 158   1              unsigned char i;
 159   1      
 160   1              UEPNUM = EpNum;//指向相应端点
 161   1              UEPSTAX |= DIR;//设置方向为写Set for status of a Control In transaction
 162   1      
 163   1              for (i=0; i<nLength; i++) 
 164   1              {
 165   2                      UEPDATX = Data[i];//将数据写入端点
 166   2              }
 167   1      
 168   1              UEPSTAX |= TXRDY;//发送数据Sending the data,this action will switch between bank0 and bank1
 169   1              
 170   1      }
 171          
 172          void Get_Status()
 173          {
 174   1              printu("Get_Status");
 175   1      } 
 176          
 177          void Clear_Feature()
 178          {
 179   1              printu("Clear_Feature");
C51 COMPILER V7.20   32MUSB                                                                03/21/2007 13:33:19 PAGE 4   

 180   1      }
 181          
 182          void Set_Feature()
 183          {
 184   1              printu("Set_Feature");
 185   1      } 
 186          
 187          void Set_Address(unsigned char EpNum)
 188          {
 189   1      //      unsigned char Test[] = {0};
 190   1              WriteEp(0, 0, 0);//在Status阶段过后才能改变设备地址
 191   1      
 192   1              USBADDR |= EpNum;//设置地址
 193   1              USBADDR |= FEN;//地址使能
 194   1              USBCON |= FADDEN;
 195   1      
 196   1      //      printuf("\nSet_Address : %x\n", USBADDR);
 197   1      } 
 198          
 199          void Get_Descriptor(unsigned char DesType, unsigned char nLength)
 200          {
 201   1              if (DesType == 0x01) 
 202   1              {
 203   2                      WriteEp(0, 18, Device_Descriptor);//提供设备描述符
 204   2              }
 205   1              if ((DesType == 0x02) && (nLength == 0x09))
 206   1              {
 207   2                      WriteEp(0, 9, Configuration_Descriptor_All);//提供配置描述符
 208   2              }
 209   1              //提供全部描述符
 210   1              if ((DesType == 0x02) && (nLength == 0xff)) 
 211   1              { 
 212   2                      WriteEp(0, 32, Configuration_Descriptor_All);
 213   2                      WriteEp(0, 2, &Device_Descriptor[4]);
 214   2              }
 215   1              //提供全部描述符
 216   1              if ((DesType == 0x02) && (nLength == 0x20))
 217   1              {
 218   2                      WriteEp(0, 32, Configuration_Descriptor_All);
 219   2              }
 220   1      
 221   1      //              printu("Get_Descriptor\n");
 222   1      }
 223          

⌨️ 快捷键说明

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