diff options
Diffstat (limited to 'avr')
-rw-r--r-- | avr/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; |