usbdescriptor.h
Go to the documentation of this file.
1 #ifndef USBDESCRIPTOR_H_INCLUDED
2 #define USBDESCRIPTOR_H_INCLUDED
3 
4 /*
5 * Endpoints to be used for USBD1.
6 */
7 #define USBD1_DATA_REQUEST_EP 1
8 #define USBD1_DATA_AVAILABLE_EP 1
9 #define USBD1_INTERRUPT_REQUEST_EP 2
10 
11 /*
12 * USB Device Descriptor.
13 */
14 static const uint8_t vcom_device_descriptor_data[18] = {
15  USB_DESC_DEVICE (0x0110, /* bcdUSB (1.1). */
16  0x02, /* bDeviceClass (CDC). */
17  0x00, /* bDeviceSubClass. */
18  0x00, /* bDeviceProtocol. */
19  0x40, /* bMaxPacketSize. */
20  0x0483, /* idVendor (ST). */
21  0x5740, /* idProduct. */
22  0x0200, /* bcdDevice. */
23  1, /* iManufacturer. */
24  2, /* iProduct. */
25  3, /* iSerialNumber. */
26  1) /* bNumConfigurations. */
27 };
28 
29 /*
30 * Device Descriptor wrapper.
31 */
32 static const USBDescriptor vcom_device_descriptor = {
33  sizeof vcom_device_descriptor_data,
34  vcom_device_descriptor_data
35 };
36 
37 /* Configuration Descriptor tree for a CDC.*/
38 static const uint8_t vcom_configuration_descriptor_data[67] = {
39  /* Configuration Descriptor.*/
40  USB_DESC_CONFIGURATION(67, /* wTotalLength. */
41  0x02, /* bNumInterfaces. */
42  0x01, /* bConfigurationValue. */
43  0, /* iConfiguration. */
44  0xC0, /* bmAttributes (self powered). */
45  50), /* bMaxPower (100mA). */
46  /* Interface Descriptor.*/
47  USB_DESC_INTERFACE (0x00, /* bInterfaceNumber. */
48  0x00, /* bAlternateSetting. */
49  0x01, /* bNumEndpoints. */
50  0x02, /* bInterfaceClass (Communications
51 Interface Class, CDC section
52 4.2). */
53  0x02, /* bInterfaceSubClass (Abstract
54 Control Model, CDC section 4.3). */
55  0x01, /* bInterfaceProtocol (AT commands,
56 CDC section 4.4). */
57  0), /* iInterface. */
58  /* Header Functional Descriptor (CDC section 5.2.3).*/
59  USB_DESC_BYTE (5), /* bLength. */
60  USB_DESC_BYTE (0x24), /* bDescriptorType (CS_INTERFACE). */
61  USB_DESC_BYTE (0x00), /* bDescriptorSubtype (Header
62 Functional Descriptor. */
63  USB_DESC_BCD (0x0110), /* bcdCDC. */
64  /* Call Management Functional Descriptor. */
65  USB_DESC_BYTE (5), /* bFunctionLength. */
66  USB_DESC_BYTE (0x24), /* bDescriptorType (CS_INTERFACE). */
67  USB_DESC_BYTE (0x01), /* bDescriptorSubtype (Call Management
68 Functional Descriptor). */
69  USB_DESC_BYTE (0x00), /* bmCapabilities (D0+D1). */
70  USB_DESC_BYTE (0x01), /* bDataInterface. */
71  /* ACM Functional Descriptor.*/
72  USB_DESC_BYTE (4), /* bFunctionLength. */
73  USB_DESC_BYTE (0x24), /* bDescriptorType (CS_INTERFACE). */
74  USB_DESC_BYTE (0x02), /* bDescriptorSubtype (Abstract
75 Control Management Descriptor). */
76  USB_DESC_BYTE (0x02), /* bmCapabilities. */
77  /* Union Functional Descriptor.*/
78  USB_DESC_BYTE (5), /* bFunctionLength. */
79  USB_DESC_BYTE (0x24), /* bDescriptorType (CS_INTERFACE). */
80  USB_DESC_BYTE (0x06), /* bDescriptorSubtype (Union
81 Functional Descriptor). */
82  USB_DESC_BYTE (0x00), /* bMasterInterface (Communication
83 Class Interface). */
84  USB_DESC_BYTE (0x01), /* bSlaveInterface0 (Data Class
85 Interface). */
86  /* Endpoint 2 Descriptor.*/
87  USB_DESC_ENDPOINT (USBD1_INTERRUPT_REQUEST_EP|0x80,
88  0x03, /* bmAttributes (Interrupt). */
89  0x0008, /* wMaxPacketSize. */
90  0xFF), /* bInterval. */
91  /* Interface Descriptor.*/
92  USB_DESC_INTERFACE (0x01, /* bInterfaceNumber. */
93  0x00, /* bAlternateSetting. */
94  0x02, /* bNumEndpoints. */
95  0x0A, /* bInterfaceClass (Data Class
96 Interface, CDC section 4.5). */
97  0x00, /* bInterfaceSubClass (CDC section
98 4.6). */
99  0x00, /* bInterfaceProtocol (CDC section
100 4.7). */
101  0x00), /* iInterface. */
102  /* Endpoint 3 Descriptor.*/
103  USB_DESC_ENDPOINT (USBD1_DATA_AVAILABLE_EP, /* bEndpointAddress.*/
104  0x02, /* bmAttributes (Bulk). */
105  0x0040, /* wMaxPacketSize. */
106  0x00), /* bInterval. */
107  /* Endpoint 1 Descriptor.*/
108  USB_DESC_ENDPOINT (USBD1_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/
109  0x02, /* bmAttributes (Bulk). */
110  0x0040, /* wMaxPacketSize. */
111  0x00) /* bInterval. */
112 };
113 
114 /*
115 * Configuration Descriptor wrapper.
116 */
117 static const USBDescriptor vcom_configuration_descriptor = {
118  sizeof vcom_configuration_descriptor_data,
119  vcom_configuration_descriptor_data
120 };
121 
122 /*
123 * U.S. English language identifier.
124 */
125 static const uint8_t vcom_string0[] = {
126  USB_DESC_BYTE(4), /* bLength. */
127  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
128  USB_DESC_WORD(0x0409) /* wLANGID (U.S. English). */
129 };
130 
131 /*
132 * Vendor string.
133 */
134 static const uint8_t vcom_string1[] = {
135  USB_DESC_BYTE(38), /* bLength. */
136  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
137  'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
138  'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
139  'c', 0, 's', 0
140 };
141 
142 /*
143 * Device Description string.
144 */
145 static const uint8_t vcom_string2[] = {
146  USB_DESC_BYTE(56), /* bLength. */
147  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
148  'C', 0, 'h', 0, 'i', 0, 'b', 0, 'i', 0, 'O', 0, 'S', 0, '/', 0,
149  'R', 0, 'T', 0, ' ', 0, 'V', 0, 'i', 0, 'r', 0, 't', 0, 'u', 0,
150  'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0, 'M', 0, ' ', 0, 'P', 0,
151  'o', 0, 'r', 0, 't', 0
152 };
153 
154 /*
155 * Serial Number string.
156 */
157 static const uint8_t vcom_string3[] = {
158  USB_DESC_BYTE(8), /* bLength. */
159  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */
160  '0' + CH_KERNEL_MAJOR, 0,
161  '0' + CH_KERNEL_MINOR, 0,
162  '0' + CH_KERNEL_PATCH, 0
163 };
164 
165 /*
166 * Strings wrappers array.
167 */
168 static const USBDescriptor vcom_strings[] = {
169  {sizeof vcom_string0, vcom_string0},
170  {sizeof vcom_string1, vcom_string1},
171  {sizeof vcom_string2, vcom_string2},
172  {sizeof vcom_string3, vcom_string3}
173 };
174 
175 
176 
177 #endif // USBDESCRIPTOR_H_INCLUDED
#define USBD1_INTERRUPT_REQUEST_EP
Definition: usbdescriptor.h:9
#define USBD1_DATA_AVAILABLE_EP
Definition: usbdescriptor.h:8
#define USBD1_DATA_REQUEST_EP
Definition: usbdescriptor.h:7