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 0x1669 /* PIKRON company bought vendor ID */
29 #ifndef USB_PRODUCT_ID
30 #define USB_PRODUCT_ID 0x1023 /* Number reserved for RoCoN on LX_CPU1 */
32 #define USB_RELEASE_VER 0x0100
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 0
42 #define CONFIG_DESCRIPTOR_LENGTH sizeof( USB_CONFIGURATION_DESCRIPTOR) \
43 + sizeof( USB_INTERFACE_DESCRIPTOR) \
44 + ( NUM_ENDPOINTS * sizeof( USB_ENDPOINT_DESCRIPTOR))
46 /*** Device descriptor ***/
47 CODE const USB_DEVICE_DESCRIPTOR DeviceDescription = {
48 sizeof( USB_DEVICE_DESCRIPTOR),
49 USB_DESCRIPTOR_TYPE_DEVICE,
56 SWAP( USB_PRODUCT_ID),
57 SWAP( USB_RELEASE_VER),
58 1, /* manufacturer string ID */
59 2, /* product string ID */
60 3, /* serial number string ID */
64 /*** All In Configuration 0 ***/
65 #ifndef CONFIG_APP_ULAD31_WITH_DIPSW
67 #endif /*CONFIG_APP_ULAD31_WITH_DIPSW*/
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 250 /* device power current from host 500mA / 2 */
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 */
137 CODE const char Str2Desc[] = { /* 2 = product */
146 #define usb_devdes_serial_number Str3Desc
147 /* Serial number is stored in data area to be set at device start-up */
148 char Str3Desc[(1+8)*2] = { /* 3 = serial number */
160 CODE const char Str4Desc[] = { /* 4 = configuration */
179 CODE const char Str5Desc[] = { /* 5 = interface */
195 CODE const char Str6Desc[] = { /* EP1 OUT descriptor */
205 CODE const char Str7Desc[] = { /* EP2 IN descriptor */
214 /* all strings in pointers array */
215 CODE const PUSB_STRING_DESCRIPTOR StringDescriptors[] = {
216 (PUSB_STRING_DESCRIPTOR) Str0Desc,
217 (PUSB_STRING_DESCRIPTOR) Str1Desc,
218 (PUSB_STRING_DESCRIPTOR) Str2Desc,
219 (PUSB_STRING_DESCRIPTOR) Str3Desc,
220 (PUSB_STRING_DESCRIPTOR) Str4Desc,
221 (PUSB_STRING_DESCRIPTOR) Str5Desc,
222 (PUSB_STRING_DESCRIPTOR) Str6Desc,
223 (PUSB_STRING_DESCRIPTOR) Str7Desc
226 #define CNT_STRINGS (sizeof(StringDescriptors)/sizeof(StringDescriptors[0]))
228 CODE const USB_DEVICE_CONFIGURATION_ENTRY usb_devdes_configurations[] = {
230 .pConfigDescription = &ConfigDescription.configuration,
231 .iConfigTotalLength = CONFIG_DESCRIPTOR_LENGTH
235 CODE const USB_INTERFACE_DESCRIPTOR *usb_devdes_interfaces[] = {
236 &ConfigDescription.interface
239 CODE const USB_DEVICE_DESCRIPTORS_TABLE usb_devdes_table = {
240 .pDeviceDescription = &DeviceDescription,
241 .pConfigurations = usb_devdes_configurations,
242 .pInterfaceDescriptors = usb_devdes_interfaces,
243 .pStrings = StringDescriptors,
244 .iNumStrings = CNT_STRINGS,
245 .bNumEndpoints = NUM_ENDPOINTS,
246 .bNumConfigurations = 1,
250 #endif /* USB_DEFS_MODULE */