]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/app/usbcan/usb/usb_defs.h
changed usb vendor and product id.
[lincan.git] / embedded / app / usbcan / usb / usb_defs.h
1
2 #ifndef USB_DEFS_MODULE
3   #define USB_DEFS_MODULE
4
5   #include <usb/usb_spec.h>
6 //  #include <usb/pdiusb.h>
7   #include <usb/lpcusb.h>
8   #include <endian.h>
9   #include <cpu_def.h>
10
11   #include <endian.h>
12   #if __BYTE_ORDER == __BIG_ENDIAN
13     #include <byteswap.h>
14     #define SWAP(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
15   #else /*__LITTLE_ENDIAN*/
16     #define SWAP(x) (x)
17   #endif
18
19   #ifndef CODE
20     #define CODE
21   #endif
22
23         #ifdef USB_MAX_PACKET
24                 #undef USB_MAX_PACKET
25                 #define USB_MAX_PACKET 16
26         #endif
27 /*****************************************************/
28 /*** Static data structures for device descriptors ***/
29 /*****************************************************/
30 #ifndef USB_VENDOR_ID
31   #define USB_VENDOR_ID      0x1669  /* vymyslene cislo ( snad ho nikdo nema ... ;-) */
32 #endif
33 #ifndef USB_PRODUCT_ID
34   #define USB_PRODUCT_ID     0x1011  /* test code for ULAD21 */
35 #endif
36   #define USB_RELEASE_VER    0x0010
37
38 /*** Class codes for device description ***/
39   #define USB_CLASS_CODE      0xFF
40   #define USB_SUBCLASS_CODE   0x00
41   #define USB_PROTOCOL_CODE   0x00
42
43
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))
48
49 /*** Device descriptor ***/
50   CODE const USB_DEVICE_DESCRIPTOR DeviceDescription = {
51     sizeof( USB_DEVICE_DESCRIPTOR),
52     USB_DESCRIPTOR_TYPE_DEVICE,
53     SWAP( 0x0100),
54     USB_CLASS_CODE,
55     USB_SUBCLASS_CODE,
56     USB_PROTOCOL_CODE,
57     USB_MAX_PACKET0,
58     SWAP( USB_VENDOR_ID),
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 */
64     1
65   };
66
67 /*** All In Configuration 0 ***/
68   CODE const struct {
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 ***/
75     {
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 */
84     },
85     /*** Interface Descriptor ***/
86     {
87       sizeof( USB_INTERFACE_DESCRIPTOR),
88       USB_DESCRIPTOR_TYPE_INTERFACE,
89       0,    /* index of this interface for SetInterface request */
90       0,    /* ID alternate interface */
91       NUM_ENDPOINTS,
92       USB_CLASS_CODE,
93       USB_SUBCLASS_CODE,
94       USB_PROTOCOL_CODE,
95       5
96     },
97     /*** Endpoint 1 - Tx,Bulk ***/
98     {
99       sizeof( USB_ENDPOINT_DESCRIPTOR),
100       USB_DESCRIPTOR_TYPE_ENDPOINT,
101       0x01,
102       USB_ENDPOINT_TYPE_BULK,
103       SWAP( USB_MAX_PACKET),
104       0
105     },
106     /*** Endpoint 1 - Rx,Bulk ***/
107     {
108       sizeof( USB_ENDPOINT_DESCRIPTOR),
109       USB_DESCRIPTOR_TYPE_ENDPOINT,
110       0x81,
111       USB_ENDPOINT_TYPE_BULK,
112       SWAP( USB_MAX_PACKET),
113       0
114     }
115   };
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 */
120   };
121
122   CODE const char Str1Desc[] = {  /* 1 = manufacturer */
123     48,0x03,
124     'S',0,
125     'm',0,
126     'o',0,
127     'l',0,
128     'i',0,
129     'k',0,
130     ',',0,
131     'B',0,
132     'a',0,
133     'r',0,
134     't',0,
135     'o',0,
136     's',0,
137     'i',0,
138     'n',0,
139     's',0,
140     'k',0,
141     'i',0,
142     ',',0,
143     'P',0,
144     'i',0,
145     's',0,
146     'a',0
147   };
148
149   CODE const char Str2Desc[] = {  /* 2 = product */
150     38, 0x03,
151     'u',0,
152     'L',0,
153     'a',0,
154     'n',0,
155     '2',0,
156     'u',0,
157     's',0,
158     'b',0,
159     ' ',0,
160     'c',0,
161     'o',0,
162     'n',0,
163     'v',0,
164     'e',0,
165     'r',0,
166     't',0,
167     'o',0,
168     'r',0
169   };
170
171
172   CODE const char Str3Desc[] = {  /* 3 = version */
173     26, 0x03,
174     '2',0,
175     '3',0,
176     '.',0,
177     '0',0,
178     '7',0,
179     '.',0,
180     '0',0,
181     '4',0,
182     '-',0,
183     '1',0,
184     '.',0,
185     '1',0
186   };
187   CODE const char Str4Desc[] = {  /* 4 = configuration */
188     34, 0x03,
189     'C',0,
190     'o',0,
191     'n',0,
192     'f',0,
193     'i',0,
194     'g',0,
195     'u',0,
196     'r',0,
197     'a',0,
198     't',0,
199     'i',0,
200     'o',0,
201     'n',0,
202     ' ',0,
203     '#',0,
204     '1',0
205   };
206   CODE const char Str5Desc[] = {  /* 5 = interface */
207     26,0x03,
208     'I',0,
209     'n',0,
210     't',0,
211     'e',0,
212     'r',0,
213     'f',0,
214     'a',0,
215     'c',0,
216     'e',0,
217     ' ',0,
218     '#',0,
219     '0',0
220   };
221
222   CODE const char Str6Desc[] = {  /* EP1 OUT descriptor */
223     136,0x03,
224     'E',0,
225     'P',0,
226     '1',0,
227     'O',0,
228     'U',0,
229     'T',0,
230     '-',0,
231     's',0,
232     'e',0,
233     'n',0,
234     'd',0,
235     ' ',0,
236     'm',0,
237     'e',0,
238     's',0,
239     's',0,
240     'a',0,
241     'g',0,
242     'e',0,
243     '-',0,
244     'd',0,
245     'a',0,
246     'd',0,
247     'r',0,
248     ',',0,
249     's',0,
250     'a',0,
251     'd',0,
252     'r',0,
253     ',',0,
254     'c',0,
255     'm',0,
256     'd',0,
257     ',',0,
258     'f',0,
259     'l',0,
260     'g',0,
261     ',',0,
262     's',0,
263     't',0,
264     'a',0,
265     'm',0,
266     'p',0,
267     ',',0,
268     'f',0,
269     'r',0,
270     'e',0,
271     'e',0,
272     ',',0,
273     'l',0,
274     'e',0,
275     'n',0,
276     '-',0,
277     'l',0,
278     'o',0,
279     ',',0,
280     'l',0,
281     'e',0,
282     'n',0,
283     '-',0,
284     'h',0,
285     'i',0,
286     ',',0,
287     'd',0,
288     'a',0,
289     't',0,
290     'a',0
291   };
292
293   CODE const char Str7Desc[] = {  /* EP2 IN descriptor */
294     140,0x03,
295     'E',0,
296     'P',0,
297     '1',0,
298     'I',0,
299     'N',0,
300     '-',0,
301     'r',0,
302     'e',0,
303     'c',0,
304     'e',0,
305     'i',0,
306     'v',0,
307     'e',0,
308     ' ',0,
309     'm',0,
310     'e',0,
311     's',0,
312     's',0,
313     'a',0,
314     'g',0,
315     'e',0,
316     '-',0,
317     'd',0,
318     'a',0,
319     'd',0,
320     'r',0,
321     ',',0,
322     's',0,
323     'a',0,
324     'd',0,
325     'r',0,
326     ',',0,
327     'c',0,
328     'm',0,
329     'd',0,
330     ',',0,
331     'f',0,
332     'l',0,
333     'g',0,
334     ',',0,
335     's',0,
336     't',0,
337     'a',0,
338     'm',0,
339     'p',0,
340     ',',0,
341     'f',0,
342     'r',0,
343     'e',0,
344     'e',0,
345     ',',0,
346     'l',0,
347     'e',0,
348     'n',0,
349     '-',0,
350     'l',0,
351     'o',0,
352     ',',0,
353     'l',0,
354     'e',0,
355     'n',0,
356     '-',0,
357     'h',0,
358     'i',0,
359     ',',0,
360     'd',0,
361     'a',0,
362     't',0,
363     'a',0
364   };
365
366   CODE const char Str8Desc[] = {  /* EP1 OUT descriptor */
367     136,0x03,
368     'E',0,
369     'P',0,
370     '2',0,
371     'O',0,
372     'U',0,
373     'T',0,
374     '-',0,
375     's',0,
376     'e',0,
377     'n',0,
378     'd',0,
379     ' ',0,
380     'm',0,
381     'e',0,
382     's',0,
383     's',0,
384     'a',0,
385     'g',0,
386     'e',0,
387     '-',0,
388     'd',0,
389     'a',0,
390     'd',0,
391     'r',0,
392     ',',0,
393     's',0,
394     'a',0,
395     'd',0,
396     'r',0,
397     ',',0,
398     'c',0,
399     'm',0,
400     'd',0,
401     ',',0,
402     'f',0,
403     'l',0,
404     'g',0,
405     ',',0,
406     's',0,
407     't',0,
408     'a',0,
409     'm',0,
410     'p',0,
411     ',',0,
412     'f',0,
413     'r',0,
414     'e',0,
415     'e',0,
416     ',',0,
417     'l',0,
418     'e',0,
419     'n',0,
420     '-',0,
421     'l',0,
422     'o',0,
423     ',',0,
424     'l',0,
425     'e',0,
426     'n',0,
427     '-',0,
428     'h',0,
429     'i',0,
430     ',',0,
431     'd',0,
432     'a',0,
433     't',0,
434     'a',0
435   };
436
437   #define CNT_STRINGS 0x09
438
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
450   };
451
452 #endif /* USB_DEFS_MODULE */