2 * Copyright (C) 2005 Benedikt Sauter
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /*-------------------------------------------
23 * ------------------------------------------*/
24 struct usb_device_descriptor
26 unsigned char bLength;
27 unsigned char bDescriptorType;
28 unsigned short bcdUSB;
29 unsigned char bDeviceClass;
30 unsigned char bDeviceSubClass;
31 unsigned char bDeviceProtocol;
32 unsigned char bMaxPacketSize0;
33 unsigned short idVendor;
34 unsigned short idProduct;
35 unsigned short bcdDevice;
36 unsigned char iManufacturer;
37 unsigned char iProduct;
38 unsigned char iSerialNumber;
39 unsigned char bNumConfigurations;
42 /*-------------------------------------------
43 * configuration descriptor
44 * ------------------------------------------*/
46 struct usb_configuration_descriptor
48 unsigned char bLength;
49 unsigned char bDescriptorType;
50 unsigned short wTotalLength;
51 unsigned char bNumInterfaces;
52 unsigned char bConfigurationValue;
53 unsigned char iConfiguration;
54 unsigned char bmAttributes;
55 unsigned char MaxPower;
58 /*-------------------------------------------
59 * interface descriptor
60 * ------------------------------------------*/
62 struct usb_interface_descriptor
64 unsigned char bLength;
65 unsigned char bDescriptorType;
66 unsigned char bInterfaceNumber;
67 unsigned char bAlternateSetting;
68 unsigned char bNumEndpoints;
69 unsigned char bInterfaceClass;
70 unsigned char bInterfaceSubClass;
71 unsigned char bInterfaceProtocol;
72 unsigned char iInterface;
76 /*-------------------------------------------
78 * ------------------------------------------*/
79 struct usb_endpoint_descriptor
81 unsigned char bLength;
82 unsigned char bDescriptorType;
83 unsigned char bEndpointAddress;
84 unsigned char bmAttributes;
85 unsigned short wMaxPacketSize;
86 unsigned char bIntervall;
91 /*-------------------------------------------
93 * ------------------------------------------*/
94 struct usb_string_descriptor
96 unsigned char bLength;
97 unsigned char bDescriptorType;
98 unsigned char* String;
104 /*-------------------------------------------
106 * ------------------------------------------*/
107 typedef struct usb_device_request_t usb_device_request;
108 struct usb_device_request_t
110 unsigned char bmRequestType;
111 unsigned char bRequest;
112 unsigned short wValue;
113 unsigned short wIndex;
114 unsigned short wLength;
117 /*-------------------------------------------
118 * Get Device Descriptor Request
119 * ------------------------------------------*/
120 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
121 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
122 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, address, 0x00,0x00,0x00,0x40};
123 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, 0x00, 0x00,0x00,0x00,0x00};
126 /*------------------------------------------
128 * ------------------------------------------*/
130 #define USB_CTRL 0x00
131 #define USB_ISOC 0x01
132 #define USB_BULK 0x02
133 #define USB_INTR 0x03
135 /*-------------------------------------------
136 * device descriptor types
137 * ------------------------------------------*/
138 #define DO_STANDARD 0x00
139 #define DO_CLASS 0x20
140 #define DO_VENDOR 0x40
142 /*-------------------------------------------
143 * standard requests for ep0
144 * ------------------------------------------*/
146 #define GET_STATUS 0x00
147 #define CLR_FEATURE 0x01
148 #define SET_FEATURE 0x03
149 #define SET_ADDRESS 0x05
150 #define GET_DESCRIPTOR 0x06
151 #define SET_DESCRIPTOR 0x07
152 #define GET_CONFIGURATION 0x08
153 #define SET_CONFIGURATION 0x09
154 #define GET_INTERFACE 0x0A
155 #define SET_INTERFACE 0x0B
157 /*-------------------------------------------
159 * ------------------------------------------*/
162 #define CONFIGURATION 0x02
164 #define INTERFACE 0x04
165 #define ENDPOINT 0x05
166 #define DEVICEQUALIFIER 0x06 // only usb2.0
167 #define OTHERSPEEDCONFIGURATION 0x07 // only usb2.0
170 /*-------------------------------------------
172 * ------------------------------------------*/
174 #define USB_PID_SOF 0x05
175 #define USB_PID_SETUP 0x0D
176 #define USB_PID_IN 0x09
177 #define USB_PID_OUT 0x01
178 #define USB_PID_DATA0 0x03
179 #define USB_PID_DATA1 0x0B
180 #define USB_PID_ACK 0x02
181 #define USB_PID_NACK 0x0A
182 #define USB_PID_STALL 0x0E
183 #define USB_PID_PRE 0x0C
186 #define MASS_STORAGE_CLASSCODE 0x08
187 #define HUB_CLASSCODE 0x09
191 #endif /* __USB11SPEC_H__ */