Skip to content

Commit a46a5b0

Browse files
cmagliefacchinm
authored andcommitted
USBDevice: EPOUTHandler ISR now has a single exit point
1 parent 3c84f7c commit a46a5b0

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

cores/arduino/USB/SAMD21_USBDevice.h

+9-16
Original file line numberDiff line numberDiff line change
@@ -336,43 +336,36 @@ class DoubleBufferedEPOutHandler : public EPHandler {
336336
// W : last0/1, notify
337337
if (usbd.epBank0IsTransferComplete(ep))
338338
{
339-
// Ack Transfer complete
340-
usbd.epBank0AckTransferComplete(ep);
341-
//usbd.epBank0AckTransferFailed(ep); // XXX
342339
uint32_t received = usbd.epBank0ByteCount(ep);
343340
if (received == 0) {
344341
release();
345-
return;
346-
}
347-
342+
} else if (incoming == 0) {
348343
// Update counters and swap banks for non-ZLP's
349-
if (incoming == 0) {
350344
last0 = received;
351345
incoming = 1;
352346
usbd.epBank0SetAddress(ep, const_cast<uint8_t *>(data1));
353347
synchronized {
354348
ready0 = true;
355-
if (ready1) {
356-
notify = true;
357-
return;
349+
notify = ready1;
350+
if (!notify) {
351+
release();
358352
}
359-
notify = false;
360353
}
361354
} else {
362355
last1 = received;
363356
incoming = 0;
364357
usbd.epBank0SetAddress(ep, const_cast<uint8_t *>(data0));
365358
synchronized {
366359
ready1 = true;
367-
if (ready0) {
368-
notify = true;
369-
return;
360+
notify = ready0;
361+
if (!notify) {
362+
release();
370363
}
371-
notify = false;
372364
}
373365
}
374-
release();
375366
}
367+
368+
usbd.epAckPendingInterrupts(ep);
376369
}
377370

378371
// Returns how many bytes are stored in the buffers

0 commit comments

Comments
 (0)