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*/
26 #define USB_MAX_PACKET 16
28 /*****************************************************/
29 /*** Static data structures for device descriptors ***/
30 /*****************************************************/
32 #define USB_VENDOR_ID 0x1669 /* PiKRON.com registered number */
34 #ifndef USB_PRODUCT_ID
35 #define USB_PRODUCT_ID 0x1011 /* test code for ULAD21 */
37 #define USB_RELEASE_VER 0x0010
39 /*** Class codes for device description ***/
40 #define USB_CLASS_CODE 0xFF
41 #define USB_SUBCLASS_CODE 0x00
42 #define USB_PROTOCOL_CODE 0x00
45 #define NUM_ENDPOINTS 2
46 #define CONFIG_DESCRIPTOR_LENGTH sizeof( USB_CONFIGURATION_DESCRIPTOR) \
47 + sizeof( USB_INTERFACE_DESCRIPTOR) \
48 + ( NUM_ENDPOINTS * sizeof( USB_ENDPOINT_DESCRIPTOR))
50 /*** Device descriptor ***/
51 CODE const USB_DEVICE_DESCRIPTOR DeviceDescription = {
52 sizeof( USB_DEVICE_DESCRIPTOR),
53 USB_DESCRIPTOR_TYPE_DEVICE,
60 SWAP( USB_PRODUCT_ID),
61 SWAP( USB_RELEASE_VER),
62 1, /* manufacturer string ID */
63 2, /* product string ID */
64 3, /* serial number string ID */
68 /*** All In Configuration 0 ***/
70 USB_CONFIGURATION_DESCRIPTOR configuration;
71 USB_INTERFACE_DESCRIPTOR interface;
72 USB_ENDPOINT_DESCRIPTOR endpoint_tx;
73 USB_ENDPOINT_DESCRIPTOR endpoint_rx;
74 } ConfigDescription = {
75 /*** Configuration descriptor ***/
77 sizeof( USB_CONFIGURATION_DESCRIPTOR),
78 USB_DESCRIPTOR_TYPE_CONFIGURATION,
79 SWAP( CONFIG_DESCRIPTOR_LENGTH),
80 1, /* cnt of interfaces */
81 1, /* this configuration ID */
82 4, /* config.name string ID*/
83 0x80, /* cfg, in spec is, taha bit 7 must be set to one -> 0xe0 , orig 0x60*/
84 0x32 /* device power current from host 100mA */
86 /*** Interface Descriptor ***/
88 sizeof( USB_INTERFACE_DESCRIPTOR),
89 USB_DESCRIPTOR_TYPE_INTERFACE,
90 0, /* index of this interface for SetInterface request */
91 0, /* ID alternate interface */
98 /*** Endpoint 1 - Tx,Bulk ***/
100 sizeof( USB_ENDPOINT_DESCRIPTOR),
101 USB_DESCRIPTOR_TYPE_ENDPOINT,
103 USB_ENDPOINT_TYPE_BULK,
104 SWAP( USB_MAX_PACKET),
107 /*** Endpoint 1 - Rx,Bulk ***/
109 sizeof( USB_ENDPOINT_DESCRIPTOR),
110 USB_DESCRIPTOR_TYPE_ENDPOINT,
112 USB_ENDPOINT_TYPE_BULK,
113 SWAP( USB_MAX_PACKET),
117 /*** Strings - in unicode ***/
118 CODE const char Str0Desc[] = { /* supported languages of strings */
119 4, 0x03, /* 2+2*N , N is count of supported languages */
120 0x09,0x04 /* english 0x0409 */
123 CODE const char Str1Desc[] = { /* 1 = manufacturer */
148 CODE const char Str2Desc[] = { /* 2 = product */
173 CODE const char Str3Desc[] = { /* 3 = version */
188 CODE const char Str4Desc[] = { /* 4 = configuration */
207 CODE const char Str5Desc[] = { /* 5 = interface */
229 CODE const char Str6Desc[] = { /* EP1 OUT descriptor */
256 CODE const char Str7Desc[] = { /* EP1 IN descriptor */
285 /* all strings in pointers array */
286 CODE const PUSB_STRING_DESCRIPTOR StringDescriptors[] = {
287 (PUSB_STRING_DESCRIPTOR) Str0Desc,
288 (PUSB_STRING_DESCRIPTOR) Str1Desc,
289 (PUSB_STRING_DESCRIPTOR) Str2Desc,
290 (PUSB_STRING_DESCRIPTOR) Str3Desc,
291 (PUSB_STRING_DESCRIPTOR) Str4Desc,
292 (PUSB_STRING_DESCRIPTOR) Str5Desc,
293 (PUSB_STRING_DESCRIPTOR) Str6Desc,
294 (PUSB_STRING_DESCRIPTOR) Str7Desc,
297 #define CNT_STRINGS (sizeof(StringDescriptors)/sizeof(StringDescriptors[0]))
299 CODE const USB_DEVICE_CONFIGURATION_ENTRY usb_devdes_configurations[] = {
301 .pConfigDescription = &ConfigDescription.configuration,
302 .iConfigTotalLength = CONFIG_DESCRIPTOR_LENGTH
306 CODE const USB_INTERFACE_DESCRIPTOR *usb_devdes_interfaces[] = {
307 &ConfigDescription.interface
310 CODE const USB_DEVICE_DESCRIPTORS_TABLE usb_devdes_table = {
311 .pDeviceDescription = &DeviceDescription,
312 .pConfigurations = usb_devdes_configurations,
313 .pInterfaceDescriptors = usb_devdes_interfaces,
314 .pStrings = StringDescriptors,
315 .iNumStrings = CNT_STRINGS,
316 .bNumEndpoints = NUM_ENDPOINTS,
317 .bNumConfigurations = 1,
321 #endif /* USB_DEFS_MODULE */