Skip to content

Commit 8ac782d

Browse files
cmagliefacchinm
authored andcommitted
USBDevice: pending interrupts flag are now automatically acknowledged
1 parent a46a5b0 commit 8ac782d

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

cores/arduino/USB/CDC.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ uint8_t Serial_::getShortName(char* name) {
117117
return 32;
118118
}
119119

120-
void Serial_::handleEndpoint(int ep) {
121-
usbd.epAckPendingInterrupts(ep);
120+
void Serial_::handleEndpoint(int /* ep */) {
122121
}
123122

124123
bool Serial_::setup(USBSetup& setup)

cores/arduino/USB/USBCore.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,6 @@ void USBDeviceClass::ISRHandler()
833833
// Endpoint 0 Received Setup interrupt
834834
if (usbd.epBank0IsSetupReceived(0))
835835
{
836-
usbd.epBank0AckSetupReceived(0);
837-
838836
USBSetup *setup = reinterpret_cast<USBSetup *>(udd_ep_out_cache_buffer[0]);
839837

840838
delayMicroseconds(10);
@@ -859,24 +857,23 @@ void USBDeviceClass::ISRHandler()
859857

860858
if (usbd.epBank1IsStalled(0))
861859
{
862-
usbd.epBank1AckStalled(0);
863-
864860
// Remove stall request
865861
usbd.epBank1DisableStalled(0);
866862
}
867-
868863
} // end Received Setup handler
864+
usbd.epAckPendingInterrupts(0);
869865

870-
for (int i = 1; i < USB_EPT_NUM; i++) {
866+
for (int ep = 1; ep < USB_EPT_NUM; ep++) {
871867
// Endpoint Transfer Complete (0/1) Interrupt
872-
if (usbd.epBank0IsTransferComplete(i) || usbd.epBank1IsTransferComplete(i)) {
873-
if (epHandlers[i]) {
874-
epHandlers[i]->handleEndpoint();
868+
if (usbd.epHasPendingInterrupts(ep)) {
869+
if (epHandlers[ep]) {
870+
epHandlers[ep]->handleEndpoint();
875871
} else {
876872
#if defined(PLUGGABLE_USB_ENABLED)
877-
PluggableUSB().handleEndpoint(i);
873+
PluggableUSB().handleEndpoint(ep);
878874
#endif
879875
}
876+
usbd.epAckPendingInterrupts(ep);
880877
}
881878
}
882879
}

0 commit comments

Comments
 (0)