Skip to content

Commit c333aa4

Browse files
author
Alrik Vidstrom
committed
Improve error handling at timeout
Set state to USB_TYPE_IDLE to allow recover from the error, but return the error. The previous solution didn't correctly report all errors.
1 parent 69326c0 commit c333aa4

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/USBHost/USBHost.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,8 @@ USB_TYPE USBHost::generalTransfer(USBDeviceConnected * dev, USBEndpoint * ep, ui
11451145
USB_DBG_TRANSFER("%s TRANSFER res: %s on ep: %p\r\n", type_str, ep->getStateString(), ep);
11461146

11471147
if (res != USB_TYPE_IDLE) {
1148+
// Set state to USB_TYPE_IDLE to allow recover from the error, but return the error
1149+
ep->setState(USB_TYPE_IDLE);
11481150
return res;
11491151
}
11501152

src/targets/TARGET_STM/USBEndpoint_STM.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ void USBEndpoint::setState(USB_TYPE st)
153153
USBx_HC(hced->ch_num)->HCCHAR &= ~USB_OTG_HCCHAR_CHDIS;
154154
USBx_HC(hced->ch_num)->HCCHAR |= USB_OTG_HCCHAR_CHENA;
155155
// <--
156-
// Set state to USB_TYPE_IDLE to allow the library to recover from the error.
157-
// WARNING: This might lead to some errors going unreported, and should be improved in the future, but
158-
// at least the library passes all our tests from higher levels at this point, which it didn't
159-
// do before.
160-
state = USB_TYPE_IDLE;
161156
}
162157
}
163158

0 commit comments

Comments
 (0)