X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/2e7fc37ad25448a3652d18a3d38c5151fd8e0db7..31d3984d8d8afeed7b1e064428b01e42fe27f2f9:/Bootloaders/Printer/BootloaderPrinter.c diff --git a/Bootloaders/Printer/BootloaderPrinter.c b/Bootloaders/Printer/BootloaderPrinter.c index fba323c2b..9a6a8c27f 100644 --- a/Bootloaders/Printer/BootloaderPrinter.c +++ b/Bootloaders/Printer/BootloaderPrinter.c @@ -80,7 +80,7 @@ static bool PageDirty = false; * * \param[in] Byte ASCII byte of data to check * - * \return Boolean \c true if the input data is ASCII encoded HEX, false otherwise. + * \return Boolean \c true if the input data is ASCII encoded HEX, \c false otherwise. */ static bool IsHex(const char Byte) { @@ -189,6 +189,9 @@ static void ParseIntelHEXByte(const char ReadCharacter) break; } + /* Convert the last two received data bytes into a 16-bit word */ + uint16_t NewDataWord = ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData; + switch (HEXParser.RecordType) { case HEX_RECORD_TYPE_Data: @@ -204,7 +207,7 @@ static void ParseIntelHEXByte(const char ReadCharacter) } /* Fill the FLASH memory buffer with the new word of data */ - boot_page_fill(HEXParser.CurrAddress, ((uint16_t)HEXParser.Data << 8) | HEXParser.PrevData); + boot_page_fill(HEXParser.CurrAddress, NewDataWord); HEXParser.CurrAddress += 2; /* Flush the FLASH page to physical memory if we are crossing a page boundary */ @@ -222,12 +225,12 @@ static void ParseIntelHEXByte(const char ReadCharacter) case HEX_RECORD_TYPE_ExtendedSegmentAddress: /* Extended address data - store the upper 12-bits of the new address */ - HEXParser.CurrBaseAddress = (((uint32_t)HEXParser.PrevData << 8) | HEXParser.Data) << 4; + HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 4); break; case HEX_RECORD_TYPE_ExtendedLinearAddress: /* Extended address data - store the upper 16-bits of the new address */ - HEXParser.CurrBaseAddress = (((uint32_t)HEXParser.PrevData << 8) | HEXParser.Data) << 16; + HEXParser.CurrBaseAddress = ((uint32_t)NewDataWord << 16); break; } @@ -296,7 +299,7 @@ int main(void) } /** Configures the board hardware and chip peripherals for the demo's functionality. */ -void SetupHardware(void) +static void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); @@ -332,7 +335,7 @@ void EVENT_USB_Device_Connect(void) } /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via - * the status LEDs and stops the Mass Storage management task. + * the status LEDs and stops the Printer management task. */ void EVENT_USB_Device_Disconnect(void) {