Root/atusb/fw/descr.c

1/*
2 * fw/descr.c - USB descriptors
3 *
4 * Written 2008-2011, 2014 by Werner Almesberger
5 * Copyright 2008-2011, 2014 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include "usb.h"
15#include "dfu.h"
16#include "board.h"
17
18
19#define LE(x) ((uint16_t) (x) & 0xff), ((uint16_t) (x) >> 8)
20
21/*
22 * Device descriptor
23 */
24
25const uint8_t device_descriptor[18] = {
26    18, /* bLength */
27    USB_DT_DEVICE, /* bDescriptorType */
28    LE(0x200), /* bcdUSB */
29    USB_CLASS_VENDOR_SPEC, /* bDeviceClass */
30    0x00, /* bDeviceSubClass */
31    0x00, /* bDeviceProtocol */
32    EP0_SIZE, /* bMaxPacketSize */
33    LE(USB_VENDOR), /* idVendor */
34    LE(USB_PRODUCT), /* idProduct */
35    LE(0x0001), /* bcdDevice */
36    0, /* iManufacturer */
37    0, /* iProduct */
38#ifdef HAS_BOARD_SERNUM
39    1, /* iSerialNumber */
40#else
41    0, /* iSerialNumber */
42#endif
43    1 /* bNumConfigurations */
44};
45
46
47/*
48 * Our configuration
49 *
50 * We're always bus-powered.
51 */
52
53const uint8_t config_descriptor[] = {
54    9, /* bLength */
55    USB_DT_CONFIG, /* bDescriptorType */
56#if 0
57    LE(9+9+7+7), /* wTotalLength */
58#else
59    LE(9+9+7+9), /* wTotalLength */
60#endif
61    2, /* bNumInterfaces */
62    1, /* bConfigurationValue (> 0 !) */
63    0, /* iConfiguration */
64    USB_ATTR_BUS_POWERED, /* bmAttributes */
65    ((BOARD_MAX_mA)+1)/2, /* bMaxPower */
66
67    /* Interface #0 */
68
69    9, /* bLength */
70    USB_DT_INTERFACE, /* bDescriptorType */
71    0, /* bInterfaceNumber */
72    0, /* bAlternateSetting */
73    1, /* bNumEndpoints */
74    USB_CLASS_VENDOR_SPEC, /* bInterfaceClass */
75    0, /* bInterfaceSubClass */
76    0, /* bInterfaceProtocol */
77    0, /* iInterface */
78
79#if 0
80    /* EP OUT */
81
82    7, /* bLength */
83    USB_DT_ENDPOINT, /* bDescriptorType */
84    0x01, /* bEndPointAddress */
85    0x02, /* bmAttributes (bulk) */
86    LE(EP1_SIZE), /* wMaxPacketSize */
87    0, /* bInterval */
88#endif
89
90#if 1
91    /* EP IN */
92
93    7, /* bLength */
94    USB_DT_ENDPOINT, /* bDescriptorType */
95    0x81, /* bEndPointAddress */
96    0x02, /* bmAttributes (bulk) */
97    LE(EP1_SIZE), /* wMaxPacketSize */
98    0, /* bInterval */
99#endif
100
101    /* Interface #1 */
102
103    DFU_ITF_DESCR(1, 0, dfu_proto_runtime, 0)
104};
105

Archive Download this file



interactive