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/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'firmware/main.c') 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