aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/usb/usb.c10
-rw-r--r--core/usb/usb_callbacks.c2
2 files changed, 8 insertions, 4 deletions
diff --git a/core/usb/usb.c b/core/usb/usb.c
index f20f144..da0f37a 100644
--- a/core/usb/usb.c
+++ b/core/usb/usb.c
@@ -402,7 +402,8 @@ uint8 usbReceiveBytes(uint8* recvBuf, uint8 len) {
int i;
for (i=0;i<len;i++) {
- recvBuf[i] = (uint8)(vcomBufferRx[(recvBufOut++)%VCOM_RX_EPSIZE]);
+ recvBuf[i] = (uint8)(vcomBufferRx[recvBufOut]);
+ recvBufOut = (recvBufOut + 1) % VCOM_RX_EPSIZE;
}
maxNewBytes += len;
@@ -412,9 +413,12 @@ uint8 usbReceiveBytes(uint8* recvBuf, uint8 len) {
void usbSendHello(void) {
char* myStr = "hello!";
- uint8 thisVal = 48 + usbBytesAvailable();
+ uint8 bufin = 48 + recvBufIn;;
+ uint8 bufout = 48 + recvBufOut;
+
char *line = "\n";
- while(usbSendBytes(&thisVal,1) == 0);
+ while(usbSendBytes(&bufin,1) == 0);
+ while(usbSendBytes(&bufout,1) == 0);
while(usbSendBytes((uint8*)line,1) == 0);
uint8 recv[64];
diff --git a/core/usb/usb_callbacks.c b/core/usb/usb_callbacks.c
index 1fb73d5..f4c491b 100644
--- a/core/usb/usb_callbacks.c
+++ b/core/usb/usb_callbacks.c
@@ -73,7 +73,7 @@ void vcomDataRxCb(void) {
PMAToUserBufferCopy(&vcomBufferRx[recvBufIn],VCOM_RX_ADDR,tailBytes);
PMAToUserBufferCopy(&vcomBufferRx[0], VCOM_RX_ADDR,remaining);
- recvBufIn += (newBytes % VCOM_RX_EPSIZE);
+ recvBufIn = (recvBufIn + newBytes ) % VCOM_RX_EPSIZE;
}
maxNewBytes -= newBytes;