When the EP0 IN buffer is full, don't panic, just skip sending another
authorKeith Packard <keithp@keithp.com>
Mon, 26 Jul 2010 19:52:17 +0000 (12:52 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 26 Jul 2010 19:54:41 +0000 (12:54 -0700)
If the host doesn't pull the IN packet out of EP0 before sending
another SETUP command along, the IN buffer will still be busy when we
try to reply to the SETUP command. While I don't quite understand why
this would ever happen, there's no need to panic about it, just drop
the reply packet on the floor.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_usb.c

index d071fe6febfa8a7a41fc9d0e658774bb337f92e2..f6e0fcf91b54e83e643b46eeec599f5dacce06db 100644 (file)
@@ -82,10 +82,11 @@ ao_usb_ep0_flush(void)
        __xdata uint8_t this_len;
        __xdata uint8_t cs0;
 
+       /* If the IN packet hasn't been picked up, just return */
        USBINDEX = 0;
        cs0 = USBCS0;
        if (cs0 & USBCS0_INPKT_RDY)
-               ao_panic(AO_PANIC_USB);
+               return;
 
        this_len = ao_usb_ep0_in_len;
        if (this_len > AO_USB_CONTROL_SIZE)