diff options
author | AJM <poslathian@poslathian.(none)> | 2010-04-25 15:19:41 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2010-05-20 22:09:15 -0400 |
commit | 8d6602547bc7beb39652a35a1cfdddc250f683ff (patch) | |
tree | e0ca6532b26db74654382a2db761b6bdc8ddd868 /core/usb | |
parent | 4dcbd9612275d7957484f4a87e16f0bb09484ee6 (diff) | |
download | librambutan-8d6602547bc7beb39652a35a1cfdddc250f683ff.tar.gz librambutan-8d6602547bc7beb39652a35a1cfdddc250f683ff.zip |
theres still a remaining bug whereby fast consecutive read/writes to serial might crash the fifo, but other than that it seems to work. see usbSendHello for an example. include usb.h in your application, and call setupUSB() to turn everything on.
Diffstat (limited to 'core/usb')
-rw-r--r-- | core/usb/usb.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/usb/usb.c b/core/usb/usb.c index c0229ff..f20f144 100644 --- a/core/usb/usb.c +++ b/core/usb/usb.c @@ -396,19 +396,17 @@ uint8 usbBytesAvailable(void) { will only copy the minimum of len or the available bytes. returns the number of bytes copied */ uint8 usbReceiveBytes(uint8* recvBuf, uint8 len) { - uint8 bytesCopied; - if (len > VCOM_RX_EPSIZE - maxNewBytes) { len = VCOM_RX_EPSIZE - maxNewBytes; } int i; for (i=0;i<len;i++) { - *recvBuf++ = vcomBufferRx[(recvBufOut++)%VCOM_RX_EPSIZE]; + recvBuf[i] = (uint8)(vcomBufferRx[(recvBufOut++)%VCOM_RX_EPSIZE]); } - maxNewBytes += bytesCopied; - return bytesCopied; + maxNewBytes += len; + return len; } void usbSendHello(void) { @@ -418,4 +416,7 @@ void usbSendHello(void) { char *line = "\n"; while(usbSendBytes(&thisVal,1) == 0); while(usbSendBytes((uint8*)line,1) == 0); + + uint8 recv[64]; + usbReceiveBytes(&recv[0],1); } |