Skip to content

Commit c033f15

Browse files
turmaryLynnL4
authored andcommitted
Fix from: not checking epInterruptSummary() in commit 'USB: only clear pending interrupts explicitely'
1 parent e8a2eb0 commit c033f15

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

cores/arduino/USB/SAMD21_USBDevice.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,7 @@ class DoubleBufferedEPOutHandler : public EPHandler {
393393
}
394394
release();
395395
}
396-
if (usbd.epBank0IsTransferComplete(ep) || usbd.epBank1IsTransferComplete(ep)) {
397-
usbd.epAckPendingInterrupts(ep);
398-
}
396+
usbd.epAckPendingInterrupts(ep);
399397
}
400398

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

cores/arduino/USB/USBCore.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,9 @@ void USBDeviceClass::handleEndpoint(uint8_t ep)
300300
#if defined(CDC_ENABLED)
301301
if (ep == CDC_ENDPOINT_IN || ep == CDC_ENDPOINT_ACM)
302302
{
303-
if (usbd.epBank0IsTransferComplete(ep) || usbd.epBank1IsTransferComplete(ep)) {
304-
// NAK on endpoint IN, the bank is not yet filled in.
305-
usbd.epBank1ResetReady(ep);
306-
usbd.epBank1AckTransferComplete(ep);
307-
}
303+
// NAK on endpoint IN, the bank is not yet filled in.
304+
usbd.epBank1ResetReady(ep);
305+
usbd.epBank1AckTransferComplete(ep);
308306
return;
309307
}
310308
#endif
@@ -1012,11 +1010,18 @@ void USBDeviceClass::ISRHandler()
10121010
}
10131011

10141012
} // end Received Setup handler
1015-
// usbd.epAckPendingInterrupts(0);
10161013

1014+
uint8_t ept_int = usbd.epInterruptSummary() & 0xFE; // Remove endpoint number 0 (setup)
10171015
for (int ep = 1; ep < USB_EPT_NUM; ep++) {
1016+
// Check if endpoint has a pending interrupt
1017+
if ((ept_int & (1 << ep)) == 0) {
1018+
continue;
1019+
}
1020+
10181021
// Endpoint Transfer Complete (0/1) Interrupt
1019-
if (usbd.epHasPendingInterrupts(ep)) {
1022+
if (usbd.epBank0IsTransferComplete(ep) ||
1023+
usbd.epBank1IsTransferComplete(ep))
1024+
{
10201025
if (epHandlers[ep]) {
10211026
epHandlers[ep]->handleEndpoint();
10221027
} else {

0 commit comments

Comments
 (0)