- for (;;) {
- USBINDEX = AO_USB_IN_EP;
- if ((USBCSIL & USBCSIL_INPKT_RDY) == 0)
- break;
- ao_sleep(&ao_usb_in_bytes);
+
+ /* If there are pending bytes, or if the last packet was full,
+ * send another IN packet
+ */
+ if (ao_usb_in_bytes || (ao_usb_in_bytes_last == AO_USB_IN_SIZE)) {
+ ao_usb_in_wait();
+ ao_usb_in_send();