diff --git a/cores/arduino/USB/CDC.cpp b/cores/arduino/USB/CDC.cpp index 3c795f18e..c60388deb 100644 --- a/cores/arduino/USB/CDC.cpp +++ b/cores/arduino/USB/CDC.cpp @@ -150,6 +150,7 @@ void Serial_::begin(uint32_t /* baud_count */, uint8_t /* config */) void Serial_::end(void) { + memset((void*)&_usbLineInfo, 0, sizeof(_usbLineInfo)); } int Serial_::available(void) diff --git a/cores/arduino/USB/USBAPI.h b/cores/arduino/USB/USBAPI.h index 690488b79..379f55ed3 100644 --- a/cores/arduino/USB/USBAPI.h +++ b/cores/arduino/USB/USBAPI.h @@ -58,6 +58,7 @@ class USBDeviceClass { // USB Device API void init(); + bool end(); bool attach(); bool detach(); void setAddress(uint32_t addr); diff --git a/cores/arduino/USB/USBCore.cpp b/cores/arduino/USB/USBCore.cpp index 311903989..ee7b90a44 100644 --- a/cores/arduino/USB/USBCore.cpp +++ b/cores/arduino/USB/USBCore.cpp @@ -387,6 +387,13 @@ bool USBDeviceClass::detach() return true; } +bool USBDeviceClass::end() { + if (!initialized) + return false; + usbd.disable(); + return true; +} + bool USBDeviceClass::configured() { return _usbConfiguration != 0;