From dfc2f5fbfb5bb34d43fee7677486d8e8430f1f87 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 24 Jan 2016 18:44:55 +0100 Subject: can properly send data to avr --- avr/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'avr') 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; -- cgit v1.2.3