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

📄 usb.lst

📁 HardDiskUSBconnectsourcecode
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V8.05a   USB                                                                  05/22/2009 15:28:38 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE USB
OBJECT MODULE PLACED IN USB.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE USB.c BROWSE INCDIR(.\INCLUDE;D:\ch9\include\) DEBUG OBJECTEXTEND

line level    source

   1          /**************************************************************************
   2           *                         H E A D E R   F I L E S
   3           *************************************************************************/
   4          #include "stdio.h"
   5          #include<ABSACC.H>
   6          #include <reg51.h>
   7          #include <intrins.h>
   8          #include "AT89C51SND.h"
   9          #include "typedef.h"
  10          #include "config.h"
  11          #include "constant.h"
  12          #include "usb.h"
  13          #include "global.h"
  14          #include "gpio.h"
  15          #include "macro.h"
  16          #include "external.h"
  17          
  18          /********************************************
  19          *
  20          *GET_DESCRIPTOR(Device Descriptor = 18 byte)
  21          *
  22          ********************************************/
  23          code UINT8   USB_DeviceDescriptor[] =
  24          {
  25                          
  26          
  27                          
  28                          0x12,                   /*bLength:*/
  29                          0x01,                   /*bDescriptorType*/
  30                          0x10, 0x01,           /*bcdUSB*/
  31                          0x00,                   /*bDeviceClass*/
  32                          0x00,                   /*bDeviceSubClass*/
  33                          0x00,                   /*bDeviceProtocol*/
  34                          0x08,                   /*bMaxPacketSize0*/
  35                          0x34, 0x22,           /*idVendor*/
  36                          0x78, 0x56,           /*idProduct*/
  37                          0x01, 0x00,           /*bcdDevice*/
  38                          0x01,                   /*iManufacturer*/
  39                          0x02,                   /*iProduct*/
  40                          0x03,                   /*iSerialNumber*/
  41                          0x01,                   /*bNumConfigurations*/
  42          };
  43          
  44          /********************************************
  45          *
  46          *GET_DESCRIPTOR(Configuration Descriptor = 34 byte)
  47          *
  48          ********************************************/
  49          code UINT8   USB_ConfigurationDescriptor[] =
  50          {
  51                          
  52                          
  53                          0x09,                   /*bLength*/
  54                          0x02,                   /*bDescriptorType*/
  55                          0x20, 0x00,           /*wTotalLength*/
C51 COMPILER V8.05a   USB                                                                  05/22/2009 15:28:38 PAGE 2   

  56                          0x01,                   /*bNumInterfaces*/
  57                          0x01,                   /*bConfigurationValue*/
  58                          0x00,                   /*iConfiguration*/
  59                          0x80,                   /*bmAttributes*/
  60                          0xFA,                   /*bMaxPower*/
  61          
  62          
  63                          /*Interface Descriptor(0x09 byte)*/
  64                          0x09,                   /*bLength             */
  65                          0x04,                   /*bDescriptorType  */
  66                          0x00,                   /*bInterfaceNumber*/
  67                          0x00,                   /*bAlternateSetting*/
  68                          0x02,                   /*bNumEndpoints:*/
  69                          0x08,                   /*bInterfaceClass*/
  70                          0x06,                   /*bInterfaceSubClass:*/
  71                          0x50,                   /*bInterfaceProtocol*/
  72                          0x00,                   /*iInterface*/
  73          
  74                          /*Endpoint Descriptor (0x07 byte)*/
  75                          0x07,                   /*bLength:*/
  76                          0x05,                   /*bDescriptorType:*/
  77                          0x81,                   /*bEndpointAddress*/
  78                          0x02,                   /*bmAttributes*/
  79                          0x40, 0x00,           /*wMaxPacketSize*/
  80                          0x00,                   /*bInterval: ignored*/
  81                                             
  82          
  83                          /*Endpoint Descriptor (0x07 byte)*/
  84                          0x07,                   /*bLength:*/
  85                          0x05,                   /*bDescriptorType:*/
  86                          0x02,                   /*bEndpointAddress*/
  87                          0x02,                   /*bmAttributes*/
  88                          0x40, 0x00,           /*wMaxPacketSize*/
  89                          0x00,                   /*bInterval: ignored*/
  90          
  91          };
  92          
  93          /********************************************
  94          *
  95          *GET_DESCRIPTOR(STRING Descriptor = 4 byte)
  96          *
  97          ********************************************/
  98          code UINT8   USB_LanguageIdString[] =
  99          {
 100                          
 101                          0x04,              /*bLength*/
 102                          0x03,              /*bDescriptorType: STRING*/
 103                          0x09, 0x04,     /*bString: English (US)*/
 104          };
 105          
 106          /********************************************
 107          *
 108          *GET_DESCRIPTOR(STRING Descriptor = 32 byte)
 109          *
 110          ********************************************/
 111          code UINT8   USB_ManufacturerString[] =
 112          {
 113          
 114                          0x20,           /*bLength*/
 115                          0x03,           /*bDescriptorType: STRING*/
 116                          'a', 0x00,     
 117                          't', 0x00,
C51 COMPILER V8.05a   USB                                                                  05/22/2009 15:28:38 PAGE 3   

 118                          'm', 0x00,
 119                          'e', 0x00,
 120                          'l', 0x00,
 121                          ' ', 0x00,
 122                          ' ', 0x00,
 123                          ' ', 0x00,
 124                          ' ', 0x00,
 125                          ' ', 0x00,
 126                          ' ', 0x00,
 127                          ' ', 0x00,
 128                          ' ', 0x00,
 129                          ' ', 0x00,
 130                          ' ', 0x00,
 131          };
 132          
 133          /********************************************
 134          *
 135          *GET_DESCRIPTOR(STRING Descriptor = 48 byte)
 136          *
 137          ********************************************/
 138          code UINT8   USB_ProductString[] =
 139          {
 140                          
 141                          0x30,           /*bLength*/
 142                          0x03,           /*bDescriptorType: STRING*/
 143                          'a',0x00,     
 144                          't',0x00,
 145                          'm',0x00,
 146                          'e',0x00,
 147                          'l',0x00,
 148                          'a',0x00,
 149                          't',0x00,
 150                          '8',0x00,
 151                          '9',0x00,
 152                          'c',0x00,
 153                          '5',0x00,
 154                          '1',0x00,
 155                          's',0x00,
 156                          'n',0x00,
 157                          'd',0x00,
 158                          '1',0x00,
 159                          'c',0x00,
 160                          ' ',0x00,
 161                          ' ',0x00,
 162                          ' ',0x00,
 163                          ' ',0x00,
 164                          ' ',0x00,
 165                          ' ',0x00,
 166          };
 167          
 168          /********************************************
 169          *
 170          *GET_DESCRIPTOR(STRING Descriptor = 18 byte)
 171          *
 172          ********************************************/
 173          code UINT8   USB_SerialNumberString[] =
 174          {
 175                          
 176                          0x12,           /*bLength*/
 177                          0x03,           /*bDescriptorType: STRING*/
 178                          '0', 0x00,     /*bString: 01.00.00*/
 179                          '1', 0x00,
C51 COMPILER V8.05a   USB                                                                  05/22/2009 15:28:38 PAGE 4   

 180                          '.', 0x00,
 181                          '0', 0x00,
 182                          '0', 0x00,
 183                          '.', 0x00,
 184                          '0', 0x00,
 185                          '0', 0x00,
 186          };
 187          
 188          /**************************************************************************
 189           *                                                                                                        
             -                         
 190           *  Function Name: usb_init                                                                               
 191           *                                                                                                        
             -                  
 192           *  Descriptions:                                                       
 193           *                                                                        
 194           *  Arguments:                                                           
 195           *                                                                       
 196           *  Returns: None                                                         
 197           *                                          
 198           **************************************************************************/
 199          
 200          void usb_init(void ){
 201   1      
 202   1             Pll_ndiv(1);
 203   1             Pll_rdiv(11);
 204   1             Pll_enable();
 205   1             Set_Usb_clock(1);
 206   1             Usb_enable();      /*Enable usb controller*/     
 207   1             Reset_All_Ep();   
 208   1             Stop_Reset_All_Ep();
 209   1             Usb_sel_ep(0);   /*select ep0*/ 
 210   1               UEPCONX = 0x80;
 211   1      }
 212          
 213          /**************************************************************************
 214           *                                                                                                        
             -                         
 215           *  Function Name: usb_task                                                                               
 216           *                                                                                                        
             -                  
 217           *  Descriptions:                                                       
 218           *                                                                        
 219           *  Arguments:                                                           
 220           *                                                                       
 221           *  Returns: None                                                         
 222           *                                          
 223           **************************************************************************/
 224          void usb_task (void)
 225          {
 226   1      
 227   1      
 228   1      
 229   1              if (Usb_reset_event())                      
 230   1              {
 231   2                      Clear_Usb_reset_event();        
 232   2                      printf("USB RESET detection\n ");
 233   2              }
 234   1      
 235   1              if (Usb_ep_int_event() == 0x01)
 236   1              {

⌨️ 快捷键说明

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