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 <keithp@keithp.com>
ao_usb_pollchar(void) __critical
{
char c;
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;
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];
}
--ao_usb_out_bytes;
c = USBFIFO[AO_USB_OUT_EP << 1];