aboutsummaryrefslogtreecommitdiffstats
path: root/core/usb
diff options
context:
space:
mode:
authorAJM <poslathian@poslathian.(none)>2010-04-25 16:13:07 -0400
committerbnewbold <bnewbold@robocracy.org>2010-05-20 22:09:16 -0400
commitfc4b9b386a80d06c73e03d70767643aae3961e2a (patch)
treef3ea4c4eeecc247ac964311702767b0a2532c3ab /core/usb
parent7b1e00bca888247efddddd28912d51e9ba7112ba (diff)
downloadlibrambutan-fc4b9b386a80d06c73e03d70767643aae3961e2a.tar.gz
librambutan-fc4b9b386a80d06c73e03d70767643aae3961e2a.zip
fixed the receive 0 bytes bug, where full buffers block the usb port and never get re-enabled.
Diffstat (limited to 'core/usb')
-rw-r--r--core/usb/usb.c8
1 files changed, 8 insertions, 0 deletions
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];