2 #ifndef USB_DEFS_MODULE
3 #define USB_DEFS_MODULE
5 #include <usb/usb_spec.h>
6 #include <usb/lpcusb.h>
11 #if __BYTE_ORDER == __BIG_ENDIAN
13 #define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
14 #else /*__LITTLE_ENDIAN*/
22 /*****************************************************/
23 /*** Static data structures for device descriptors ***/
24 /*****************************************************/
25 #define USB_VENDOR_ID 0x1669 /* PIKRON company bought vendor ID */
26 #define USB_PRODUCT_ID 0x1023 /* Number reserved for RoCoN on LX_CPU1 */
27 #define USB_RELEASE_VER 0x0100
29 /*** Class codes for device description ***/
30 #define USB_CLASS_CODE 0xFF
31 #define USB_SUBCLASS_CODE 0x00
32 #define USB_PROTOCOL_CODE 0x00
34 #define NUM_ENDPOINTS 2
36 /*** Device descriptor ***/
37 CODE const USB_DEVICE_DESCRIPTOR DeviceDescription =
39 sizeof(USB_DEVICE_DESCRIPTOR),
40 USB_DESCRIPTOR_TYPE_DEVICE,
48 SWAP(USB_RELEASE_VER),
49 1, /* manufacturer string ID */
50 2, /* product string ID */
51 3, /* serial number string ID */
55 /*** All In Configuration 0 ***/
58 USB_CONFIGURATION_DESCRIPTOR configuration;
59 USB_INTERFACE_DESCRIPTOR interface;
60 USB_ENDPOINT_DESCRIPTOR endpoint_tx;
61 USB_ENDPOINT_DESCRIPTOR endpoint_rx;
64 /*** Configuration descriptor ***/
66 sizeof(USB_CONFIGURATION_DESCRIPTOR),
67 USB_DESCRIPTOR_TYPE_CONFIGURATION,
68 sizeof(ConfigDescription),
69 1, /* cnt of interfaces */
70 1, /* this configuration ID */
71 4, /* config.name string ID */
72 0x80, /* cfg, in spec is, taha bit 7 must be set to one -> 0xe0 , orig 0x60*/
73 250 /* device power current from host 500mA / 2 */
75 /*** Interface Descriptor ***/
77 sizeof(USB_INTERFACE_DESCRIPTOR),
78 USB_DESCRIPTOR_TYPE_INTERFACE,
79 0, /* index of this interface for SetInterface request */
80 0, /* ID alternate interface */
87 /*** Endpoint 1 - Rx,Bulk ***/
89 sizeof(USB_ENDPOINT_DESCRIPTOR),
90 USB_DESCRIPTOR_TYPE_ENDPOINT,
92 USB_ENDPOINT_TYPE_BULK,
96 /*** Endpoint 1 - Tx,Bulk ***/
98 sizeof(USB_ENDPOINT_DESCRIPTOR),
99 USB_DESCRIPTOR_TYPE_ENDPOINT,
101 USB_ENDPOINT_TYPE_BULK,
102 SWAP(USB_MAX_PACKET),
106 /*** Strings - in unicode ***/
107 CODE const char Str0Desc[] = /* supported languages of strings */
109 4, 0x03, /* 2+2*N , N is count of supported languages */
110 0x09, 0x04 /* english 0x0409 */
113 CODE const char Str1Desc[] = /* 1 = manufacturer */
129 CODE const char Str2Desc[] = /* 2 = product */
139 #define usb_devdes_serial_number Str3Desc
140 /* Serial number is stored in data area to be set at device start-up */
141 char Str3Desc[(1 + 8) * 2] = /* 3 = serial number */
154 CODE const char Str4Desc[] = /* 4 = configuration */
174 CODE const char Str5Desc[] = /* 5 = interface */
191 /* all strings in pointers array */
192 CODE const PUSB_STRING_DESCRIPTOR StringDescriptors[] =
194 (PUSB_STRING_DESCRIPTOR) Str0Desc,
195 (PUSB_STRING_DESCRIPTOR) Str1Desc,
196 (PUSB_STRING_DESCRIPTOR) Str2Desc,
197 (PUSB_STRING_DESCRIPTOR) Str3Desc,
198 (PUSB_STRING_DESCRIPTOR) Str4Desc,
199 (PUSB_STRING_DESCRIPTOR) Str5Desc
202 #define CNT_STRINGS (sizeof(StringDescriptors)/sizeof(StringDescriptors[0]))
204 CODE const USB_DEVICE_CONFIGURATION_ENTRY usb_devdes_configurations[] =
207 .pConfigDescription = &ConfigDescription.configuration,
208 .iConfigTotalLength = sizeof(ConfigDescription)
212 CODE const USB_INTERFACE_DESCRIPTOR *usb_devdes_interfaces[] =
214 &ConfigDescription.interface
217 CODE const USB_DEVICE_DESCRIPTORS_TABLE usb_devdes_table =
219 .pDeviceDescription = &DeviceDescription,
220 .pConfigurations = usb_devdes_configurations,
221 .pInterfaceDescriptors = usb_devdes_interfaces,
222 .pStrings = StringDescriptors,
223 .iNumStrings = CNT_STRINGS,
224 .bNumEndpoints = NUM_ENDPOINTS,
225 .bNumConfigurations = 1,
229 #endif /* USB_DEFS_MODULE */