usb.h
00001 #ifndef __USB_H__6PFTDPIMZM__
00002 #define __USB_H__6PFTDPIMZM__
00003 #include <stdint.h>
00004
00005
00006
00007
00008
00009
00010 #ifdef __GNUC__
00011 #define BYTE_ALIGNED __attribute__ ((__packed__))
00012 #else
00013 #define BYTE_ALIGNED
00014 #endif
00015
00016 #define LOW_BYTE(x) ((unsigned char)x)
00017 #define HIGH_BYTE(x) ((unsigned char)(x>>8))
00018
00019 typedef uint8_t Uchar;
00020 typedef uint16_t Uint16;
00021 typedef uint32_t Uint32;
00022
00023
00024
00025 #define GET_STATUS 0x00
00026 #define GET_DEVICE 0x01
00027 #define CLEAR_FEATURE 0x01
00028 #define GET_STRING 0x03
00029 #define SET_FEATURE 0x03
00030 #define SET_ADDRESS 0x05
00031 #define GET_DESCRIPTOR 0x06
00032 #define SET_DESCRIPTOR 0x07
00033 #define GET_CONFIGURATION 0x08
00034 #define SET_CONFIGURATION 0x09
00035 #define GET_INTERFACE 0x0A
00036 #define SET_INTERFACE 0x0B
00037 #define SYNCH_FRAME 0x0C
00038
00039 #define GET_DEVICE_DESCRIPTOR 1
00040 #define GET_CONFIGURATION_DESCRIPTOR 4
00041
00042 #define REQUEST_DEVICE_STATUS 0x80
00043 #define REQUEST_INTERFACE_STATUS 0x81
00044 #define REQUEST_ENDPOINT_STATUS 0x82
00045 #define ZERO_TYPE 0x00
00046 #define INTERFACE_TYPE 0x01
00047 #define ENDPOINT_TYPE 0x02
00048
00049
00050
00051 #define DEVICE 0x01
00052 #define CONFIGURATION 0x02
00053 #define STRING 0x03
00054 #define INTERFACE 0x04
00055 #define ENDPOINT 0x05
00056
00057
00058 #define HID 0x21
00059 #define REPORT 0x22
00060
00061
00062
00063
00064 #define DEVICE_REMOTE_WAKEUP_FEATURE 0x01
00065 #define ENDPOINT_HALT_FEATURE 0x00
00066
00067
00068
00069 #define SELF_POWERED 1
00070
00071
00072
00073 #define ATTACHED 0
00074 #define POWERED 1
00075 #define DEFAULT 2
00076 #define ADDRESSED 3
00077 #define CONFIGURED 4
00078 #define SUSPENDED 5
00079
00080 #define USB_CONFIG_BUSPOWERED 0x80
00081 #define USB_CONFIG_SELFPOWERED 0x40
00082 #define USB_CONFIG_REMOTEWAKEUP 0x20
00083
00084
00085 #define CS_INTERFACE 0x24
00086 #define CS_ENDPOINT 0x25
00087
00088
00089
00090
00091 struct USB_request_st
00092 {
00093 Uchar bmRequestType;
00094 Uchar bRequest;
00095 Uint16 wValue;
00096 Uint16 wIndex;
00097 Uint16 wLength;
00098 };
00099
00100
00101
00102
00103 struct usb_st_device_descriptor
00104 {
00105 Uchar bLength;
00106 Uchar bDescriptorType;
00107 Uint16 bscUSB;
00108 Uchar bDeviceClass;
00109 Uchar bDeviceSubClass;
00110 Uchar bDeviceProtocol;
00111 Uchar bMaxPacketSize0;
00112 Uint16 idVendor;
00113 Uint16 idProduct;
00114 Uint16 bcdDevice;
00115 Uchar iManufacturer;
00116 Uchar iProduct;
00117 Uchar iSerialNumber;
00118 Uchar bNumConfigurations;
00119 } BYTE_ALIGNED;
00120
00121
00122
00123
00124 struct usb_st_configuration_descriptor
00125 {
00126 Uchar bLength;
00127 Uchar bDescriptorType;
00128 Uint16 wTotalLength;
00129 Uchar bNumInterfaces;
00130 Uchar bConfigurationValue;
00131 Uchar iConfiguration;
00132 Uchar bmAttibutes;
00133 Uchar MaxPower;
00134 } BYTE_ALIGNED;
00135
00136
00137
00138
00139 struct usb_st_interface_descriptor
00140 {
00141 Uchar bLength;
00142 Uchar bDescriptorType;
00143 Uchar bInterfaceNumber;
00144 Uchar bAlternateSetting;
00145 Uchar bNumEndpoints;
00146 Uchar bInterfaceClass;
00147 Uchar bInterfaceSubClass;
00148 Uchar bInterfaceProtocol;
00149 Uchar iInterface;
00150 } BYTE_ALIGNED;
00151
00152
00153
00154
00155 struct usb_st_endpoint_descriptor
00156 {
00157 Uchar bLength;
00158 Uchar bDescriptorType;
00159 Uchar bEndpointAddress;
00160 Uchar bmAttributes;
00161 Uint16 wMaxPacketSize;
00162 Uchar bInterval;
00163
00164
00165 } BYTE_ALIGNED;
00166
00167
00168
00169
00170 struct usb_st_string_descriptor
00171 {
00172 Uchar bLength;
00173 Uchar bDescriptorType;
00174 Uint16 wstring[1];
00175 } BYTE_ALIGNED;
00176
00177
00178 struct usb_st_language_descriptor
00179 {
00180 Uchar bLength;
00181 Uchar bDescriptorType;
00182 Uint16 wlangid[1];
00183 } BYTE_ALIGNED;
00184
00185 #endif