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

📄 usb.h

📁 ST公司的upsd34XX评估板固定源程序
💻 H
字号:
 /* `=========================================================================`

                    ***************************************
                  ****   *                           *   ****
                                   Title: USB
                                File name: USB.H
                               Project name: USB
                  ****                                   ****
                    ***************************************

                    $Version:  0.005a  Build: April 30, 2004
                    $Version:  0.005   Build: 2004-02-24,20:44:09
                                  Description:
                                  ============
                         USB structures and constants.
                   Based on USB demo version 1.0.7, updated.
                     Since v.0.005 DT_HID_PHYSICALD added

                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                       Copyright 2003 ST Microelectronics

             This code/file is provided as is and has no warranty,
     implied or otherwise.  You are free to use/modify any of the provided
    code at your own risk in your applications with the expressed limitation
        of liability (see below) so long as your product using the code
                 contains at least one uPSD products (device).

                            LIMITATION OF LIABILITY:
                            ========================
              NEITHER STMicroelectronics NOR ITS VENDORS OR AGENTS
      SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
       INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
       CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
         OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                           =-=-=-=-=-=-=-=-=-=-=-=-=
                                  =-=-=-=-=-=

                   For current information on uPSD products,
                please consult our pages on the World Wide Web:

                                 www.st.com/psm

                            - - - - - - - - - - - -

                     STMicroelectronics GROUP OF COMPANIES
    Australia - Brazil - China - Czech Republic - Finland - France - Germany
   Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco - Singapore
             Spain - Sweden - Switzerland - United Kingdom - U.S.A.

                               http://www.st.com


 `========================================================================` */


#ifndef USB_H
#define USB_H
// iword - Intel word structure.  iword=uchar1, uchar2;
typedef struct
 {
  uchar lo;
  uchar hi;
 }   iword;             //定义字类型


// USB 1.1 device descriptor              //定义设备描述符类型;
                                          //共18个字节;    
typedef struct                            //一个USB总线设备只能有一个设备描述符
                                          //usb总线设备的一般信息
 {
  uchar bLength;                             // Size of this Descriptor in Bytes
  uchar bDescriptorType;                     // Descriptor Type (=1)
  iword bcdUSB;                              // USB Spec Release Number in BCD
  uchar bDeviceClass;                        // Device Class Code
                                         //我们设备定义为HID类
  uchar bDeviceSubClass;                     // Device Subclass Code
  uchar bDeviceProtocol;                     // Device Protocol Code
  uchar bMaxPacketSize0;                     // Maximum Packet Size for EP0
  iword idVendor;                            // Vendor ID
  iword idProduct;                           // Product ID
  iword bcdDevice;                           // Device Release Number in BCD
  uchar iManufacturer;                    // Index of String Desc for Manufacturer
  uchar iProduct;                            // Index of String Desc for Product
  uchar iSerialNumber;                       // Index of String Desc for SerNo
  uchar bNumConfigurations;                  // Number of possible Configurations
 }   device_descriptor;

// USB 1.1 configuration descriptor

typedef struct
 {
  uchar bLength;                             // Size of this Descriptor in Bytes
  uchar bDescriptorType;                     // Descriptor Type (=2)
  iword wTotalLength;                        // Total Length of Data for this Conf
  uchar bNumInterfaces;                 // No of Interfaces supported by this Conf
  uchar bConfigurationValue;          // Designator Value for *this* Configuration
  uchar iConfiguration;                      // Index of String Desc for this Conf
  uchar bmAttributes;                 // Configuration Characteristics (see below)
  uchar bMaxPower;                   // Max. Power Consumption in this Conf (*2mA)
 }
   configuration_descriptor;

// USB 1.1 interface descriptor           //接口描述符类型

typedef struct
 {
  uchar bLength;                             // Size of this Descriptor in Bytes
  uchar bDescriptorType;                     // Descriptor Type (=4)
  uchar bInterfaceNumber;                    // Number of *this* Interface (0..)
  uchar bAlternateSetting;              // Alternative for this Interface (if any)
  uchar bNumEndpoints;                    // No of EPs used by this IF (excl. EP0)
  uchar bInterfaceClass;                     // Interface Class Code
  uchar bInterfaceSubClass;                  // Interface Subclass Code
  uchar bInterfaceProtocol;                  // Interface Protocol Code
  uchar iInterface;                     // Index of String Desc for this Interface
 }
   interface_descriptor;

// USB 1.1 endpoint descriptor

typedef struct                             //端点描述符
 {
  uchar bLength;                             // Size of this Descriptor in Bytes
  uchar bDescriptorType;                     // Descriptor Type (=5)
  uchar bEndpointAddress;                 // Endpoint Address (Number + Direction)
  uchar bmAttributes;                       // Endpoint Attributes (Transfer Type)
  iword wMaxPacketSize;                      // Max. Endpoint Packet Size
  uchar bInterval;                           // Polling Interval (Interrupt) in ms
 }
   endpoint_descriptor;

// USB SETUP packet

typedef struct                                    //设置包描述符
 {
  uchar bmRequestType;               // Characteristics (Direction,Type,Recipient)
  uchar bRequest;                            // Standard Request Code
  iword wValue;                              // Value Field
  iword wIndex;                              // Index or Offset Field
  iword wLength;                       // Number of Bytes to transfer (Data Stage)
 }
   setup_buffer;

// USB Status Codes

#define US_ATTACHED       0x00
#define US_POWERED        0x01
#define US_DEFAULT        0x02
#define US_ADDRESSED      0x03
#define US_CONFIGURED     0x04
#define US_SUSPENDED      0x80

//added the following on April 30, 2004
//EP1 state VERA
#define US_EP1DEFAULT     0x00
#define US_EP1STALL       0x01


// USB Standard Device Request Codes   //USB标准11个请求

#define GET_STATUS        0x00
#define CLEAR_FEATURE     0x01
#define SET_FEATURE       0x03
#define SET_ADDRESS       0x05
#define GET_DESCRIPTOR    0x06
#define SET_DESCRIPTOR    0x07               // optional
#define GET_CONFIGURATION 0x08
#define SET_CONFIGURATION 0x09
#define GET_INTERFACE     0x0A
#define SET_INTERFACE     0x0B
#define SYNCH_FRAME       0x0C               // optional

// SETUP packet request types

#define CLASS_INTERFACE_TO_DEVICE   0x21           //到设备的类接口代码
#define CLASS_INTERFACE_TO_HOST     0xA1         //从设备到主机的接口代码

// HID class specific requests

#define HID_GET_REPORT      0x01                //人机接口类,另添加了6个特殊请求
#define HID_GET_IDLE        0x02               //还有两个特殊请求:
#define HID_SET_REPORT      0x09               //HID_SET_PROTOCOL
#define HID_SET_IDLE        0x0A               //HID_GET_PROTOCOL

#define REQUEST_COMPLETE 0xff                // not part of the Standard - just
                                             // a Flag to indicate that the recent
                                             // request has been finished
// Descriptor Types
                                //描述符类型
#define DT_DEVICE        1
#define DT_CONFIGURATION 2
#define DT_STRING        3
#define DT_INTERFACE     4
#define DT_ENDPOINT      5

#define DT_HID_CLASS     0x21  //HID的类描述符
#define DT_HID_REPORT    0x22  //HID的报表描述符
#define DT_HID_PHYSICALD 0x23  //

#endif


/* *************************************************************************
  ***                                                                      ***
  **                         *** End of File ***                            **
  ***                                                                      ***
   *************************************************************************  */

⌨️ 快捷键说明

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