2 #ifndef USB_DEFS_MODULE
3 #define USB_DEFS_MODULE
5 #include <usb/usb_spec.h>
6 // #include <usb/pdiusb.h>
7 #include <usb/lpcusb.h>
12 #if __BYTE_ORDER == __BIG_ENDIAN
14 #define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
15 #else /*__LITTLE_ENDIAN*/
23 /*****************************************************/
24 /*** Static data structures for device descriptors ***/
25 /*****************************************************/
27 #define USB_VENDOR_ID 0xDEAD /* vymyslene cislo ( snad ho nikdo nema ... ;-) */
29 #ifndef USB_PRODUCT_ID
30 #define USB_PRODUCT_ID 0x1001 /* test code for ULAD21 */
32 #define USB_RELEASE_VER 0x0010
34 /*** Class codes for device description ***/
35 #define USB_CLASS_CODE 0xFF
36 #define USB_SUBCLASS_CODE 0x00
37 #define USB_PROTOCOL_CODE 0x00
40 #define NUM_ENDPOINTS 2
41 #define CONFIG_DESCRIPTOR_LENGTH sizeof( USB_CONFIGURATION_DESCRIPTOR) \
42 + sizeof( USB_INTERFACE_DESCRIPTOR) \
43 + ( NUM_ENDPOINTS * sizeof( USB_ENDPOINT_DESCRIPTOR))
45 /*** Device descriptor ***/
46 CODE const USB_DEVICE_DESCRIPTOR DeviceDescription = {
47 sizeof( USB_DEVICE_DESCRIPTOR),
48 USB_DESCRIPTOR_TYPE_DEVICE,
55 SWAP( USB_PRODUCT_ID),
56 SWAP( USB_RELEASE_VER),
57 1, /* manufacturer string ID */
58 2, /* product string ID */
59 3, /* serial number string ID */
63 /*** All In Configuration 0 ***/
65 USB_CONFIGURATION_DESCRIPTOR configuration;
66 USB_INTERFACE_DESCRIPTOR interface;
67 USB_ENDPOINT_DESCRIPTOR endpoint_tx;
68 USB_ENDPOINT_DESCRIPTOR endpoint_rx;
69 } ConfigDescription = {
70 /*** Configuration descriptor ***/
72 sizeof( USB_CONFIGURATION_DESCRIPTOR),
73 USB_DESCRIPTOR_TYPE_CONFIGURATION,
74 SWAP( CONFIG_DESCRIPTOR_LENGTH),
75 1, /* cnt of interfaces */
76 1, /* this configuration ID */
77 4, /* config.name string ID*/
78 0x80, /* cfg, in spec is, taha bit 7 must be set to one -> 0xe0 , orig 0x60*/
79 0x32 /* device power current from host 100mA */
81 /*** Interface Descriptor ***/
83 sizeof( USB_INTERFACE_DESCRIPTOR),
84 USB_DESCRIPTOR_TYPE_INTERFACE,
85 0, /* index of this interface for SetInterface request */
86 0, /* ID alternate interface */
93 /*** Endpoint 1 - Tx,Bulk ***/
95 sizeof( USB_ENDPOINT_DESCRIPTOR),
96 USB_DESCRIPTOR_TYPE_ENDPOINT,
98 USB_ENDPOINT_TYPE_BULK,
99 SWAP( USB_MAX_PACKET),
102 /*** Endpoint 1 - Rx,Bulk ***/
104 sizeof( USB_ENDPOINT_DESCRIPTOR),
105 USB_DESCRIPTOR_TYPE_ENDPOINT,
107 USB_ENDPOINT_TYPE_BULK,
108 SWAP( USB_MAX_PACKET),
112 /*** Strings - in unicode ***/
113 CODE const char Str0Desc[] = { /* supported languages of strings */
114 4, 0x03, /* 2+2*N , N is count of supported languages */
115 0x09,0x04 /* english 0x0409 */
118 CODE const char Str1Desc[] = { /* 1 = manufacturer */
145 CODE const char Str2Desc[] = { /* 2 = product */
168 CODE const char Str3Desc[] = { /* 3 = version */
183 CODE const char Str4Desc[] = { /* 4 = configuration */
202 CODE const char Str5Desc[] = { /* 5 = interface */
218 CODE const char Str6Desc[] = { /* EP1 OUT descriptor */
289 CODE const char Str7Desc[] = { /* EP2 IN descriptor */
362 CODE const char Str8Desc[] = { /* EP1 OUT descriptor */
433 #define CNT_STRINGS 0x09
435 /* all strings in pointers array */
436 CODE const PUSB_STRING_DESCRIPTOR StringDescriptors[] = {
437 (PUSB_STRING_DESCRIPTOR) Str0Desc,
438 (PUSB_STRING_DESCRIPTOR) Str1Desc,
439 (PUSB_STRING_DESCRIPTOR) Str2Desc,
440 (PUSB_STRING_DESCRIPTOR) Str3Desc,
441 (PUSB_STRING_DESCRIPTOR) Str4Desc,
442 (PUSB_STRING_DESCRIPTOR) Str5Desc,
443 (PUSB_STRING_DESCRIPTOR) Str6Desc,
444 (PUSB_STRING_DESCRIPTOR) Str7Desc,
445 (PUSB_STRING_DESCRIPTOR) Str8Desc
448 #endif /* USB_DEFS_MODULE */