📄 usb100.h
字号:
// ----------------------------------------------------------------------------
// ATMEL Microcontroller Software Support - ROUSSET -
// ----------------------------------------------------------------------------
// DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
// DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
// File Name : usb100.h
// Object : DOC: usb_20.pdf
// Universal Serial Bus Specification: Revision 2.0,
// April 27, 2000
//
// Creation : JCB 15/apr/2005
// Modif :
// ----------------------------------------------------------------------------
#ifndef __USB100_H__
#define __USB100_H__
// Q: Should my USB device set the remote wake bit on the USB storage device抯 configuration descriptor ?
// The Windows USB storage driver does not currently use the remote wake field of the device.
// This will change, however, if USB storage devices intend to use selective suspend capabilities
// in future versions of the Windows operating system.
/* Table 8-3. Endpoint Type Values in Split Special Token */
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
/* Figure 9-2. wIndex Format when Specifying an Endpoint */
/* The Direction bit is set to zero to indicate the OUT endpoint */
/* with the specified Endpoint Number and to one to indicate the IN endpoint */
#define USB_ENDPOINT_DIRECTION_MASK 0x80
#define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
#define USB_ENDPOINT_DIRECTION_IN(addr) ( (addr) & USB_ENDPOINT_DIRECTION_MASK )
/* Figure 9-4. Information Returned by a GetStatus() Request to a Device */
#define USB_GETSTATUS_SELF_POWERED 0x01
#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
/* Table 9-5. Descriptor Types */
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
#define USB_QUALIFIER_DESCRIPTOR_TYPE 0x06
#define USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE 0x07
#define USB_INTERFACE_POWER1_DESCRIPTOR_TYPE 0x08
/* Table 9-4. Standard Request Codes */
#define USB_REQUEST_GET_STATUS 0x00
#define USB_REQUEST_CLEAR_FEATURE 0x01
/* Reserved for futur use 0x02 */
#define USB_REQUEST_SET_FEATURE 0x03
/* Reserved for futur use 0x04 */
#define USB_REQUEST_SET_ADDRESS 0x05
#define USB_REQUEST_GET_DESCRIPTOR 0x06
#define USB_REQUEST_SET_DESCRIPTOR 0x07
#define USB_REQUEST_GET_CONFIGURATION 0x08
#define USB_REQUEST_SET_CONFIGURATION 0x09
#define USB_REQUEST_GET_INTERFACE 0x0A
#define USB_REQUEST_SET_INTERFACE 0x0B
#define USB_REQUEST_SYNC_FRAME 0x0C
/* Table 9-6. Standard Feature Selectors */
#define USB_FEATURE_REMOTE_WAKEUP 0x0001
#define USB_FEATURE_ENDPOINT_HALT 0x0000
#define USB_FEATURE_TEST_MODE 0x0002
/* Table 9-7. Test Mode Selectors */
#define TEST_J 0x01
#define TEST_K 0x02
#define TEST_SEO_NAK 0x03
#define TEST_PACKET 0x04
#define TEST_FORCE_ENABLE 0x05
/* Table 9-8. Standard Device Descriptor */
#ifndef ADS_COMPIL
#pragma pack(1)
#endif
__packed typedef struct _USB_DEVICE_DESCRIPTOR
{
UCHAR bLength;
UCHAR bDescriptorType;
USHORT bcdUSB;
UCHAR bDeviceClass;
UCHAR bDeviceSubClass;
UCHAR bDeviceProtocol;
UCHAR bMaxPacketSize0;
USHORT idVendor;
USHORT idProduct;
USHORT bcdDevice;
UCHAR iManufacturer;
UCHAR iProduct;
UCHAR iSerialNumber;
UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
#ifndef ADS_COMPIL
#pragma pack()
#endif
// Table 9-9. Device_Qualifier Descriptor
// Usb Device Qualifier Descriptor
#ifndef ADS_COMPIL
#pragma pack(1)
typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR
#else
__packed typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR
#endif
{
UCHAR bLength; // Size of this descriptor in bytes
UCHAR bDescriptorType; // Device Qualifier descriptor type
USHORT bscUSB; // Binay Coded Decimal Spec. release
UCHAR bDeviceClass; // Class code assigned by the USB
UCHAR bDeviceSubClass; // Sub-class code assigned by the USB
UCHAR bDeviceProtocol; // Protocol code assigned by the USB
UCHAR bMaxPacketSize0; // Max packet size for EP0
UCHAR bNumConfigurations; // Number of possible configurations
UCHAR bReserved; // Reserved for future use, must be zero
} USB_DEVICE_QUALIFIER_DESCRIPTOR;
#ifndef ADS_COMPIL
#pragma pack()
#endif
// 9.6.4 Other_Speed_Configuration, Table 9-11, usb_20.pdf
#ifndef ADS_COMPIL
#pragma pack(1)
typedef struct _USB_DEVICE_OTHER_SPEED_CONFIGURATION
#else
__packed typedef struct _USB_DEVICE_OTHER_SPEED_CONFIGURATION
#endif
{
UCHAR bLength; // Size of this descriptor in bytes
UCHAR bDescriptorType; // Other_speed_Configuration Type
USHORT wTotalLength; // Total length of data returned
UCHAR bNumInterfaces; // Number of interfaces supported by this speed configuration
UCHAR bConfigurationValue; // Value to use to select configuration
UCHAR iConfiguration; // Index of string descriptor
UCHAR bmAttributes; //
UCHAR bMaxPower; // Same as Configuration descriptor
UCHAR bDivers[23];
} USB_DEVICE_OTHER_SPEED_CONFIGURATION;
#ifndef ADS_COMPIL
#pragma pack()
#endif
/* Definitions for bits in the bmAttributes field of */
/* (Table 9-10) Standard Configuration Descriptor */
/* Reserved (reset to zero) */ /* D4...D0 */
#define USB_CONFIG_BUS_NOWAKEUP 0x80 /* D5=0 + D6=0 + D7=1 */
#define USB_CONFIG_SELF_NOWAKEUP 0xC0 /* D5=0 + D6=1 + D7=1 */
#define USB_CONFIG_BUS_WAKEUP 0xA0 /* D5=1 + D6=0 + D7=1 */
#define USB_CONFIG_SELF_WAKEUP 0xE0 /* D5=1 + D6=1 + D7=1 */
/* Reserved (set to one) */ /* D7 */
/* Table 9-10. Standard Configuration Descriptor */
#ifndef ADS_COMPIL
#pragma pack(1)
struct _USB_CONFIGURATION_DESCRIPTOR
#else
__packed struct _USB_CONFIGURATION_DESCRIPTOR
#endif
{
UCHAR bLength;
UCHAR bDescriptorType;
USHORT wTotalLength;
UCHAR bNumInterfaces;
UCHAR bConfigurationValue;
UCHAR iConfiguration;
UCHAR bmAttributes;
UCHAR MaxPower;
};
#ifndef ADS_COMPIL
#pragma pack()
#endif
typedef struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
// Table 2.1 - SubClassCodes Mapped to Command Block Specifications, usb_msc_overview_1.2.pdf
#define SUBCLASSCODE_RBC 0x01
#define SUBCLASSCODE_SFF_MCC 0x02
#define SUBCLASSCODE_QIC 0x03
#define SUBCLASSCODE_UFI 0x04
#define SUBCLASSCODE_SFF 0x05
#define SUBCLASSCODE_SCSI 0x06
// Reserved for futur use 0x07 - 0xFF
// Table 3.1 - Mass Storage Transport Protocol, usb_msc_overview_1.2.pdf
#define PROTOCOL_CRTL_BULK_IT_WITH_COMPL 0x00
#define PROTOCOL_CRTL_BULK_IT_NO_COMPL 0x01
#define PROTOCOL_BULK_ONLY_TRANSPORT 0x50
// Reserved 0x02 - 0x4F
// Reserved 0x51 - 0xFF
/* Table 9-12. Standard Interface Descriptor */
#ifndef ADS_COMPIL
#pragma pack(1)
struct _USB_INTERFACE_DESCRIPTOR
#else
__packed struct _USB_INTERFACE_DESCRIPTOR
#endif
{
UCHAR bLength; // Size of this descriptor in bytes
UCHAR bDescriptorType; // INTERFACE Descriptor Type
UCHAR bInterfaceNumber; // Number of this interface.
UCHAR bAlternateSetting; // Value used to select this alternate setting for the interface identified in the prior field
UCHAR bNumEndpoints; // Number of endpoints used by this interface (excluding endpoint zero)
UCHAR bInterfaceClass; // Class code (assigned by the USB-IF).
UCHAR bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
UCHAR bInterfaceProtocol; // Protocol code (assigned by the USB).
UCHAR iInterface; // Index of string descriptor describing this interface
};
#ifndef ADS_COMPIL
#pragma pack()
#endif
typedef struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
/* Table 9-13. Standard Endpoint Descriptor */
#ifndef ADS_COMPIL
#pragma pack(1)
struct _USB_ENDPOINT_DESCRIPTOR
#else
__packed struct _USB_ENDPOINT_DESCRIPTOR
#endif
{
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bEndpointAddress;
UCHAR bmAttributes;
USHORT wMaxPacketSize;
UCHAR bInterval;
};
#ifndef ADS_COMPIL
#pragma pack()
#endif
typedef struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
/* Table 9-15. String Descriptor Zero, */
/* Specifying Languages Supported by the Device */
typedef struct _USB_STRING_DESCRIPTOR
{
UCHAR bLength;
UCHAR bDescriptorType;
UCHAR bString[1];
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
/* Table 11-13. Hub Descriptor */
typedef struct _USB_HUB_DESCRIPTOR
{
UCHAR bDescriptorLength; /* Length of this descriptor */
UCHAR bDescriptorType; /* Hub configuration type */
UCHAR bNumberOfPorts; /* number of ports on this hub */
USHORT wHubCharacteristics; /* Hub Charateristics */
UCHAR bPowerOnToPowerGood; /* port power on till power good in 2ms */
UCHAR bHubControlCurrent; /* max current in mA */
/* room for 255 ports power control and removable bitmask */
UCHAR bRemoveAndPowerMask[64];
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
/* Table 2: USB DWG Class support in Windows */
/* USB Class Drivers */
/* http://www.microsoft.com/whdc/system/bus/usb/USBFAQ_intro.mspx */
/* Which USB DWG Classes are supported by Microsoft ? */
#define USB_DEVICE_CLASS_RESERVED 0x00
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_MODEM_CDC 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE_HID 0x03
#define USB_DEVICE_CLASS_MONITOR 0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
#define USB_DEVICE_CLASS_SCANNING_PTP 0x06
#define USB_DEVICE_CLASS_PRINTER 0x07
#define USB_DEVICE_CLASS_MASS_STORAGE_MSC 0x08
#define USB_DEVICE_CLASS_HUB 0x09
/* Chip/smart card interface devices (CCID) 0x0B */
/* Video class (UVC) 0x0E */
/* Bluetooth class 0xE0 */
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
#endif /* __USB100_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -