mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 /* Copyright (c) 2014 mbed.org, MIT License
elessair 0:f269e3021894 2 *
elessair 0:f269e3021894 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
elessair 0:f269e3021894 4 * and associated documentation files (the "Software"), to deal in the Software without
elessair 0:f269e3021894 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
elessair 0:f269e3021894 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
elessair 0:f269e3021894 7 * Software is furnished to do so, subject to the following conditions:
elessair 0:f269e3021894 8 *
elessair 0:f269e3021894 9 * The above copyright notice and this permission notice shall be included in all copies or
elessair 0:f269e3021894 10 * substantial portions of the Software.
elessair 0:f269e3021894 11 *
elessair 0:f269e3021894 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
elessair 0:f269e3021894 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
elessair 0:f269e3021894 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
elessair 0:f269e3021894 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
elessair 0:f269e3021894 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
elessair 0:f269e3021894 17 */
elessair 0:f269e3021894 18
elessair 0:f269e3021894 19 #include "USBHostMIDI.h"
elessair 0:f269e3021894 20
elessair 0:f269e3021894 21 #if USBHOST_MIDI
elessair 0:f269e3021894 22
elessair 0:f269e3021894 23 #include "dbg.h"
elessair 0:f269e3021894 24
elessair 0:f269e3021894 25 #define SET_LINE_CODING 0x20
elessair 0:f269e3021894 26
elessair 0:f269e3021894 27 USBHostMIDI::USBHostMIDI() {
elessair 0:f269e3021894 28 host = USBHost::getHostInst();
elessair 0:f269e3021894 29 size_bulk_in = 0;
elessair 0:f269e3021894 30 size_bulk_out = 0;
elessair 0:f269e3021894 31 init();
elessair 0:f269e3021894 32 }
elessair 0:f269e3021894 33
elessair 0:f269e3021894 34 void USBHostMIDI::init() {
elessair 0:f269e3021894 35 dev = NULL;
elessair 0:f269e3021894 36 bulk_in = NULL;
elessair 0:f269e3021894 37 bulk_out = NULL;
elessair 0:f269e3021894 38 dev_connected = false;
elessair 0:f269e3021894 39 midi_intf = -1;
elessair 0:f269e3021894 40 midi_device_found = false;
elessair 0:f269e3021894 41 sysExBufferPos = 0;
elessair 0:f269e3021894 42 }
elessair 0:f269e3021894 43
elessair 0:f269e3021894 44 bool USBHostMIDI::connected() {
elessair 0:f269e3021894 45 return dev_connected;
elessair 0:f269e3021894 46 }
elessair 0:f269e3021894 47
elessair 0:f269e3021894 48 bool USBHostMIDI::connect() {
elessair 0:f269e3021894 49 if (dev_connected) {
elessair 0:f269e3021894 50 return true;
elessair 0:f269e3021894 51 }
elessair 0:f269e3021894 52
elessair 0:f269e3021894 53 for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) {
elessair 0:f269e3021894 54 if ((dev = host->getDevice(i)) != NULL) {
elessair 0:f269e3021894 55
elessair 0:f269e3021894 56 USB_DBG("Trying to connect MIDI device\r\n");
elessair 0:f269e3021894 57
elessair 0:f269e3021894 58 if (host->enumerate(dev, this)) {
elessair 0:f269e3021894 59 break;
elessair 0:f269e3021894 60 }
elessair 0:f269e3021894 61
elessair 0:f269e3021894 62 if (midi_device_found) {
elessair 0:f269e3021894 63 bulk_in = dev->getEndpoint(midi_intf, BULK_ENDPOINT, IN);
elessair 0:f269e3021894 64 bulk_out = dev->getEndpoint(midi_intf, BULK_ENDPOINT, OUT);
elessair 0:f269e3021894 65
elessair 0:f269e3021894 66 if (!bulk_in || !bulk_out) {
elessair 0:f269e3021894 67 break;
elessair 0:f269e3021894 68 }
elessair 0:f269e3021894 69
elessair 0:f269e3021894 70 USB_INFO("New MIDI device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, midi_intf);
elessair 0:f269e3021894 71 dev->setName("MIDI", midi_intf);
elessair 0:f269e3021894 72 host->registerDriver(dev, midi_intf, this, &USBHostMIDI::init);
elessair 0:f269e3021894 73
elessair 0:f269e3021894 74 size_bulk_in = bulk_in->getSize();
elessair 0:f269e3021894 75 size_bulk_out = bulk_out->getSize();
elessair 0:f269e3021894 76
elessair 0:f269e3021894 77 bulk_in->attach(this, &USBHostMIDI::rxHandler);
elessair 0:f269e3021894 78
elessair 0:f269e3021894 79 host->bulkRead(dev, bulk_in, buf, size_bulk_in, false);
elessair 0:f269e3021894 80 dev_connected = true;
elessair 0:f269e3021894 81 return true;
elessair 0:f269e3021894 82 }
elessair 0:f269e3021894 83 }
elessair 0:f269e3021894 84 }
elessair 0:f269e3021894 85
elessair 0:f269e3021894 86 init();
elessair 0:f269e3021894 87 return false;
elessair 0:f269e3021894 88 }
elessair 0:f269e3021894 89
elessair 0:f269e3021894 90 void USBHostMIDI::rxHandler() {
elessair 0:f269e3021894 91 uint8_t *midi;
elessair 0:f269e3021894 92 if (bulk_in) {
elessair 0:f269e3021894 93 int length = bulk_in->getLengthTransferred();
elessair 0:f269e3021894 94 if (bulk_in->getState() == USB_TYPE_IDLE || bulk_in->getState() == USB_TYPE_FREE) {
elessair 0:f269e3021894 95 // MIDI event handling
elessair 0:f269e3021894 96 for (int i = 0; i < length; i += 4) {
elessair 0:f269e3021894 97 if (i + 4 > length) {
elessair 0:f269e3021894 98 // length shortage, ignored.
elessair 0:f269e3021894 99 break;
elessair 0:f269e3021894 100 }
elessair 0:f269e3021894 101
elessair 0:f269e3021894 102 // read each four bytes
elessair 0:f269e3021894 103 midi = &buf[i];
elessair 0:f269e3021894 104 // process MIDI message
elessair 0:f269e3021894 105 // switch by code index number
elessair 0:f269e3021894 106 switch (midi[0] & 0xf) {
elessair 0:f269e3021894 107 case 0: // miscellaneous function codes
elessair 0:f269e3021894 108 miscellaneousFunctionCode(midi[1], midi[2], midi[3]);
elessair 0:f269e3021894 109 break;
elessair 0:f269e3021894 110 case 1: // cable events
elessair 0:f269e3021894 111 cableEvent(midi[1], midi[2], midi[3]);
elessair 0:f269e3021894 112 break;
elessair 0:f269e3021894 113 case 2: // two bytes system common messages
elessair 0:f269e3021894 114 systemCommonTwoBytes(midi[1], midi[2]);
elessair 0:f269e3021894 115 break;
elessair 0:f269e3021894 116 case 3: // three bytes system common messages
elessair 0:f269e3021894 117 systemCommonThreeBytes(midi[1], midi[2], midi[3]);
elessair 0:f269e3021894 118 break;
elessair 0:f269e3021894 119 case 4: // SysEx starts or continues
elessair 0:f269e3021894 120 sysExBuffer[sysExBufferPos++] = midi[1];
elessair 0:f269e3021894 121 if (sysExBufferPos >= 64) {
elessair 0:f269e3021894 122 systemExclusive(sysExBuffer, sysExBufferPos, true);
elessair 0:f269e3021894 123 sysExBufferPos = 0;
elessair 0:f269e3021894 124 }
elessair 0:f269e3021894 125 sysExBuffer[sysExBufferPos++] = midi[2];
elessair 0:f269e3021894 126 if (sysExBufferPos >= 64) {
elessair 0:f269e3021894 127 systemExclusive(sysExBuffer, sysExBufferPos, true);
elessair 0:f269e3021894 128 sysExBufferPos = 0;
elessair 0:f269e3021894 129 }
elessair 0:f269e3021894 130 sysExBuffer[sysExBufferPos++] = midi[3];
elessair 0:f269e3021894 131 // SysEx continues. don't send
elessair 0:f269e3021894 132 break;
elessair 0:f269e3021894 133 case 5: // SysEx ends with single byte
elessair 0:f269e3021894 134 sysExBuffer[sysExBufferPos++] = midi[1];
elessair 0:f269e3021894 135 systemExclusive(sysExBuffer, sysExBufferPos, false);
elessair 0:f269e3021894 136 sysExBufferPos = 0;
elessair 0:f269e3021894 137 break;
elessair 0:f269e3021894 138 case 6: // SysEx ends with two bytes
elessair 0:f269e3021894 139 sysExBuffer[sysExBufferPos++] = midi[1];
elessair 0:f269e3021894 140 if (sysExBufferPos >= 64) {
elessair 0:f269e3021894 141 systemExclusive(sysExBuffer, sysExBufferPos, true);
elessair 0:f269e3021894 142 sysExBufferPos = 0;
elessair 0:f269e3021894 143 }
elessair 0:f269e3021894 144 sysExBuffer[sysExBufferPos++] = midi[2];
elessair 0:f269e3021894 145 systemExclusive(sysExBuffer, sysExBufferPos, false);
elessair 0:f269e3021894 146 sysExBufferPos = 0;
elessair 0:f269e3021894 147 break;
elessair 0:f269e3021894 148 case 7: // SysEx ends with three bytes
elessair 0:f269e3021894 149 sysExBuffer[sysExBufferPos++] = midi[1];
elessair 0:f269e3021894 150 if (sysExBufferPos >= 64) {
elessair 0:f269e3021894 151 systemExclusive(sysExBuffer, sysExBufferPos, true);
elessair 0:f269e3021894 152 sysExBufferPos = 0;
elessair 0:f269e3021894 153 }
elessair 0:f269e3021894 154 sysExBuffer[sysExBufferPos++] = midi[2];
elessair 0:f269e3021894 155 if (sysExBufferPos >= 64) {
elessair 0:f269e3021894 156 systemExclusive(sysExBuffer, sysExBufferPos, true);
elessair 0:f269e3021894 157 sysExBufferPos = 0;
elessair 0:f269e3021894 158 }
elessair 0:f269e3021894 159 sysExBuffer[sysExBufferPos++] = midi[3];
elessair 0:f269e3021894 160 systemExclusive(sysExBuffer, sysExBufferPos, false);
elessair 0:f269e3021894 161 sysExBufferPos = 0;
elessair 0:f269e3021894 162 break;
elessair 0:f269e3021894 163 case 8:
elessair 0:f269e3021894 164 noteOff(midi[1] & 0xf, midi[2], midi[3]);
elessair 0:f269e3021894 165 break;
elessair 0:f269e3021894 166 case 9:
elessair 0:f269e3021894 167 if (midi[3]) {
elessair 0:f269e3021894 168 noteOn(midi[1] & 0xf, midi[2], midi[3]);
elessair 0:f269e3021894 169 } else {
elessair 0:f269e3021894 170 noteOff(midi[1] & 0xf, midi[2], midi[3]);
elessair 0:f269e3021894 171 }
elessair 0:f269e3021894 172 break;
elessair 0:f269e3021894 173 case 10:
elessair 0:f269e3021894 174 polyKeyPress(midi[1] & 0xf, midi[2], midi[3]);
elessair 0:f269e3021894 175 break;
elessair 0:f269e3021894 176 case 11:
elessair 0:f269e3021894 177 controlChange(midi[1] & 0xf, midi[2], midi[3]);
elessair 0:f269e3021894 178 break;
elessair 0:f269e3021894 179 case 12:
elessair 0:f269e3021894 180 programChange(midi[1] & 0xf, midi[2]);
elessair 0:f269e3021894 181 break;
elessair 0:f269e3021894 182 case 13:
elessair 0:f269e3021894 183 channelPressure(midi[1] & 0xf, midi[2]);
elessair 0:f269e3021894 184 break;
elessair 0:f269e3021894 185 case 14:
elessair 0:f269e3021894 186 pitchBend(midi[1] & 0xf, midi[2] | (midi[3] << 7));
elessair 0:f269e3021894 187 break;
elessair 0:f269e3021894 188 case 15:
elessair 0:f269e3021894 189 singleByte(midi[1]);
elessair 0:f269e3021894 190 break;
elessair 0:f269e3021894 191 }
elessair 0:f269e3021894 192 }
elessair 0:f269e3021894 193
elessair 0:f269e3021894 194 // read another message
elessair 0:f269e3021894 195 host->bulkRead(dev, bulk_in, buf, size_bulk_in, false);
elessair 0:f269e3021894 196 }
elessair 0:f269e3021894 197 }
elessair 0:f269e3021894 198 }
elessair 0:f269e3021894 199
elessair 0:f269e3021894 200 bool USBHostMIDI::sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3) {
elessair 0:f269e3021894 201 if (bulk_out) {
elessair 0:f269e3021894 202 uint8_t midi[4];
elessair 0:f269e3021894 203
elessair 0:f269e3021894 204 midi[0] = data0;
elessair 0:f269e3021894 205 midi[1] = data1;
elessair 0:f269e3021894 206 midi[2] = data2;
elessair 0:f269e3021894 207 midi[3] = data3;
elessair 0:f269e3021894 208 if (host->bulkWrite(dev, bulk_out, (uint8_t *)midi, 4) == USB_TYPE_OK) {
elessair 0:f269e3021894 209 return true;
elessair 0:f269e3021894 210 }
elessair 0:f269e3021894 211 }
elessair 0:f269e3021894 212 return false;
elessair 0:f269e3021894 213 }
elessair 0:f269e3021894 214
elessair 0:f269e3021894 215 bool USBHostMIDI::sendMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3) {
elessair 0:f269e3021894 216 return sendMidiBuffer(0, data1, data2, data3);
elessair 0:f269e3021894 217 }
elessair 0:f269e3021894 218
elessair 0:f269e3021894 219 bool USBHostMIDI::sendCableEvent(uint8_t data1, uint8_t data2, uint8_t data3) {
elessair 0:f269e3021894 220 return sendMidiBuffer(1, data1, data2, data3);
elessair 0:f269e3021894 221 }
elessair 0:f269e3021894 222
elessair 0:f269e3021894 223 bool USBHostMIDI::sendSystemCommmonTwoBytes(uint8_t data1, uint8_t data2) {
elessair 0:f269e3021894 224 return sendMidiBuffer(2, data1, data2, 0);
elessair 0:f269e3021894 225 }
elessair 0:f269e3021894 226
elessair 0:f269e3021894 227 bool USBHostMIDI::sendSystemCommmonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3) {
elessair 0:f269e3021894 228 return sendMidiBuffer(3, data1, data2, 0);
elessair 0:f269e3021894 229 }
elessair 0:f269e3021894 230
elessair 0:f269e3021894 231 bool USBHostMIDI::sendSystemExclusive(uint8_t *buffer, int length) {
elessair 0:f269e3021894 232 uint8_t midi[64];
elessair 0:f269e3021894 233 int midiLength;
elessair 0:f269e3021894 234 int midiPos;
elessair 0:f269e3021894 235 if (bulk_out) {
elessair 0:f269e3021894 236 for (int i = 0; i < length; i += 48) {
elessair 0:f269e3021894 237 if (i + 48 >= length) {
elessair 0:f269e3021894 238 // contains last data
elessair 0:f269e3021894 239 midiLength = (((length - i) + 2) / 3) * 4;
elessair 0:f269e3021894 240 for (int pos = i; pos < length; pos += 3) {
elessair 0:f269e3021894 241 midiPos = (pos + 2) / 3 * 4;
elessair 0:f269e3021894 242 if (pos + 3 >= length) {
elessair 0:f269e3021894 243 // last data
elessair 0:f269e3021894 244 switch (pos % 3) {
elessair 0:f269e3021894 245 case 0:
elessair 0:f269e3021894 246 midi[midiPos ] = 7;
elessair 0:f269e3021894 247 midi[midiPos + 1] = buffer[pos ];
elessair 0:f269e3021894 248 midi[midiPos + 2] = buffer[pos + 1];
elessair 0:f269e3021894 249 midi[midiPos + 3] = buffer[pos + 2];
elessair 0:f269e3021894 250 break;
elessair 0:f269e3021894 251 case 1:
elessair 0:f269e3021894 252 midi[midiPos ] = 5;
elessair 0:f269e3021894 253 midi[midiPos + 1] = buffer[pos ];
elessair 0:f269e3021894 254 midi[midiPos + 2] = 0;
elessair 0:f269e3021894 255 midi[midiPos + 3] = 0;
elessair 0:f269e3021894 256 break;
elessair 0:f269e3021894 257 case 2:
elessair 0:f269e3021894 258 midi[midiPos ] = 6;
elessair 0:f269e3021894 259 midi[midiPos + 1] = buffer[pos ];
elessair 0:f269e3021894 260 midi[midiPos + 2] = buffer[pos + 1];
elessair 0:f269e3021894 261 midi[midiPos + 3] = 0;
elessair 0:f269e3021894 262 break;
elessair 0:f269e3021894 263 }
elessair 0:f269e3021894 264 } else {
elessair 0:f269e3021894 265 // has more data
elessair 0:f269e3021894 266 midi[midiPos ] = 4;
elessair 0:f269e3021894 267 midi[midiPos + 1] = buffer[pos ];
elessair 0:f269e3021894 268 midi[midiPos + 2] = buffer[pos + 1];
elessair 0:f269e3021894 269 midi[midiPos + 3] = buffer[pos + 2];
elessair 0:f269e3021894 270 }
elessair 0:f269e3021894 271 }
elessair 0:f269e3021894 272 } else {
elessair 0:f269e3021894 273 // has more data
elessair 0:f269e3021894 274 midiLength = 64;
elessair 0:f269e3021894 275 for (int pos = i; pos < length; pos += 3) {
elessair 0:f269e3021894 276 midiPos = (pos + 2) / 3 * 4;
elessair 0:f269e3021894 277 midi[midiPos ] = 4;
elessair 0:f269e3021894 278 midi[midiPos + 1] = buffer[pos ];
elessair 0:f269e3021894 279 midi[midiPos + 2] = buffer[pos + 1];
elessair 0:f269e3021894 280 midi[midiPos + 3] = buffer[pos + 2];
elessair 0:f269e3021894 281 }
elessair 0:f269e3021894 282 }
elessair 0:f269e3021894 283
elessair 0:f269e3021894 284 if (host->bulkWrite(dev, bulk_out, (uint8_t *)midi, midiLength) != USB_TYPE_OK) {
elessair 0:f269e3021894 285 return false;
elessair 0:f269e3021894 286 }
elessair 0:f269e3021894 287 }
elessair 0:f269e3021894 288 return true;
elessair 0:f269e3021894 289 }
elessair 0:f269e3021894 290 return false;
elessair 0:f269e3021894 291 }
elessair 0:f269e3021894 292
elessair 0:f269e3021894 293 bool USBHostMIDI::sendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity) {
elessair 0:f269e3021894 294 return sendMidiBuffer(8, channel & 0xf | 0x80, note & 0x7f, velocity & 0x7f);
elessair 0:f269e3021894 295 }
elessair 0:f269e3021894 296
elessair 0:f269e3021894 297 bool USBHostMIDI::sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity) {
elessair 0:f269e3021894 298 return sendMidiBuffer(9, channel & 0xf | 0x90, note & 0x7f, velocity & 0x7f);
elessair 0:f269e3021894 299 }
elessair 0:f269e3021894 300
elessair 0:f269e3021894 301 bool USBHostMIDI::sendPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure) {
elessair 0:f269e3021894 302 return sendMidiBuffer(10, channel & 0xf | 0xa0, note & 0x7f, pressure & 0x7f);
elessair 0:f269e3021894 303 }
elessair 0:f269e3021894 304
elessair 0:f269e3021894 305 bool USBHostMIDI::sendControlChange(uint8_t channel, uint8_t key, uint8_t value) {
elessair 0:f269e3021894 306 return sendMidiBuffer(11, channel & 0xf | 0xb0, key & 0x7f, value & 0x7f);
elessair 0:f269e3021894 307 }
elessair 0:f269e3021894 308
elessair 0:f269e3021894 309 bool USBHostMIDI::sendProgramChange(uint8_t channel, uint8_t program) {
elessair 0:f269e3021894 310 return sendMidiBuffer(12, channel & 0xf | 0xc0, program & 0x7f, 0);
elessair 0:f269e3021894 311 }
elessair 0:f269e3021894 312
elessair 0:f269e3021894 313 bool USBHostMIDI::sendChannelPressure(uint8_t channel, uint8_t pressure) {
elessair 0:f269e3021894 314 return sendMidiBuffer(13, channel & 0xf | 0xd0, pressure & 0x7f, 0);
elessair 0:f269e3021894 315 }
elessair 0:f269e3021894 316
elessair 0:f269e3021894 317 bool USBHostMIDI::sendPitchBend(uint8_t channel, uint16_t value) {
elessair 0:f269e3021894 318 return sendMidiBuffer(14, channel & 0xf | 0xe0, value & 0x7f, (value >> 7) & 0x7f);
elessair 0:f269e3021894 319 }
elessair 0:f269e3021894 320
elessair 0:f269e3021894 321 bool USBHostMIDI::sendSingleByte(uint8_t data) {
elessair 0:f269e3021894 322 return sendMidiBuffer(15, data, 0, 0);
elessair 0:f269e3021894 323 }
elessair 0:f269e3021894 324
elessair 0:f269e3021894 325 /*virtual*/ void USBHostMIDI::setVidPid(uint16_t vid, uint16_t pid)
elessair 0:f269e3021894 326 {
elessair 0:f269e3021894 327 // we don't check VID/PID for this driver
elessair 0:f269e3021894 328 }
elessair 0:f269e3021894 329
elessair 0:f269e3021894 330 /*virtual*/ bool USBHostMIDI::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed
elessair 0:f269e3021894 331 {
elessair 0:f269e3021894 332 // USB MIDI class/subclass
elessair 0:f269e3021894 333 if ((midi_intf == -1) &&
elessair 0:f269e3021894 334 (intf_class == AUDIO_CLASS) &&
elessair 0:f269e3021894 335 (intf_subclass == 0x03)) {
elessair 0:f269e3021894 336 midi_intf = intf_nb;
elessair 0:f269e3021894 337 return true;
elessair 0:f269e3021894 338 }
elessair 0:f269e3021894 339
elessair 0:f269e3021894 340 // vendor specific device
elessair 0:f269e3021894 341 if ((midi_intf == -1) &&
elessair 0:f269e3021894 342 (intf_class == 0xff) &&
elessair 0:f269e3021894 343 (intf_subclass == 0x03)) {
elessair 0:f269e3021894 344 midi_intf = intf_nb;
elessair 0:f269e3021894 345 return true;
elessair 0:f269e3021894 346 }
elessair 0:f269e3021894 347
elessair 0:f269e3021894 348 return false;
elessair 0:f269e3021894 349 }
elessair 0:f269e3021894 350
elessair 0:f269e3021894 351 /*virtual*/ bool USBHostMIDI::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
elessair 0:f269e3021894 352 {
elessair 0:f269e3021894 353 if (intf_nb == midi_intf) {
elessair 0:f269e3021894 354 if (type == BULK_ENDPOINT) {
elessair 0:f269e3021894 355 midi_device_found = true;
elessair 0:f269e3021894 356 return true;
elessair 0:f269e3021894 357 }
elessair 0:f269e3021894 358 }
elessair 0:f269e3021894 359 return false;
elessair 0:f269e3021894 360 }
elessair 0:f269e3021894 361
elessair 0:f269e3021894 362 #endif