summaryrefslogtreecommitdiff
path: root/avr
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2016-01-24 18:44:55 +0100
committerFlorian Jung <flo@windfisch.org>2016-01-24 18:44:55 +0100
commitdfc2f5fbfb5bb34d43fee7677486d8e8430f1f87 (patch)
tree84bc3b7f05399cfed39d5f5c4e743152b05f8afc /avr
parentc23307d11666127bfd495dba8839d0e54e23f0aa (diff)
can properly send data to avr
Diffstat (limited to 'avr')
-rw-r--r--avr/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/avr/main.c b/avr/main.c
index 9810e49..6774d6e 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -44,6 +44,7 @@
#define FUNC_GET_TYPE 0xFE
volatile int got_data = 0; // set to 1, if we get data to write from the PC
+volatile int recvd_data_len = 0;
void jump_to_bootloader(void)
@@ -70,7 +71,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
len = 0;
break;
case FUNC_READ:
- got_data = 1;
+ recvd_data_len = 0;
return USB_NO_MSG;
case FUNC_WRITE:
@@ -89,8 +90,11 @@ volatile int count = 5;
uchar usbFunctionWrite(uint8_t * data, uchar len)
{
- memcpy(replyBuffer,data,len);
- replyBuffer[len]='\0';
+ memcpy(replyBuffer+recvd_data_len,data,len);
+ recvd_data_len+=len;
+ if (recvd_data_len >= 33)
+ got_data = 1;
+ //replyBuffer[len]='\0';
return len;
}
@@ -153,7 +157,7 @@ int main(void)
wdt_reset(); // keep the watchdog happy
usbPoll();
- if (++c % (got_data ? 1500 : 3000) == 0)
+ if (++c % (got_data ? 1000 : 3000) == 0)
{
PORTC^=LED_BLUE;
PORTC |= LED_RED | LED_GREEN;