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 | |
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')
-rw-r--r-- | firmware/Makefile | 2 | ||||
-rw-r--r-- | firmware/main.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/firmware/Makefile b/firmware/Makefile index 9da5be6..459052b 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -190,7 +190,7 @@ read_fuses: $(UISP) --rd_fuses clean: - rm -f main.hex main.bin main.c.lst main.map *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s libs-device/osccalASM.o *.lss + rm -f main.hex main.bin main.c.lst main.map *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s *.lss # file targets: main.bin: $(OBJECTS) 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); |