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