From fc4b9b386a80d06c73e03d70767643aae3961e2a Mon Sep 17 00:00:00 2001 From: AJM Date: Sun, 25 Apr 2010 16:13:07 -0400 Subject: fixed the receive 0 bytes bug, where full buffers block the usb port and never get re-enabled. --- core/usb/usb.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/usb') diff --git a/core/usb/usb.c b/core/usb/usb.c index cb8de52..a8298c0 100644 --- a/core/usb/usb.c +++ b/core/usb/usb.c @@ -407,6 +407,12 @@ uint8 usbReceiveBytes(uint8* recvBuf, uint8 len) { } maxNewBytes += len; + + /* re-enable the rx endpoint which we had set to receive 0 bytes */ + if (maxNewBytes - len == 0) { + SetEPRxCount(VCOM_RX_ENDP,maxNewBytes); + } + return len; } @@ -415,10 +421,12 @@ void usbSendHello(void) { uint8 bufin = 48 + recvBufIn;; uint8 bufout = 48 + recvBufOut; + uint8 avail = 48 + usbBytesAvailable(); char *line = "\r\n"; while(usbSendBytes(&bufin,1) == 0); while(usbSendBytes(&bufout,1) == 0); + while(usbSendBytes(&avail,1) == 0); while(usbSendBytes((uint8*)line,2) == 0); uint8 recv[64]; -- cgit v1.2.3