aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/hal_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/src/hal_usb.c')
-rw-r--r--os/hal/src/hal_usb.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/os/hal/src/hal_usb.c b/os/hal/src/hal_usb.c
index e58055714..451b19aa4 100644
--- a/os/hal/src/hal_usb.c
+++ b/os/hal/src/hal_usb.c
@@ -751,8 +751,17 @@ void _usb_wakeup(USBDriver *usbp) {
void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
size_t max;
- osalDbgAssert(usbp->ep0state == USB_EP0_STP_WAITING, "not in setup state");
+ /* Is the EP0 state machine in the correct state for handling setup
+ packets?*/
+ if (usbp->ep0state != USB_EP0_STP_WAITING) {
+ /* This is unexpected could require handling with a warning event.*/
+ /* TODO: handling here.*/
+ /* Resetting the EP0 state machine and going ahead.*/
+ usbp->ep0state = USB_EP0_STP_WAITING;
+ }
+
+ /* Reading the setup data into the driver buffer.*/
usbReadSetup(usbp, ep, usbp->setup);
/* First verify if the application has an handler installed for this