Skip to content

Commit 8b60e9f

Browse files
committed
Merge pull request #222 from nomis52/cdc
Add the CDC interface association descriptor.
2 parents 41b037d + 364d79a commit 8b60e9f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

firmware/src/usb_descriptors.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ static const USB_DEVICE_DESCRIPTOR g_device_descriptor = {
7979
0x12, // Size of this descriptor in bytes
8080
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
8181
0x0200, // USB Spec Release Number in BCD format
82-
0x00, // Class Code
83-
0x00, // Subclass code
84-
0x00, // Protocol code
82+
// Since we use an Interface Association, we need to set the class, subclass
83+
// and protocol according to:
84+
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff540054(v=vs.85).aspx
85+
0xef, // Class Code
86+
0x02, // Subclass code
87+
0x01, // Protocol code
8588
USB_DEVICE_EP0_BUFFER_SIZE, // Max packet size for EP0, see usb_config.h
8689
USB_DEVICE_VENDOR_ID,
8790
USB_DEVICE_MAIN_PRODUCT_ID,
@@ -98,13 +101,23 @@ static const uint8_t g_config_descriptor[] = {
98101
// Configuration Descriptor Header
99102
0x09, // Size of this descriptor
100103
USB_DESCRIPTOR_CONFIGURATION, // Descriptor type
101-
0x6c, 0x00, // Total length of data for this cfg
104+
0x74, 0x00, // Total length of data for this cfg
102105
4, // Number of interfaces in this cfg
103106
1, // Index value of this configuration
104107
0, // Configuration string index
105108
USB_ATTRIBUTE_DEFAULT | USB_ATTRIBUTE_SELF_POWERED, // Attributes
106109
USB_POWER_CONSUMPTION, // Max power consumption
107110

111+
// Interface Association Descriptor: CDC Function 1
112+
0x08, // Size of this descriptor in bytes
113+
0x0B, // Interface association descriptor type
114+
0, // The first associated interface
115+
0x02, // Number of contiguous associated interfaces
116+
0x02, // bInterfaceClass of the first interface
117+
0x02, // bInterfaceSubclass of the first interface
118+
0x01, // bInterfaceProtocol of the first interface
119+
0x00, // Interface string index
120+
108121
// First CDC Interface Descriptor
109122
0x09, // Size of this descriptor in bytes
110123
USB_DESCRIPTOR_INTERFACE, // Descriptor type

0 commit comments

Comments
 (0)