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

📄 usb20.h

📁 Spearhead2000的bootloader
💻 H
字号:
/********************************************************************************                                                                           ****  Copyright (c) 2002 ST Microelectronics                                   ****  All rights reserved                                                      ****                                                                           ****      Filename  :  usb20.h                                                 ****      Author    :  Armando Visconti                                        ****      Revision  :  1.0                                                     ****                                                                           ****                                                                           ****                                                                           *********************************************************************************/#ifndef ___USB20_HEADER#define ___USB20_HEADER#ifdef     __cplusplusextern  "C" {           /* C declarations in C++     */#endif//*****************************************************************************//* Defines for UDC//*****************************************************************************/* * This file contains declarations according to Chapter 9 of * the "Universal Serial Bus Specification Revision 2.0". */ /*********************************************************** * USB Requests. ***********************************************************/ // This struct is 8 bytes long.//typedef struct//        {//                char    bmReqType;//                char    bReq;//                short   wValue;//                short   wIndex;//                short   wLen;//        } UsbSetup;// USB device requests, the setup packet.//// The structure is defined entirely in terms of bytes, eliminating// any confusion about who is supposed to swap what when. This avoids// endianness-related portability problems, and eliminates any need// to worry about alignment. Also for some requests the value field// is split into separate bytes anyway.typedef struct  {    unsigned char       bmReqType;    unsigned char       bReq;    unsigned char       wValue_lo;    unsigned char       wValue_hi;    unsigned char       wIndex_lo;    unsigned char       wIndex_hi;    unsigned char       wLen_lo;    unsigned char       wLen_hi;} UsbSetup; // USB Standard Request Opcode#define USB_GET_STATUS          0#define USB_CLEAR_FEATURE       1#define USB_RESERVED1           2#define USB_SET_FEATURE         3#define USB_RESERVED2           4#define USB_SET_ADDRESS         5#define USB_GET_DESCRIPTOR      6#define USB_SET_DESCRIPTOR      7#define USB_GET_CONFIGURATION   8#define USB_SET_CONFIGURATION   9#define USB_GET_INTERFACE       10#define USB_SET_INTERFACE       11#define USB_SYNCH_FRAME         12// USB Printer Class Specific Request Opcode#define USB_GET_DEVICE_ID       0#define USB_GET_PORT_STATUS     1#define USB_SOFT_RESET          2// USB Request Type#define USB_DIR_MASK            0x80#define USB_DIR_TO_DEV          0x00#define USB_DIR_TO_HOST         0x80#define USB_TYPE_MASK           0x60#define USB_TYPE_STANDARD       0x00#define USB_TYPE_CLASS          0x20#define USB_TYPE_VENDOR         0x40#define USB_DEST_MASK           0x1F#define USB_DEST_DEV            0x00#define USB_DEST_INTERFACE      0x01#define USB_DEST_ENDPT          0x02// USB Descriptor Types#define USB_DEVICE                     0x01#define USB_CONFIGURATION              0x02#define USB_STRING                     0x03#define USB_INTERFACE                  0x04#define USB_ENDPOINT                   0x05#define USB_DEVICE_QUALIFIER           0X06#define USB_OTHER_SPEED_CONFIGURATION  0X07#define USB_INTERFACE_POWER            0X08// USB Descriptor Lengths#define USB_DEVICE_LEN                     0x12#define USB_CONFIGURATION_LEN              0x09#define USB_INTERFACE_LEN                  0x09#define USB_ENDPOINT_LEN                   0x07#define USB_DEVICE_QUALIFIER_LEN           0X0A#define USB_OTHER_SPEED_CONFIGURATION_LEN  0x09/*********************************************************** * USB Descriptors. ***********************************************************/ /* * Device Descriptor */typedef struct        {                char    bLength;                // Size of this Descriptor in bytes.                char    bDescrType;             // USB_DEVICE Descriptor Type.                short   bcdUSB;                 // USB Specification Rel # (in BCD).                char    bDevClass;              // Device Class code.                char    bDevSubClass;           // Device SubClass code.                char    bDevProtocol;           // Device Protocol code.                char    bMaxPacketSize;         // Endpoint 0 maximum packet size.                short   idVendor;               // Vendor ID code.                short   idProduct;              // Product ID code.                short   bcdDevice;              // Device Rel # (in BCD).                char    iManufacturer;          // Index of string descriptor for Manufacturer.                char    iProduct;               // Index of string descriptor for Product.                char    iSerialNumber;          // Index of string descriptor for Serial #.                char    bNumConfigurations;     // # of configurations.        } UsbDevDescr;/* Printer Device Descriptor definitions */#define USB_DEV_LENGTH          0x12        #define USB_DEV_SPEC_NUM        0x0100#define USB_DEV_CLASS           0x00#define USB_DEV_SUBCLASS        0x00#define USB_DEV_PROTOCOL        0x00#define USB_DEV_MAXPCKSZ0       0x40#define USB_DEV_VENDOR_ID       0x00 // (TODO)#define USB_DEV_PRODUCT_ID      0x00 // (TODO)#define USB_DEV_RELEASE_NUM     0x00 // (TODO)#define USB_DEV_RELEASE_NUM     0x00 // (TODO)#define USB_DEV_MFG_STR         0x00 // String not supported (0x00)#define USB_DEV_PRODUCT_STR     0x00 // String not supported (0x00)#define USB_DEV_SERIAL_STR      0x00 // String not supported (0x00)#define USB_DEV_CFG_NUM         0x01 #define USB_DESCR_MASK          0xFF/* * Configuration Descriptor */typedef struct        {                char    bLength;                // Size of this Descriptor in bytes.                char    bDescrType;             // USB_CONFIGURATION Descriptor Type.                short   bTotalLen;              // Total byte len (CFG descr + IF descrs + ENDPT descrs).                char    bNumIfs;                // Number of interfaces belonging to this configuration.                char    bCfgValue;              // Configuration selector.                char    iCfg;                   // Index of string descriptor for this configuration.                char    bmAttrs;                // Configuration characteristics                char    MaxPower;               // Maximum power consumption for this configuration.        } UsbCfgDescr;/* Printer Configuration Descriptor definitions */#define USB_CFG_LENGTH          0x09        #define USB_CFG_IF_NUM          0x01#define USB_CFG_SELECT          0x01#define USB_CFG_STR             0x00#define USB_CFG_ATTR            0x60#define USB_CFG_MAXPOWER        0x00      /* * Interface Descriptor */typedef struct        {                char    bLength;                // Size of this Descriptor in bytes.                char    bDescrType;             // USB_INTERFACE Descriptor Type.                char    bIfNum;                 // Interface number.                char    bAltSet;                // Alternative setting.                char    bNumEndpts;             // Number of endpoints selector.                char    bIfClass;               // Interface class.                char    bIfSubClass;            // Interface sub-class.                char    bIfProto;               // Interface protocol                char    iInterface;             // Index of string describing interface.        } UsbIfDescr;/* Printer Interface Descriptor definitions */#define USB_IF_LENGTH           0x09#define USB_IF_NUM              0x00#define USB_IF_ALT_SETT         0x00#define USB_IF_ENDPT_NUM        0x04#define USB_IF_CLASS            0x07#define USB_IF_SUBCLASS         0x01#define USB_IF_PROTO            0x02#define USB_IF_STR              0x00/* * Endpoint Descriptor */typedef struct        {                char    bLength;                // Size of this Descriptor in bytes.                char    bDescrType;             // USB_ENDPOINT Descriptor Type.                char    bEndPtAddr;             // Endpoint address.                char    bmAttr;                 // Endpoint attributes.                short   wMaxPacketSize;         // Endpoint maximum packet size.                char    bInterval;              // Endpoint interval.        } UsbEndPtDescr;/* Printer Bulk-OUT Endpoint Descriptor definitions */#define USB_BLKOUT1_LENGTH      0x09        #define USB_BLKOUT1_ADDR        0x01     #define USB_BLKOUT1_ATTR        0x02#define USB_BLKOUT1_MAXPCKSZ    0x40     /* (non deve essere in word? per gli endpoint*/ #define USB_BLKOUT1_INTERVAL    0x00     /* bulk la max dimens. del pacchetto e' 512byte.*/#define USB_BLKOUT3_LENGTH      0x09        #define USB_BLKOUT3_ADDR        0x03     #define USB_BLKOUT3_ATTR        0x02#define USB_BLKOUT3_MAXPCKSZ    0x40     ??????#define USB_BLKOUT3_INTERVAL    0x00/* Printer Bulk-IN Endpoint Descriptor definitions */#define USB_BLKIN2_LENGTH       0x09#define USB_BLKIN2_ADDR         0x82#define USB_BLKIN2_ATTR         0x02#define USB_BLKIN2_MAXPCKSZ     0x40#define USB_BLKIN2_INTERVAL     0x00#define USB_BLKIN4_LENGTH       0x09#define USB_BLKIN4_ADDR         0x84#define USB_BLKIN4_ATTR         0x02#define USB_BLKIN4_MAXPCKSZ     0x40#define USB_BLKIN4_INTERVAL     0x00    /* * String Descriptor (TBD) */#define LANGID              0x0409  /* English is 0009, neutral is 0000 */#if 0typedef enum _TRANSFER_STATE{  TransferState_NoState=0,  TransferState_Ready,  TransferState_Busy,} TRANSFER_STATE; //stTranferState;#define ENDPOINT_COUNT 3typedef struct _ENDPOINT_TX_INFO{  U8 *pPkt;       // point to the packet being transfer  U8 *pPktStart;  // point to the start of the packet  U32 XferRemain; // Bytes remaining in tranfer  TRANSFER_STATE State; // enumState;  // State of a transfer  //stTransferState enumState;  // State of a transfer  Boolean UsingEpTransfer;  U32 MaxPktSize;} EPXFERINFO, *pEPXFERINFO;EPXFERINFO  EpXferInfo[3];#define BULKOUT 1#define BULKIN    2#endif#ifdef     __cplusplus}                       /* C declarations in C++     */#endif#endif  // __USB_HEADER         

⌨️ 快捷键说明

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