From 2430d649ea6f91d45d37b254f4c0a55e67b6f0f4 Mon Sep 17 00:00:00 2001 From: Neil Thiessen Date: Wed, 11 Jun 2014 13:40:18 -0600 Subject: [PATCH] Reset device to initial state in disconnect() Added code to reset the device to the initial state when disconnect() is called. This prevents calls to configured() from returning true when the device has been disconnected. --- libraries/USBDevice/USBDevice/USBDevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/USBDevice/USBDevice/USBDevice.cpp b/libraries/USBDevice/USBDevice/USBDevice.cpp index 53659164a79..0f08932a80d 100644 --- a/libraries/USBDevice/USBDevice/USBDevice.cpp +++ b/libraries/USBDevice/USBDevice/USBDevice.cpp @@ -718,6 +718,11 @@ void USBDevice::disconnect(void) { /* Disconnect device */ USBHAL::disconnect(); + + /* Set initial device state */ + device.state = POWERED; + device.configuration = 0; + device.suspended = false; } CONTROL_TRANSFER * USBDevice::getTransferPtr(void)