Il y avait des problèmes dans la libraire...
Fork of USBDEVICE by
Diff: USBAudio/USBAudio.cpp
- Revision:
- 3:d9c7334e2183
- Parent:
- 1:2a3ae13b45ef
- Child:
- 4:50ec00aa4515
--- a/USBAudio/USBAudio.cpp Thu Dec 15 17:40:59 2016 +0100 +++ b/USBAudio/USBAudio.cpp Wed Feb 15 09:48:15 2017 +0100 @@ -85,7 +85,7 @@ SOF_handler = false; writeIN = false; if (interruptIN) { - USBDevice::writeNB(EP3IN, buf_write, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); + USBDevice::writeNB(EPISO_IN, buf_write, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); } else { buf_stream_out = buf_write; } @@ -102,7 +102,7 @@ writeIN = false; SOF_handler = false; if (interruptIN) { - USBDevice::writeNB(EP3IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); + USBDevice::writeNB(EPISO_IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); } else { buf_stream_out = buf; } @@ -113,6 +113,17 @@ return true; } +void USBAudio::writeSync(uint8_t *buf) +{ + USBDevice::writeNB(EPISO_IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); +} + +uint32_t USBAudio::readSync(uint8_t *buf) +{ + uint32_t size = 0; + USBDevice::readEP(EPISO_OUT, (uint8_t *)buf, &size, PACKET_SIZE_ISO_IN); + return size; +} float USBAudio::getVolume() { return (mute) ? 0.0 : volume; @@ -123,11 +134,15 @@ uint32_t size = 0; interruptOUT = true; if (buf_stream_in != NULL) { - readEP(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN); + readEP(EPISO_OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN); available = true; buf_stream_in = NULL; } - readStart(EP3OUT, PACKET_SIZE_ISO_IN); + else { + if (rxDone) + rxDone.call(); + } + readStart(EPISO_OUT, PACKET_SIZE_ISO_IN); return false; } @@ -135,6 +150,8 @@ bool USBAudio::EPISO_IN_callback() { interruptIN = true; writeIN = true; + if (txDone) + txDone.call(); return true; } @@ -147,10 +164,10 @@ if (!interruptOUT) { // read the isochronous endpoint if (buf_stream_in != NULL) { - if (USBDevice::readEP_NB(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN)) { + if (USBDevice::readEP_NB(EPISO_OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN)) { if (size) { available = true; - readStart(EP3OUT, PACKET_SIZE_ISO_IN); + readStart(EPISO_OUT, PACKET_SIZE_ISO_IN); buf_stream_in = NULL; } } @@ -160,7 +177,7 @@ if (!interruptIN) { // write if needed if (buf_stream_out != NULL) { - USBDevice::writeNB(EP3IN, (uint8_t *)buf_stream_out, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); + USBDevice::writeNB(EPISO_IN, (uint8_t *)buf_stream_out, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT); buf_stream_out = NULL; } } @@ -177,11 +194,11 @@ } // Configure isochronous endpoint - realiseEndpoint(EP3OUT, PACKET_SIZE_ISO_IN, ISOCHRONOUS); - realiseEndpoint(EP3IN, PACKET_SIZE_ISO_OUT, ISOCHRONOUS); + realiseEndpoint(EPISO_OUT, PACKET_SIZE_ISO_IN, ISOCHRONOUS); + realiseEndpoint(EPISO_IN, PACKET_SIZE_ISO_OUT, ISOCHRONOUS); // activate readings on this endpoint - readStart(EP3OUT, PACKET_SIZE_ISO_IN); + readStart(EPISO_OUT, PACKET_SIZE_ISO_IN); return true; }