aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/usb.c
diff options
context:
space:
mode:
authorAndrew J Meyer <ajm@leaflabs.com>2011-07-01 16:28:40 -0400
committerAndrew J Meyer <ajm@leaflabs.com>2011-07-01 16:28:40 -0400
commit80d5fd1f5118428857de730728233eb7d174a1a2 (patch)
tree23248c61beb6029a444c6ce99f962e91198ac465 /libmaple/usb/usb.c
parentac19671c33527c0f40b14e42f3c033cdbb808a79 (diff)
downloadlibrambutan-80d5fd1f5118428857de730728233eb7d174a1a2.tar.gz
librambutan-80d5fd1f5118428857de730728233eb7d174a1a2.zip
fixed a bug in usbreceivebytes
bug prevented consecutive SerialUSB.read() calls from returning consecutive bytes
Diffstat (limited to 'libmaple/usb/usb.c')
-rw-r--r--libmaple/usb/usb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c
index 617c1ee..651b36e 100644
--- a/libmaple/usb/usb.c
+++ b/libmaple/usb/usb.c
@@ -376,21 +376,25 @@ uint32 usbBytesAvailable(void) {
will only copy the minimum of len or the available
bytes. returns the number of bytes copied */
uint32 usbReceiveBytes(uint8* recvBuf, uint32 len) {
+ static int offset = 0;
+
if (len > newBytes) {
len = newBytes;
}
int i;
for (i=0;i<len;i++) {
- recvBuf[i] = (uint8)(vcomBufferRx[i]);
+ recvBuf[i] = (uint8)(vcomBufferRx[i+offset]);
}
newBytes -= len;
+ offset += len;
/* re-enable the rx endpoint which we had set to receive 0 bytes */
if (newBytes == 0) {
SetEPRxCount(VCOM_RX_ENDP,VCOM_RX_EPSIZE);
SetEPRxStatus(VCOM_RX_ENDP,EP_RX_VALID);
+ offset = 0;
}
return len;