53template <u
int16_t MaxPacketSize>
55 const uint8_t *descriptors,
57 USBHost::println_(
"MIDIDevice claim this=", (uintptr_t)
this, HEX);
58 USBHost::println_(
"len = ",
len);
60 const uint8_t *p = descriptors;
61 const uint8_t *end = p +
len;
63 if (p[0] != 9 || p[1] != 4)
68 if (p[5] == 1 && p[6] == 3) {
70 " Interface is MIDI");
73 if (p[5] >= 2 && p[5] <= 18)
78 USBHost::println_(
" Interface is unknown (might be Yahama)");
91 USBHost::print_(
"type: ", type);
92 USBHost::println_(
", len: ",
len);
93 if (type == 4 || type == 11)
96 uint32_t subtype = p[2];
100 USBHost::println_(
" MIDI Header (ignored)");
102 }
else if (subtype == 2) {
104 USBHost::println_(
" MIDI IN Jack (ignored)");
106 }
else if (subtype == 3) {
108 USBHost::println_(
" MIDI OUT Jack (ignored)");
110 }
else if (subtype == 4) {
112 USBHost::println_(
" MIDI Element (ignored)");
114 }
else if (subtype == 0xF1 && p[3] == 2) {
116 USBHost::println_(
" Roland vendor-specific (ignored)");
119 USBHost::println_(
" Unknown MIDI CS_INTERFACE descriptor!");
122 }
else if (type == 5) {
126 if (p[3] != 2 && p[3] != 3)
128 USBHost::println_(
" MIDI Endpoint: ", p[2], HEX);
129 switch (p[2] & 0xF0) {
136 USBHost::println_(
" rx_size = ",
rx_size);
145 USBHost::println_(
" tx_size = ",
tx_size);
148 default:
return false;
150 }
else if (type == 37) {
152 USBHost::println_(
" MIDI Endpoint Jack Association (ignored)");
154 USBHost::println_(
" Unknown descriptor, type=", type);
#define BEGIN_CS_NAMESPACE
bool claim_if_midi(Device_t *device, int type, const uint8_t *descriptors, uint32_t len)
static constexpr size_t len(T(&)[N])