From bda177784ad97bd3934bb2359621c5c5460805ef Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Mon, 16 Dec 2013 09:38:22 +0100 Subject: firmware: Clean buffer at begin of write improve robustness --- firmware/Makefile | 2 +- firmware/main.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'firmware') 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); -- cgit v1.2.3