From f1e6a55322f18fe69293ce9cc4e1da31a589ea6f Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 22 Aug 2017 07:52:33 +0000 Subject: Tentative fix for L4 OTG. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10454 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_usb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'os/hal/src') 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 -- cgit v1.2.3