1 /******************************************************************************
2 ** File Name: USB200.h *
3 ** Author: Daniel.Ding *
5 ** Copyright: 2005 Spreatrum, Incoporated. All Rights Reserved. *
7 ******************************************************************************/
8 /******************************************************************************
10 **---------------------------------------------------------------------------*
11 ** DATE NAME DESCRIPTION *
12 ** 9/1/2003 Daniel.Ding Create. *
13 ******************************************************************************/
14 #ifndef _USB200_FDL_H_
15 #define _USB200_FDL_H_
16 /*----------------------------------------------------------------------------*
18 **-------------------------------------------------------------------------- */
21 /**---------------------------------------------------------------------------*
23 **---------------------------------------------------------------------------*/
28 /**----------------------------------------------------------------------------*
30 **----------------------------------------------------------------------------*/
31 #define MAXIMUM_USB_STRING_LENGTH 255
33 #define USB_GETSTATUS_SELF_POWERED 0x01
34 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
37 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
38 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
39 #define USB_STRING_DESCRIPTOR_TYPE 0x03
40 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
41 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
42 #define USB_POWER_DESCRIPTOR_TYPE 0x06
44 #define STR_INDEX_LANGUAGE 0x00
45 #define STR_INDEX_MANUFACTURER 0x01
46 #define STR_INDEX_PRODUCT 0x02
47 #define STR_INDEX_SERIALNUMBER 0x03
48 #define STR_INDEX_CONFIGURATION 0x04
49 #define STR_INDEX_INTERFACE 0x05
51 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((short)((short)d<<8 | i))
54 // Values for bmAttributes field of an
55 // endpoint descriptor
58 #define USB_ENDPOINT_TYPE_MASK 0x03
60 #define USB_ENDPOINT_TYPE_CONTROL 0x00
61 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
62 #define USB_ENDPOINT_TYPE_BULK 0x02
63 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
67 // definitions for bits in the bmAttributes field of a
68 // configuration descriptor.
70 #define USB_CONFIG_POWERED_MASK 0xc0
72 #define USB_CONFIG_BUS_POWERED 0x80
73 #define USB_CONFIG_SELF_POWERED 0x40
74 #define USB_CONFIG_REMOTE_WAKEUP 0x20
77 // Endpoint direction bit, stored in address
80 #define USB_ENDPOINT_DIRECTION_MASK 0x80
82 // test direction bit in the bEndpointAddress field of
83 // an endpoint descriptor.
84 #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
85 #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
88 // USB defined request codes
89 // see chapter 9 of the USB 1.0 specifcation for
93 // These are the correct values based on the USB 1.0
96 #define USB_REQUEST_GET_STATUS 0x00
97 #define USB_REQUEST_CLEAR_FEATURE 0x01
99 #define USB_REQUEST_SET_FEATURE 0x03
101 #define USB_REQUEST_SET_ADDRESS 0x05
102 #define USB_REQUEST_GET_DESCRIPTOR 0x06
103 #define USB_REQUEST_SET_DESCRIPTOR 0x07
104 #define USB_REQUEST_GET_CONFIGURATION 0x08
105 #define USB_REQUEST_SET_CONFIGURATION 0x09
106 #define USB_REQUEST_GET_INTERFACE 0x0A
107 #define USB_REQUEST_SET_INTERFACE 0x0B
108 #define USB_REQUEST_SYNC_FRAME 0x0C
112 // defined USB device classes
116 #define USB_DEVICE_CLASS_RESERVED 0x00
117 #define USB_DEVICE_CLASS_AUDIO 0x01
118 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
119 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
120 #define USB_DEVICE_CLASS_MONITOR 0x04
121 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
122 #define USB_DEVICE_CLASS_POWER 0x06
123 #define USB_DEVICE_CLASS_PRINTER 0x07
124 #define USB_DEVICE_CLASS_STORAGE 0x08
125 #define USB_DEVICE_CLASS_HUB 0x09
126 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
129 // USB defined Feature selectors
132 #define USB_FEATURE_ENDPOINT_STALL 0x0000
133 #define USB_FEATURE_REMOTE_WAKEUP 0x0001
134 #define USB_FEATURE_POWER_D0 0x0002
135 #define USB_FEATURE_POWER_D1 0x0003
136 #define USB_FEATURE_POWER_D2 0x0004
137 #define USB_FEATURE_POWER_D3 0x0005
141 #define HOST_IN 0x01 //From device to host ;
142 #define HOST_OUT 0x00 //From host to device ;
144 //Define request type;
145 #define USB_REQ_STANDARD 0x00
146 #define USB_REQ_CLASS 0x01
147 #define USB_REQ_VENDOR 0x02
148 #define USB_REQ_RESERVED 0x03
151 #define USB_REC_DEVICE 0x00
152 #define USB_REC_INTERFACE 0x01
153 #define USB_REC_ENDPOINT 0x02
154 #define USB_REC_OTHER 0x03
156 #define USB_MAX_REQ_TYPE 0x04
157 #define USB_MAX_RECIPIENT 0x05
158 #define USB_MAX_REQUEST 0x30
160 #define BUS_POWERED 0x80
161 #define SELF_POWERED 0x40
162 #define REMOTE_WAKEUP 0x20
165 // USB power descriptor added to core specification
168 #define USB_SUPPORT_D0_COMMAND 0x01
169 #define USB_SUPPORT_D1_COMMAND 0x02
170 #define USB_SUPPORT_D2_COMMAND 0x04
171 #define USB_SUPPORT_D3_COMMAND 0x08
173 #define USB_SUPPORT_D1_WAKEUP 0x10
174 #define USB_SUPPORT_D2_WAKEUP 0x20
176 #define USB_CLEAR_COMM_FEATURE 0x04
177 #define USB_GET_COMM_FEATURE 0x03
178 #define USB_SET_COMM_FEATURE 0x02
179 /**----------------------------------------------------------------------------*
181 **----------------------------------------------------------------------------*/
182 //Stand USB device request command type define ;
183 typedef union _USB_STD_DEV_REQ_T
215 //Four bytes buildup a 32bit value ;
216 typedef union _USB_DWORD_U
233 //Two bytes buildup a 16bit value ;
234 typedef union _USB_WORD_U
249 // values for bmAttributes Field in
250 // USB_CONFIGURATION_DESCRIPTOR
255 // Standard USB HUB definitions
259 typedef struct _USB_DEVICE_DESCRIPTOR
262 char bDescriptorType;
265 char bDeviceSubClass;
266 char bDeviceProtocol;
267 char bMaxPacketSize0;
274 char bNumConfigurations;
275 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
277 typedef struct _USB_CONFIGURATION_DESCRIPTOR
280 char bDescriptorType;
283 char bConfigurationValue;
287 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
289 typedef struct _USB_INTERFACE_DESCRIPTOR
292 char bDescriptorType;
293 char bInterfaceNumber;
294 char bAlternateSetting;
296 char bInterfaceClass;
297 char bInterfaceSubClass;
298 char bInterfaceProtocol;
300 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
302 typedef struct _USB_STRING_DESCRIPTOR
305 char bDescriptorType;
307 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
309 typedef struct _USB_ENDPOINT_DESCRIPTOR
312 char bDescriptorType;
313 union _bEndpointAddress
334 short wMaxPacketSize;
336 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
339 typedef struct _USB_HUB_DESCRIPTOR
341 char bDescriptorLength; // Length of this descriptor
342 char bDescriptorType; // Hub configuration type
343 char bNumberOfPorts; // number of ports on this hub
344 short wHubCharacteristics; // Hub Charateristics
345 char bPowerOnToPowerGood; // port power on till power good in 2ms
346 char bHubControlCurrent; // max current in mA
348 // room for 255 ports power control and removable bitmask
349 char bRemoveAndPowerMask[64];
350 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
353 typedef struct _USB_STRING_LANGUAGE_DESCRIPTOR
356 char bDescriptorType;
358 } USB_STRING_LANGUAGE_DESCRIPTOR,*PUSB_STRING_LANGUAGE_DESCRIPTOR;
360 typedef struct _USB_STRING_INTERFACE_DESCRIPTOR
363 char bDescriptorType;
365 } USB_STRING_INTERFACE_DESCRIPTOR,*PUSB_STRING_INTERFACE_DESCRIPTOR;
367 typedef struct _USB_STRING_CONFIGURATION_DESCRIPTOR
370 char bDescriptorType;
371 char Configuration[16];
372 } USB_STRING_CONFIGURATION_DESCRIPTOR,*PUSB_STRING_CONFIGURATION_DESCRIPTOR;
374 typedef struct _USB_STRING_SERIALNUMBER_DESCRIPTOR
377 char bDescriptorType;
379 } USB_STRING_SERIALNUMBER_DESCRIPTOR,*PUSB_STRING_SERIALNUMBER_DESCRIPTOR;
381 typedef struct _USB_STRING_PRODUCT_DESCRIPTOR
384 char bDescriptorType;
386 } USB_STRING_PRODUCT_DESCRIPTOR,*PUSB_STRING_PRODUCT_DESCRIPTOR;
388 typedef struct _USB_STRING_MANUFACTURER_DESCRIPTOR
391 char bDescriptorType;
392 char Manufacturer[24];
393 } USB_STRING_MANUFACTURER_DESCRIPTOR,*PUSB_STRING_MANUFACTURER_DESCRIPTOR;
395 typedef struct _USB_POWER_DESCRIPTOR
398 char bDescriptorType;
399 char bCapabilitiesFlags;
400 short EventNotification;
405 short D0PowerConsumption;
406 short D1PowerConsumption;
407 short D2PowerConsumption;
408 } USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;
411 typedef struct _USB_COMMON_DESCRIPTOR
414 char bDescriptorType;
415 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
417 /**----------------------------------------------------------------------------*
418 ** Local Function Prototype **
419 **----------------------------------------------------------------------------*/
421 /**----------------------------------------------------------------------------*
422 ** Function Prototype **
423 **----------------------------------------------------------------------------*/
426 /**----------------------------------------------------------------------------*
428 **----------------------------------------------------------------------------*/
432 /**---------------------------------------------------------------------------*/