Hi All,
I've got an issue with flow control of a bulk OUT endpoint I'm struggling with. I'm using the NXP LPC1343, and the device code is based on their CDC class example. On the Host side, I'm using linux with libusb to do usb_bulk_write().
When there is data available on the endpoint, I USB_ReadEP() it out into a circular buffer IF I've got room in that buffer. If there's no room (ie the device is still processing old data), I don't do the USB_ReadEP() and hence the CMD_CLR_BUF bit does not get set in the peripheral. I would have expected the Host to retry sending that packet some time later, at which point I would have room and read the endpoint and everyone would be happy.
In the case where I dont read the endpoint on the device, the Host call to usb_bulk_write() function times out (even when I set the timeout to many seconds), and when I try to retry sending the packet again, it will always timeout. I can see at this time there are no interrupts being generated from the USB peripheral...
Am I going about flow control the wrong way here? Any advice would be greatly appreciated.
Thanks, Peter
Hi Tsuneo,
Thanks very much for the reply, nice idea putting the check in the SOF event handler.
By doing bulk_out_count++ it seems I get 1 more bulk_out_count than necessary, and get stuck in USB_ReadEP() in this loop:
do { cnt = LPC_USB->RxPLen; } while ((cnt &PKT_DV) == 0);
By changing bulk_out_count++ to bulk_out_count=1 in CDC_BulkOut() things are working really well.
Thanks again, Peter