使用 Lufa 的示例,作为 MIDI 的参考:
USB Composite Device
Connection Status | Device connected |
Current Configuration | 1 |
Speed | Full (12 Mbit/s) |
Device Address | 4 |
Number Of Open Pipes | 2 |
Device Descriptor LUFAMIDI Demo
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 12h | |
1 | bDescriptorType | 1 | 01h | Device |
2 | bcdUSB | 2 | 0110h | USB Spec 1.1 |
4 | bDeviceClass | 1 | 00h | Class info in Ifc Descriptors |
5 | bDeviceSubClass | 1 | 00h | |
6 | bDeviceProtocol | 1 | 00h | |
7 | bMaxPacketSize0 | 1 | 08h | 8 bytes |
8 | idVendor | 2 | 03EBh | |
10 | idProduct | 2 | 2048h | |
12 | bcdDevice | 2 | 0001h | 0.01 |
14 | iManufacturer | 1 | 01h | "Dean Camera" |
15 | iProduct | 1 | 02h | "LUFA MIDI Demo" |
16 | iSerialNumber | 1 | 00h | |
17 | bNumConfigurations | 1 | 01h |
Configuration Descriptor1
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 02h | Configuration |
2 | wTotalLength | 2 | 0065h | |
4 | bNumInterfaces | 1 | 02h | |
5 | bConfigurationValue | 1 | 01h | |
6 | iConfiguration | 1 | 00h | |
7 | bmAttributes | 1 | C0h | Self Powered |
4..0: Reserved | ...00000 | |||
5: Remote Wakeup | ..0..... | No | ||
6: Self Powered | .1...... | Yes | ||
7: Reserved (set to one) (bus-powered for 1.0) | 1....... | |||
8 | bMaxPower | 1 | 32h | 100 mA |
Interface Descriptor 0/0 Audio,0 Endpoints
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 04h | Interface |
2 | bInterfaceNumber | 1 | 00h | |
3 | bAlternateSetting | 1 | 00h | |
4 | bNumEndpoints | 1 | 00h | |
5 | bInterfaceClass | 1 | 01h | Audio |
6 | bInterfaceSubClass | 1 | 01h | Audio Control |
7 | bInterfaceProtocol | 1 | 00h | |
8 | iInterface | 1 | 00h |
Audio Control InterfaceHeader Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 24h | Audio Control Interface Header |
2 | 7 | 01 00 01 09 00 01 01 |
Interface Descriptor 1/0 Audio,2 Endpoints
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 04h | Interface |
2 | bInterfaceNumber | 1 | 01h | |
3 | bAlternateSetting | 1 | 00h | |
4 | bNumEndpoints | 1 | 02h | |
5 | bInterfaceClass | 1 | 01h | Audio |
6 | bInterfaceSubClass | 1 | 03h | MIDI Streaming |
7 | bInterfaceProtocol | 1 | 00h | |
8 | iInterface | 1 | 00h |
MIDI Streaming InterfaceHeader Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 07h | |
1 | bDescriptorType | 1 | 24h | MIDI Streaming Interface Header |
2 | 5 | 01 00 01 41 00 |
MIDI In Jack Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 06h | |
1 | bDescriptorType | 1 | 24h | MIDI In Jack |
2 | 4 | 02 01 01 00 |
MIDI In Jack Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 06h | |
1 | bDescriptorType | 1 | 24h | MIDI In Jack |
2 | 4 | 02 02 02 00 |
MIDI Out Jack Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 24h | MIDI Out Jack |
2 | 7 | 03 01 03 01 02 01 00 |
MIDI Out Jack Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 24h | MIDI Out Jack |
2 | 7 | 03 02 04 01 01 01 00 |
Endpoint Descriptor 01 1Out, Bulk, 64 bytes
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 05h | Endpoint |
2 | bEndpointAddress | 1 | 01h | 1 Out |
3 | bmAttributes | 1 | 02h | Bulk |
1..0: Transfer Type | ......10 | Bulk | ||
7..2: Reserved | 000000.. | |||
4 | wMaxPacketSize | 2 | 0040h | 64 bytes |
6 | bInterval | 1 | 05h | |
7 | bRefresh | 1 | 00h | |
8 | bSynchAddress | 1 | 00h |
Unrecognized AudioClass-Specific Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 05h | |
1 | bDescriptorType | 1 | 25h | Unrecognized Audio Class-Specific |
2 | 3 | 01 01 01 |
Endpoint Descriptor 82 2In, Bulk, 64 bytes
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 09h | |
1 | bDescriptorType | 1 | 05h | Endpoint |
2 | bEndpointAddress | 1 | 82h | 2 In |
3 | bmAttributes | 1 | 02h | Bulk |
1..0: Transfer Type | ......10 | Bulk | ||
7..2: Reserved | 000000.. | |||
4 | wMaxPacketSize | 2 | 0040h | 64 bytes |
6 | bInterval | 1 | 05h | |
7 | bRefresh | 1 | 00h | |
8 | bSynchAddress | 1 | 00h |
Unrecognized AudioClass-Specific Descriptor
Offset | Field | Size | Value | Description |
0 | bLength | 1 | 05h | |
1 | bDescriptorType | 1 | 25h | Unrecognized Audio Class-Specific |
2 | 3 | 01 01 03 |
代码上和之前的串口非常类似(MIDI 可以看作是波特率特殊的串口):