From 97c7dd4c036340324b288e8d1fe0523510111a5d Mon Sep 17 00:00:00 2001 From: Stefan Lehmann Date: Sun, 22 Jul 2018 11:25:01 +0200 Subject: [PATCH 1/2] Remove USBSerial statementents USBSerial does not exist for Adafruit Feather M0 --- src/samd/ArduinoLowPower.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/samd/ArduinoLowPower.cpp b/src/samd/ArduinoLowPower.cpp index 8867d6e..2704ecf 100644 --- a/src/samd/ArduinoLowPower.cpp +++ b/src/samd/ArduinoLowPower.cpp @@ -16,6 +16,7 @@ void ArduinoLowPowerClass::idle(uint32_t millis) { } void ArduinoLowPowerClass::sleep() { + /* remove for Adafruit Feather M0 bool restoreUSBDevice = false; if (SerialUSB) { USBDevice.standby(); @@ -23,12 +24,15 @@ void ArduinoLowPowerClass::sleep() { USBDevice.detach(); restoreUSBDevice = true; } + */ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; __DSB(); __WFI(); + /* remove for Adafruit Feather M0 if (restoreUSBDevice) { USBDevice.attach(); } + */ } void ArduinoLowPowerClass::sleep(uint32_t millis) { @@ -100,4 +104,4 @@ void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callb ArduinoLowPowerClass LowPower; -#endif // ARDUINO_ARCH_SAMD \ No newline at end of file +#endif // ARDUINO_ARCH_SAMD From b2cb5059610676030ab6b91dd5d1757bdfa9a6ff Mon Sep 17 00:00:00 2001 From: Stefan Lehmann Date: Tue, 24 Jul 2018 18:49:50 +0200 Subject: [PATCH 2/2] Replace SerialUSB by SERIAL_PORT_USBVIRTUAL Support boards where USB serial is named differently. E.g. the Adafruit Feather M0 uses Serial1 as name for serial USB port. --- src/samd/ArduinoLowPower.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/samd/ArduinoLowPower.cpp b/src/samd/ArduinoLowPower.cpp index 2704ecf..d756ed6 100644 --- a/src/samd/ArduinoLowPower.cpp +++ b/src/samd/ArduinoLowPower.cpp @@ -16,23 +16,19 @@ void ArduinoLowPowerClass::idle(uint32_t millis) { } void ArduinoLowPowerClass::sleep() { - /* remove for Adafruit Feather M0 bool restoreUSBDevice = false; - if (SerialUSB) { + if (SERIAL_PORT_USBVIRTUAL) { USBDevice.standby(); } else { USBDevice.detach(); restoreUSBDevice = true; } - */ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; __DSB(); __WFI(); - /* remove for Adafruit Feather M0 if (restoreUSBDevice) { USBDevice.attach(); } - */ } void ArduinoLowPowerClass::sleep(uint32_t millis) {