Skip to content

Commit 8cf4c73

Browse files
committed
[SAMD] Disable USB on standby()
1 parent 5456a1f commit 8cf4c73

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: src/samd/ArduinoLowPower.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ void ArduinoLowPowerClass::idle(uint32_t millis) {
1616
}
1717

1818
void ArduinoLowPowerClass::sleep() {
19-
USBDevice.standby();
19+
bool restoreUSBDevice = false;
20+
if (SerialUSB) {
21+
USBDevice.standby();
22+
} else {
23+
USBDevice.detach();
24+
restoreUSBDevice = true;
25+
}
2026
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
2127
__DSB();
2228
__WFI();
29+
if (restoreUSBDevice) {
30+
USBDevice.attach();
31+
}
2332
}
2433

2534
void ArduinoLowPowerClass::sleep(uint32_t millis) {

0 commit comments

Comments
 (0)