Skip to content

Commit f80361f

Browse files
committed
Revert "USBDevice: interrupts are now enabled on init"
This reverts commit a8d208a. Fixes #423 on Linux/Mac (and Windows when Arduino standard drivers are uninstalled) Fix for normal behaviour on Windows is ongoing
1 parent 284bc5a commit f80361f

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Diff for: cores/arduino/USB/CDC.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#ifdef CDC_ENABLED
2929

30+
extern USBDevice_SAMD21G18x usbd;
31+
3032
#define CDC_SERIAL_BUFFER_SIZE 256
3133

3234
/* For information purpose only since RTS is not always handled by the terminal application */
@@ -184,6 +186,11 @@ Serial_::Serial_(USBDeviceClass &_usb) : PluggableUSBModule(3, 2, epType), usb(_
184186
PluggableUSB().plug(this);
185187
}
186188

189+
void Serial_::enableInterrupt() {
190+
usbd.epBank1EnableTransferComplete(CDC_ENDPOINT_ACM);
191+
usbd.epBank0EnableTransferComplete(CDC_ENDPOINT_OUT);
192+
}
193+
187194
void Serial_::begin(uint32_t /* baud_count */)
188195
{
189196
// uart config is ignored in USB-CDC

Diff for: cores/arduino/USB/CDC.h

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class Serial_ : public Stream, public PluggableUSBModule {
144144
bool setup(USBSetup& setup);
145145
uint8_t getShortName(char* name);
146146
void handleEndpoint(int ep);
147+
void enableInterrupt();
147148

148149
friend USBDeviceClass;
149150

Diff for: cores/arduino/USB/USBCore.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ void USBDeviceClass::initEP(uint32_t ep, uint32_t config)
405405
usbd.epBank1SetSize(ep, 64);
406406
usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);
407407
usbd.epBank1SetType(ep, 4); // INTERRUPT IN
408-
usbd.epBank1EnableTransferComplete(ep);
409408
}
410409
else if (config == (USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_OUT(0)))
411410
{
@@ -419,9 +418,6 @@ void USBDeviceClass::initEP(uint32_t ep, uint32_t config)
419418
usbd.epBank1SetSize(ep, 64);
420419
usbd.epBank1SetAddress(ep, &udd_ep_in_cache_buffer[ep]);
421420
usbd.epBank1SetType(ep, 3); // BULK IN
422-
423-
// XXX: this somehow interfere with CDC rx - WHY???
424-
// usbd.epBank1EnableTransferComplete(ep);
425421
}
426422
else if (config == USB_ENDPOINT_TYPE_CONTROL)
427423
{
@@ -437,9 +433,6 @@ void USBDeviceClass::initEP(uint32_t ep, uint32_t config)
437433

438434
// Release OUT EP
439435
usbd.epReleaseOutBank0(ep, 64);
440-
441-
// Enable Setup-Received interrupt
442-
usbd.epBank0EnableSetupReceived(ep);
443436
}
444437
}
445438

@@ -796,6 +789,10 @@ bool USBDeviceClass::handleStandardSetup(USBSetup &setup)
796789
initEndpoints();
797790
_usbConfiguration = setup.wValueL;
798791

792+
#ifdef CDC_ENABLED
793+
SerialUSB.enableInterrupt();
794+
#endif
795+
799796
sendZlp(0);
800797
return true;
801798
} else {
@@ -831,6 +828,9 @@ void USBDeviceClass::ISRHandler()
831828
// Configure EP 0
832829
initEP(0, USB_ENDPOINT_TYPE_CONTROL);
833830

831+
// Enable Setup-Received interrupt
832+
usbd.epBank0EnableSetupReceived(0);
833+
834834
_usbConfiguration = 0;
835835
}
836836

0 commit comments

Comments
 (0)