diff options
author | cpldcpu <cpldcpu@gmail.com> | 2013-12-16 09:38:22 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2013-12-16 09:38:22 +0100 |
commit | bda177784ad97bd3934bb2359621c5c5460805ef (patch) | |
tree | 429ee39e36d9b04cfe64e7a26536b01e1b5d7b62 /firmware/main.c | |
parent | 5840482bc934c79bc810352a3d65fa9a0d100cce (diff) | |
download | micronucleus-bda177784ad97bd3934bb2359621c5c5460805ef.tar.gz micronucleus-bda177784ad97bd3934bb2359621c5c5460805ef.tar.bz2 micronucleus-bda177784ad97bd3934bb2359621c5c5460805ef.zip |
firmware: Clean buffer at begin of write
improve robustness
Diffstat (limited to 'firmware/main.c')
-rw-r--r-- | firmware/main.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/firmware/main.c b/firmware/main.c index 04b0e33..a7deccc 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -179,6 +179,10 @@ static uint8_t usbFunctionSetup(uint8_t data[8]) { return 4; } else if (rq->bRequest == 1) { // write page + + // clear page buffer as a precaution before filling the buffer in case + // a previous write operation failed and there is still something in the buffer. + __boot_page_fill_clear(); currentAddress = rq->wIndex.word; return USB_NO_MSG; // hands off work to usbFunctionWrite @@ -242,10 +246,6 @@ static void initHardware (void) CLKPR = 0; #endif - // clear page buffer as a precaution before filling the buffer on the first page - // in case the bootloader somehow ran after user program and there was something - // in the page buffer already - __boot_page_fill_clear(); usbDeviceDisconnect(); /* do this while interrupts are disabled */ _delay_ms(500); |