X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/cae0fa73d70f82820bd8d71c4d60b6aff8ccf3cb..2e6370a6b9a4893d686a8beba603b12be0376ea6:/Bootloaders/HID/BootloaderHID.c diff --git a/Bootloaders/HID/BootloaderHID.c b/Bootloaders/HID/BootloaderHID.c index 9c6b3e051..4a439544f 100644 --- a/Bootloaders/HID/BootloaderHID.c +++ b/Bootloaders/HID/BootloaderHID.c @@ -39,7 +39,7 @@ * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application * started via a forced watchdog reset. */ -bool RunBootloader = true; +static bool RunBootloader = true; /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously * runs the bootloader processing routine until instructed to soft-exit. @@ -113,10 +113,18 @@ void EVENT_USB_Device_ControlRequest(void) while (!(Endpoint_IsOUTReceived())); /* Read in the write destination address */ - uint16_t PageAddress = Endpoint_Read_Word_LE(); + #if (FLASHEND > 0xFFFF) + uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8); + #else + uint16_t PageAddress = Endpoint_Read_16_LE(); + #endif /* Check if the command is a program page command, or a start application command */ + #if (FLASHEND > 0xFFFF) + if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION) + #else if (PageAddress == COMMAND_STARTAPPLICATION) + #endif { RunBootloader = false; } @@ -127,7 +135,7 @@ void EVENT_USB_Device_ControlRequest(void) boot_spm_busy_wait(); /* Write each of the FLASH page's bytes in sequence */ - for (uint16_t PageByte = 0; PageByte < SPM_PAGESIZE; PageByte += 2) + for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++) { /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint())) @@ -137,7 +145,7 @@ void EVENT_USB_Device_ControlRequest(void) } /* Write the next data word to the FLASH page */ - boot_page_fill(PageAddress + PageByte, Endpoint_Read_Word_LE()); + boot_page_fill(PageAddress + ((uint16_t)PageWord << 1), Endpoint_Read_16_LE()); } /* Write the filled FLASH page to memory */