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*/
25 #define USB_MAX_PACKET 16
27 /*****************************************************/
28 /*** Static data structures for device descriptors ***/
29 /*****************************************************/
31 #define USB_VENDOR_ID 0x1669 /* vymyslene cislo ( snad ho nikdo nema ... ;-) */
33 #ifndef USB_PRODUCT_ID
34 #define USB_PRODUCT_ID 0x1011 /* test code for ULAD21 */
36 #define USB_RELEASE_VER 0x0010
38 /*** Class codes for device description ***/
39 #define USB_CLASS_CODE 0xFF
40 #define USB_SUBCLASS_CODE 0x00
41 #define USB_PROTOCOL_CODE 0x00
44 #define NUM_ENDPOINTS 2
45 #define CONFIG_DESCRIPTOR_LENGTH sizeof( USB_CONFIGURATION_DESCRIPTOR) \
46 + sizeof( USB_INTERFACE_DESCRIPTOR) \
47 + ( NUM_ENDPOINTS * sizeof( USB_ENDPOINT_DESCRIPTOR))
49 /*** Device descriptor ***/
50 CODE const USB_DEVICE_DESCRIPTOR DeviceDescription = {
51 sizeof( USB_DEVICE_DESCRIPTOR),
52 USB_DESCRIPTOR_TYPE_DEVICE,
59 SWAP( USB_PRODUCT_ID),
60 SWAP( USB_RELEASE_VER),
61 1, /* manufacturer string ID */
62 2, /* product string ID */
63 3, /* serial number string ID */
67 /*** All In Configuration 0 ***/
69 USB_CONFIGURATION_DESCRIPTOR configuration;
70 USB_INTERFACE_DESCRIPTOR interface;
71 USB_ENDPOINT_DESCRIPTOR endpoint_tx;
72 USB_ENDPOINT_DESCRIPTOR endpoint_rx;
73 } ConfigDescription = {
74 /*** Configuration descriptor ***/
76 sizeof( USB_CONFIGURATION_DESCRIPTOR),
77 USB_DESCRIPTOR_TYPE_CONFIGURATION,
78 SWAP( CONFIG_DESCRIPTOR_LENGTH),
79 1, /* cnt of interfaces */
80 1, /* this configuration ID */
81 4, /* config.name string ID*/
82 0x80, /* cfg, in spec is, taha bit 7 must be set to one -> 0xe0 , orig 0x60*/
83 0x32 /* device power current from host 100mA */
85 /*** Interface Descriptor ***/
87 sizeof( USB_INTERFACE_DESCRIPTOR),
88 USB_DESCRIPTOR_TYPE_INTERFACE,
89 0, /* index of this interface for SetInterface request */
90 0, /* ID alternate interface */
97 /*** Endpoint 1 - Tx,Bulk ***/
99 sizeof( USB_ENDPOINT_DESCRIPTOR),
100 USB_DESCRIPTOR_TYPE_ENDPOINT,
102 USB_ENDPOINT_TYPE_BULK,
103 SWAP( USB_MAX_PACKET),
106 /*** Endpoint 1 - Rx,Bulk ***/
108 sizeof( USB_ENDPOINT_DESCRIPTOR),
109 USB_DESCRIPTOR_TYPE_ENDPOINT,
111 USB_ENDPOINT_TYPE_BULK,
112 SWAP( USB_MAX_PACKET),
116 /*** Strings - in unicode ***/
117 CODE const char Str0Desc[] = { /* supported languages of strings */
118 4, 0x03, /* 2+2*N , N is count of supported languages */
119 0x09,0x04 /* english 0x0409 */
122 CODE const char Str1Desc[] = { /* 1 = manufacturer */
149 CODE const char Str2Desc[] = { /* 2 = product */
172 CODE const char Str3Desc[] = { /* 3 = version */
187 CODE const char Str4Desc[] = { /* 4 = configuration */
206 CODE const char Str5Desc[] = { /* 5 = interface */
222 CODE const char Str6Desc[] = { /* EP1 OUT descriptor */
293 CODE const char Str7Desc[] = { /* EP2 IN descriptor */
366 CODE const char Str8Desc[] = { /* EP1 OUT descriptor */
437 #define CNT_STRINGS 0x09
439 /* all strings in pointers array */
440 CODE const PUSB_STRING_DESCRIPTOR StringDescriptors[] = {
441 (PUSB_STRING_DESCRIPTOR) Str0Desc,
442 (PUSB_STRING_DESCRIPTOR) Str1Desc,
443 (PUSB_STRING_DESCRIPTOR) Str2Desc,
444 (PUSB_STRING_DESCRIPTOR) Str3Desc,
445 (PUSB_STRING_DESCRIPTOR) Str4Desc,
446 (PUSB_STRING_DESCRIPTOR) Str5Desc,
447 (PUSB_STRING_DESCRIPTOR) Str6Desc,
448 (PUSB_STRING_DESCRIPTOR) Str7Desc,
449 (PUSB_STRING_DESCRIPTOR) Str8Desc
452 #endif /* USB_DEFS_MODULE */