From 3ece984f4d72b4f720a5efdfaad7cff77a93d676 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 4 Nov 2009 21:32:07 -0800 Subject: [PATCH] In USB pollchar, wait for packet before re-checking USB out len This probably wouldn't actually cause a problem, but it seems more reliable to wait for a packet interrupt before re-reading the packet OUT len register. This could avoid spinning while waiting for a USB packet, which seems like a good thing. Signed-off-by: Keith Packard --- src/ao_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ao_usb.c b/src/ao_usb.c index daca71a7..527e9b30 100644 --- a/src/ao_usb.c +++ b/src/ao_usb.c @@ -377,11 +377,13 @@ char ao_usb_pollchar(void) __critical { char c; - while (ao_usb_out_bytes == 0) { + if (ao_usb_out_bytes == 0) { USBINDEX = AO_USB_OUT_EP; if ((USBCSOL & USBCSOL_OUTPKT_RDY) == 0) return AO_READ_AGAIN; ao_usb_out_bytes = (USBCNTH << 8) | USBCNTL; + if (ao_usb_out_bytes == 0) + return AO_READ_AGAIN; } --ao_usb_out_bytes; c = USBFIFO[AO_USB_OUT_EP << 1]; -- 2.30.2