1 |
/*---------------------------------------------------------------------------- |
---|
2 |
* U S B - K e r n e l |
---|
3 |
*---------------------------------------------------------------------------- |
---|
4 |
* Name: USB.H |
---|
5 |
* Purpose: USB Definitions |
---|
6 |
* Version: V1.10 |
---|
7 |
*---------------------------------------------------------------------------- |
---|
8 |
* This file is part of the uVision/ARM development tools. |
---|
9 |
* This software may only be used under the terms of a valid, current, |
---|
10 |
* end user licence from KEIL for a compatible version of KEIL software |
---|
11 |
* development tools. Nothing else gives you the right to use it. |
---|
12 |
* |
---|
13 |
* Copyright (c) 2005-2007 Keil Software. |
---|
14 |
*---------------------------------------------------------------------------*/ |
---|
15 |
|
---|
16 |
#ifndef __USB_H__ |
---|
17 |
#define __USB_H__ |
---|
18 |
|
---|
19 |
|
---|
20 |
typedef __packed union { |
---|
21 |
WORD W; |
---|
22 |
__packed struct { |
---|
23 |
BYTE L; |
---|
24 |
BYTE H; |
---|
25 |
} WB; |
---|
26 |
} WORD_BYTE; |
---|
27 |
|
---|
28 |
|
---|
29 |
/* bmRequestType.Dir */ |
---|
30 |
#define REQUEST_HOST_TO_DEVICE 0 |
---|
31 |
#define REQUEST_DEVICE_TO_HOST 1 |
---|
32 |
|
---|
33 |
/* bmRequestType.Type */ |
---|
34 |
#define REQUEST_STANDARD 0 |
---|
35 |
#define REQUEST_CLASS 1 |
---|
36 |
#define REQUEST_VENDOR 2 |
---|
37 |
#define REQUEST_RESERVED 3 |
---|
38 |
|
---|
39 |
/* bmRequestType.Recipient */ |
---|
40 |
#define REQUEST_TO_DEVICE 0 |
---|
41 |
#define REQUEST_TO_INTERFACE 1 |
---|
42 |
#define REQUEST_TO_ENDPOINT 2 |
---|
43 |
#define REQUEST_TO_OTHER 3 |
---|
44 |
|
---|
45 |
/* bmRequestType Definition */ |
---|
46 |
typedef __packed union _REQUEST_TYPE { |
---|
47 |
__packed struct _BM { |
---|
48 |
BYTE Recipient : 5; |
---|
49 |
BYTE Type : 2; |
---|
50 |
BYTE Dir : 1; |
---|
51 |
} BM; |
---|
52 |
BYTE B; |
---|
53 |
} REQUEST_TYPE; |
---|
54 |
|
---|
55 |
/* USB Standard Request Codes */ |
---|
56 |
#define USB_REQUEST_GET_STATUS 0 |
---|
57 |
#define USB_REQUEST_CLEAR_FEATURE 1 |
---|
58 |
#define USB_REQUEST_SET_FEATURE 3 |
---|
59 |
#define USB_REQUEST_SET_ADDRESS 5 |
---|
60 |
#define USB_REQUEST_GET_DESCRIPTOR 6 |
---|
61 |
#define USB_REQUEST_SET_DESCRIPTOR 7 |
---|
62 |
#define USB_REQUEST_GET_CONFIGURATION 8 |
---|
63 |
#define USB_REQUEST_SET_CONFIGURATION 9 |
---|
64 |
#define USB_REQUEST_GET_INTERFACE 10 |
---|
65 |
#define USB_REQUEST_SET_INTERFACE 11 |
---|
66 |
#define USB_REQUEST_SYNC_FRAME 12 |
---|
67 |
|
---|
68 |
/* USB GET_STATUS Bit Values */ |
---|
69 |
#define USB_GETSTATUS_SELF_POWERED 0x01 |
---|
70 |
#define USB_GETSTATUS_REMOTE_WAKEUP 0x02 |
---|
71 |
#define USB_GETSTATUS_ENDPOINT_STALL 0x01 |
---|
72 |
|
---|
73 |
/* USB Standard Feature selectors */ |
---|
74 |
#define USB_FEATURE_ENDPOINT_STALL 0 |
---|
75 |
#define USB_FEATURE_REMOTE_WAKEUP 1 |
---|
76 |
|
---|
77 |
/* USB Default Control Pipe Setup Packet */ |
---|
78 |
typedef __packed struct _USB_SETUP_PACKET { |
---|
79 |
REQUEST_TYPE bmRequestType; |
---|
80 |
BYTE bRequest; |
---|
81 |
WORD_BYTE wValue; |
---|
82 |
WORD_BYTE wIndex; |
---|
83 |
WORD wLength; |
---|
84 |
} USB_SETUP_PACKET; |
---|
85 |
|
---|
86 |
|
---|
87 |
/* USB Descriptor Types */ |
---|
88 |
#define USB_DEVICE_DESCRIPTOR_TYPE 1 |
---|
89 |
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 |
---|
90 |
#define USB_STRING_DESCRIPTOR_TYPE 3 |
---|
91 |
#define USB_INTERFACE_DESCRIPTOR_TYPE 4 |
---|
92 |
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5 |
---|
93 |
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 |
---|
94 |
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 |
---|
95 |
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 |
---|
96 |
|
---|
97 |
/* USB Device Classes */ |
---|
98 |
#define USB_DEVICE_CLASS_RESERVED 0x00 |
---|
99 |
#define USB_DEVICE_CLASS_AUDIO 0x01 |
---|
100 |
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 |
---|
101 |
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 |
---|
102 |
#define USB_DEVICE_CLASS_MONITOR 0x04 |
---|
103 |
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 |
---|
104 |
#define USB_DEVICE_CLASS_POWER 0x06 |
---|
105 |
#define USB_DEVICE_CLASS_PRINTER 0x07 |
---|
106 |
#define USB_DEVICE_CLASS_STORAGE 0x08 |
---|
107 |
#define USB_DEVICE_CLASS_HUB 0x09 |
---|
108 |
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF |
---|
109 |
|
---|
110 |
/* bmAttributes in Configuration Descriptor */ |
---|
111 |
#define USB_CONFIG_POWERED_MASK 0xC0 |
---|
112 |
#define USB_CONFIG_BUS_POWERED 0x80 |
---|
113 |
#define USB_CONFIG_SELF_POWERED 0xC0 |
---|
114 |
#define USB_CONFIG_REMOTE_WAKEUP 0x20 |
---|
115 |
|
---|
116 |
/* bMaxPower in Configuration Descriptor */ |
---|
117 |
#define USB_CONFIG_POWER_MA(mA) ((mA)/2) |
---|
118 |
|
---|
119 |
/* bEndpointAddress in Endpoint Descriptor */ |
---|
120 |
#define USB_ENDPOINT_DIRECTION_MASK 0x80 |
---|
121 |
#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) |
---|
122 |
#define USB_ENDPOINT_IN(addr) ((addr) | 0x80) |
---|
123 |
|
---|
124 |
/* bmAttributes in Endpoint Descriptor */ |
---|
125 |
#define USB_ENDPOINT_TYPE_MASK 0x03 |
---|
126 |
#define USB_ENDPOINT_TYPE_CONTROL 0x00 |
---|
127 |
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 |
---|
128 |
#define USB_ENDPOINT_TYPE_BULK 0x02 |
---|
129 |
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03 |
---|
130 |
#define USB_ENDPOINT_SYNC_MASK 0x0C |
---|
131 |
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 |
---|
132 |
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 |
---|
133 |
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 |
---|
134 |
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C |
---|
135 |
#define USB_ENDPOINT_USAGE_MASK 0x30 |
---|
136 |
#define USB_ENDPOINT_USAGE_DATA 0x00 |
---|
137 |
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10 |
---|
138 |
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 |
---|
139 |
#define USB_ENDPOINT_USAGE_RESERVED 0x30 |
---|
140 |
|
---|
141 |
/* USB Standard Device Descriptor */ |
---|
142 |
typedef __packed struct _USB_DEVICE_DESCRIPTOR { |
---|
143 |
BYTE bLength; |
---|
144 |
BYTE bDescriptorType; |
---|
145 |
WORD bcdUSB; |
---|
146 |
BYTE bDeviceClass; |
---|
147 |
BYTE bDeviceSubClass; |
---|
148 |
BYTE bDeviceProtocol; |
---|
149 |
BYTE bMaxPacketSize0; |
---|
150 |
WORD idVendor; |
---|
151 |
WORD idProduct; |
---|
152 |
WORD bcdDevice; |
---|
153 |
BYTE iManufacturer; |
---|
154 |
BYTE iProduct; |
---|
155 |
BYTE iSerialNumber; |
---|
156 |
BYTE bNumConfigurations; |
---|
157 |
} USB_DEVICE_DESCRIPTOR; |
---|
158 |
|
---|
159 |
/* USB 2.0 Device Qualifier Descriptor */ |
---|
160 |
typedef __packed struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { |
---|
161 |
BYTE bLength; |
---|
162 |
BYTE bDescriptorType; |
---|
163 |
WORD bcdUSB; |
---|
164 |
BYTE bDeviceClass; |
---|
165 |
BYTE bDeviceSubClass; |
---|
166 |
BYTE bDeviceProtocol; |
---|
167 |
BYTE bMaxPacketSize0; |
---|
168 |
BYTE bNumConfigurations; |
---|
169 |
BYTE bReserved; |
---|
170 |
} USB_DEVICE_QUALIFIER_DESCRIPTOR; |
---|
171 |
|
---|
172 |
/* USB Standard Configuration Descriptor */ |
---|
173 |
typedef __packed struct _USB_CONFIGURATION_DESCRIPTOR { |
---|
174 |
BYTE bLength; |
---|
175 |
BYTE bDescriptorType; |
---|
176 |
WORD wTotalLength; |
---|
177 |
BYTE bNumInterfaces; |
---|
178 |
BYTE bConfigurationValue; |
---|
179 |
BYTE iConfiguration; |
---|
180 |
BYTE bmAttributes; |
---|
181 |
BYTE bMaxPower; |
---|
182 |
} USB_CONFIGURATION_DESCRIPTOR; |
---|
183 |
|
---|
184 |
/* USB Standard Interface Descriptor */ |
---|
185 |
typedef __packed struct _USB_INTERFACE_DESCRIPTOR { |
---|
186 |
BYTE bLength; |
---|
187 |
BYTE bDescriptorType; |
---|
188 |
BYTE bInterfaceNumber; |
---|
189 |
BYTE bAlternateSetting; |
---|
190 |
BYTE bNumEndpoints; |
---|
191 |
BYTE bInterfaceClass; |
---|
192 |
BYTE bInterfaceSubClass; |
---|
193 |
BYTE bInterfaceProtocol; |
---|
194 |
BYTE iInterface; |
---|
195 |
} USB_INTERFACE_DESCRIPTOR; |
---|
196 |
|
---|
197 |
/* USB Standard Endpoint Descriptor */ |
---|
198 |
typedef __packed struct _USB_ENDPOINT_DESCRIPTOR { |
---|
199 |
BYTE bLength; |
---|
200 |
BYTE bDescriptorType; |
---|
201 |
BYTE bEndpointAddress; |
---|
202 |
BYTE bmAttributes; |
---|
203 |
WORD wMaxPacketSize; |
---|
204 |
BYTE bInterval; |
---|
205 |
} USB_ENDPOINT_DESCRIPTOR; |
---|
206 |
|
---|
207 |
/* USB String Descriptor */ |
---|
208 |
typedef __packed struct _USB_STRING_DESCRIPTOR { |
---|
209 |
BYTE bLength; |
---|
210 |
BYTE bDescriptorType; |
---|
211 |
WORD bString/*[]*/; |
---|
212 |
} USB_STRING_DESCRIPTOR; |
---|
213 |
|
---|
214 |
/* USB Common Descriptor */ |
---|
215 |
typedef __packed struct _USB_COMMON_DESCRIPTOR { |
---|
216 |
BYTE bLength; |
---|
217 |
BYTE bDescriptorType; |
---|
218 |
} USB_COMMON_DESCRIPTOR; |
---|
219 |
|
---|
220 |
|
---|
221 |
#endif /* __USB_H__ */ |
---|