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

📄 usb_drv.lst

📁 这是atmel公司的89C51SND1C的mp3源程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V6.20c  USB_DRV                                                               07/10/2002 15:17:37 PAGE 1   


C51 COMPILER V6.20c, COMPILATION OF MODULE USB_DRV
OBJECT MODULE PLACED IN ..\obj\usb_drv.obj
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE ..\..\..\lib\usb\usb_drv.c BROWSE INCDIR(..\src\system;..\..\..\lib) DEFINE
                    -(KEIL) DEBUG OBJECTEXTEND PRINT(.\usb_drv.lst) OBJECT(..\obj\usb_drv.obj) 

stmt level    source

   1          /*C**************************************************************************
   2          * $RCSfile: usb_drv.c,v $
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2002 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      $Name: DEMO_FAT_1_2_5 $      
   7          * REVISION:     $Revision: 1.8 $     
   8          * FILE_CVSID:   $Id: usb_drv.c,v 1.8 2002/06/07 08:56:20 ffosse Exp $       
   9          *----------------------------------------------------------------------------
  10          * PURPOSE: 
  11          * This file contains the USB driver routines
  12          *****************************************************************************/
  13          
  14          /*_____ I N C L U D E S ____________________________________________________*/
  15          
  16          #include "config.h"                         /* system configuration */
  17          #include "usb_drv.h"                        /* usb driver definition */
  18          
  19          
  20          /*_____ M A C R O S ________________________________________________________*/
  21          
  22          
  23          /*_____ D E F I N I T I O N ________________________________________________*/
  24          
  25          code struct usb_st_device_descriptor usb_device_descriptor =
  26            {
  27              sizeof(usb_device_descriptor), DEVICE, 0x1001, 0, 0, 0, EP_CONTROL_LENGTH,
  28              VENDOR_ID, PRODUCT_ID, RELEASE_NUMBER, MAN_INDEX, PROD_INDEX, SN_INDEX, 1
  29            };
  30          
  31          code struct usb_st_manufacturer usb_manufacturer =
  32            {
  33              sizeof(usb_manufacturer), STRING,
  34              USB_MANUFACTURER_NAME
  35            };
  36          
  37          code struct usb_st_product usb_product =
  38            {
  39              sizeof(usb_product), STRING,
  40              USB_PRODUCT_NAME
  41            };
  42          
  43          code struct usb_st_serial_number usb_serial_number =
  44            {
  45              sizeof(usb_serial_number), STRING,
  46              USB_SERIAL_NUMBER
  47            };
  48          
  49          code struct usb_st_language_descriptor usb_language =
  50            {
  51              sizeof(usb_language), STRING, 0x0904
  52            };
  53          
  54          code struct  
C51 COMPILER V6.20c  USB_DRV                                                               07/10/2002 15:17:37 PAGE 2   

  55            {
  56              struct usb_st_configuration_descriptor  cfg;
  57              struct usb_st_interface_descriptor      ifc;
  58              struct usb_st_endpoint_descriptor       ep1;
  59              struct usb_st_endpoint_descriptor       ep2;
  60            }
  61            usb_configuration =
  62              {
  63                { 9, CONFIGURATION, sizeof(usb_configuration) << 8, 1, 1, 0, USB_CONFIG_BUSPOWERED, 0x32},
  64                { 9, INTERFACE, 0, 0, 2, 0x08, 0x06, 0x50, 0 },
  65                { 7, ENDPOINT, 0x81, 0x02, EP_IN_LENGTH << 8, 0 },
  66                { 7, ENDPOINT, 0x02, 0x02, EP_OUT_LENGTH << 8, 0 }
  67              };
  68          
  69          static  bdata bit     zlp;
  70          static  idata Byte    endpoint_status[3];
  71          
  72          static  idata Byte    *pbuffer;
  73          static  idata Byte    bmRequestType;
  74          
  75          
  76          /*_____ D E C L A R A T I O N ______________________________________________*/
  77          
  78          extern  void    usb_mass_storage_reset (void);
  79          extern  void    usb_mass_storage_get_lun (void);
  80          
  81          static  void    usb_get_descriptor (void);
  82          static  Byte*   send_ep0_packet (Byte *, Byte);
  83          static  void    usb_read_request (void);
  84          static  void    usb_set_address (void);
  85          static  void    usb_set_configuration (void);
  86          static  void    usb_clear_feature (void);
  87          static  void    usb_set_feature (void);
  88          static  void    usb_get_status (void);
  89          static  void    usb_get_configuration (void);
  90          
  91          
  92          /*F**************************************************************************
  93          * NAME: usb_init
  94          *----------------------------------------------------------------------------
  95          * PARAMS:
  96          *
  97          * return:
  98          *----------------------------------------------------------------------------
  99          * PURPOSE: 
 100          * This function initializes the USB controller and resets the endpoints FIFOs.
 101          *----------------------------------------------------------------------------
 102          * EXAMPLE:
 103          *----------------------------------------------------------------------------
 104          * NOTE: 
 105          *----------------------------------------------------------------------------
 106          * REQUIREMENTS: 
 107          *****************************************************************************/
 108          void usb_init (void)
 109          {
 110   1        Usb_enable();                             /* enable USB */
 111   1        UEPRST = 0x07;                            /* Reset EP 0, 1 and 2 */
 112   1        UEPRST = 0x00;
 113   1        endpoint_status[EP_CONTROL] = 0x00;
 114   1        endpoint_status[EP_IN] = 0x00;
 115   1        endpoint_status[EP_OUT] = 0x00;
 116   1        Usb_select_ep(EP_CONTROL);                /* control endpoint config */
C51 COMPILER V6.20c  USB_DRV                                                               07/10/2002 15:17:37 PAGE 3   

 117   1        UEPCONX = CONTROL;
 118   1      }
 119          
 120          
 121          /*F**************************************************************************
 122          * NAME: usb_ep_init
 123          *----------------------------------------------------------------------------
 124          * PARAMS:
 125          *
 126          * return:
 127          *----------------------------------------------------------------------------
 128          * PURPOSE: 
 129          * This function configures the endpoints.
 130          *----------------------------------------------------------------------------
 131          * EXAMPLE:
 132          *----------------------------------------------------------------------------
 133          * NOTE: 
 134          *----------------------------------------------------------------------------
 135          * REQUIREMENTS: 
 136          *****************************************************************************/
 137          void usb_ep_init (void)
 138          {
 139   1        Usb_select_ep(EP_CONTROL);
 140   1        UEPCONX = CONTROL;
 141   1        Usb_select_ep(EP_IN);                     /* endpoints configuration */
 142   1        UEPCONX = BULK_IN ;
 143   1        Usb_select_ep(EP_OUT);
 144   1        UEPCONX = BULK_OUT;
 145   1        UEPRST = 0x07;
 146   1        UEPRST = 0x00;
 147   1      }
 148          
 149          
 150          /*F**************************************************************************
 151          * NAME: usb_send_ep0_packet
 152          *----------------------------------------------------------------------------
 153          * PARAMS:
 154          * *tbuf:        address of the first data to send
 155          * data_length:  number of bytes to send
 156          *
 157          * return:       address of the next byte to send
 158          *----------------------------------------------------------------------------
 159          * PURPOSE: 
 160          * This function sends the data over the default control endpoint.
 161          *----------------------------------------------------------------------------
 162          * EXAMPLE:
 163          *----------------------------------------------------------------------------
 164          * NOTE: 
 165          *----------------------------------------------------------------------------
 166          * REQUIREMENTS: 
 167          *****************************************************************************/
 168          Byte* send_ep0_packet (Byte *tbuf, Byte data_length)
 169          {
 170   1      Byte i;
 171   1      
 172   1        Usb_select_ep(EP_CONTROL);
 173   1        for (i = data_length; i != 0 ; i--, tbuf++)
 174   1        {
 175   2          Usb_write_byte(*tbuf); 
 176   2        }
 177   1        Usb_set_TXRDY();                          /* Send packet */
 178   1        return tbuf;
C51 COMPILER V6.20c  USB_DRV                                                               07/10/2002 15:17:37 PAGE 4   

 179   1      }
 180          
 181          
 182          /*F**************************************************************************
 183          * NAME: usb_enumeration_process
 184          *----------------------------------------------------------------------------
 185          * PARAMS:
 186          *
 187          * return:
 188          *----------------------------------------------------------------------------
 189          * PURPOSE: 
 190          * This function manages the enumeration process
 191          *----------------------------------------------------------------------------
 192          * EXAMPLE:
 193          *----------------------------------------------------------------------------
 194          * NOTE: 
 195          *----------------------------------------------------------------------------
 196          * REQUIREMENTS: 
 197          *****************************************************************************/
 198          void usb_enumeration_process (void)
 199          { 
 200   1        Usb_select_ep(EP_CONTROL);
 201   1        usb_read_request();
 202   1      }
 203          
 204          
 205          /*F**************************************************************************
 206          * NAME: usb_read_request
 207          *----------------------------------------------------------------------------
 208          * PARAMS:
 209          *
 210          * return:
 211          *----------------------------------------------------------------------------
 212          * PURPOSE: 
 213          * This function reads the SETUP request sent to the default control endpoint
 214          * and  the appropriate function. When exiting of the usb_read_request
 215          * function, the device is ready to manage the next request.
 216          *----------------------------------------------------------------------------
 217          * EXAMPLE:
 218          *----------------------------------------------------------------------------
 219          * NOTE: list of supported requests:
 220          *               GET_DESCRIPTOR
 221          *               GET_CONFIGURATION
 222          *               SET_ADDRESS
 223          *               SET_CONFIGURATION
 224          *               CLEAR_FEATURE
 225          *               SET_FEATURE
 226          *               GET_STATUS
 227          *               GET_MAX_LUN
 228          *               MASS_STORAGE_RESET
 229          *----------------------------------------------------------------------------
 230          * REQUIREMENTS: 
 231          *****************************************************************************/
 232          void usb_read_request (void)
 233          { 
 234   1        bmRequestType = Usb_read_byte();          /* read bmRequestType */
 235   1      
 236   1        switch (Usb_read_byte())                  /* test the bRequest value */
 237   1        {
 238   2          case GET_DESCRIPTOR:
 239   2            usb_get_descriptor();
 240   2            break;
C51 COMPILER V6.20c  USB_DRV                                                               07/10/2002 15:17:37 PAGE 5   

 241   2          case GET_CONFIGURATION:
 242   2            usb_get_configuration();
 243   2            break;
 244   2          case SET_ADDRESS:
 245   2            usb_set_address();
 246   2            break;
 247   2          case SET_CONFIGURATION:
 248   2            usb_set_configuration();
 249   2            break;
 250   2          case CLEAR_FEATURE:
 251   2            usb_clear_feature();
 252   2            break;
 253   2          case SET_FEATURE:
 254   2            usb_set_feature();
 255   2            break;
 256   2          case GET_STATUS:
 257   2            usb_get_status();
 258   2            break;
 259   2          case GET_MAX_LUN:

⌨️ 快捷键说明

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