Skip to content

Commit 1778496

Browse files
authored
Update USBCore.cpp
1 parent cb4437f commit 1778496

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

cores/arduino/USBCore.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,6 @@ bool SendDescriptor(USBSetup& setup)
466466
}
467467
#endif
468468

469-
if (t == 0x21) {
470-
InitControl(setup.wLength);
471-
int toSend = setup.wLength < hidClassDescriptorSize ? setup.wLength : hidClassDescriptorSize;
472-
USB_SendControl(TRANSFER_PGM, hidClassDescriptor, toSend);
473-
return true;
474-
}
475-
476469
if (t == 0x22) { // HID Report descriptor request
477470
return USB_SendControl(TRANSFER_PGM, hidDescriptor, hidDescriptorSize) > 0;
478471
}
@@ -846,17 +839,23 @@ ISR(USB_GEN_vect)
846839
// Therefore the we enable it only when USB is suspended
847840
if (udint & (1<<WAKEUPI))
848841
{
849-
USB_ClockEnable(); // restart PLL, unfreeze clock
850-
UDIEN = (UDIEN & ~(1<<WAKEUPE)) | (1<<SUSPE);
851-
UDINT &= ~(1<<WAKEUPI);
852-
_usbSuspendState &= ~(1<<SUSPI);
842+
UDIEN = (UDIEN & ~(1<<WAKEUPE)) | (1<<SUSPE); // Disable interrupts for WAKEUP and enable interrupts for SUSPEND
843+
844+
//TODO
845+
// WAKEUPI shall be cleared by software (USB clock inputs must be enabled before).
846+
//USB_ClockEnable();
847+
UDINT &= ~(1<<WAKEUPI);
848+
_usbSuspendState = (_usbSuspendState & ~(1<<SUSPI)) | (1<<WAKEUPI);
853849
}
854850
else if (udint & (1<<SUSPI)) // only one of the WAKEUPI / SUSPI bits can be active at time
855851
{
856-
USB_ClockDisable(); // stop PLL, freeze USB clock
857-
UDIEN = (UDIEN & ~(1<<SUSPE)) | (1<<WAKEUPE);
858-
UDINT &= ~((1<<WAKEUPI)|(1<<SUSPI));
859-
_usbSuspendState |= (1<<SUSPI);
852+
UDIEN = (UDIEN & ~(1<<SUSPE)) | (1<<WAKEUPE); // Disable interrupts for SUSPEND and enable interrupts for WAKEUP
853+
854+
//TODO
855+
//USB_ClockDisable();
856+
857+
UDINT &= ~((1<<WAKEUPI) | (1<<SUSPI)); // clear any already pending WAKEUP IRQs and the SUSPI request
858+
_usbSuspendState = (_usbSuspendState & ~(1<<WAKEUPI)) | (1<<SUSPI);
860859
}
861860
}
862861

0 commit comments

Comments
 (0)