aboutsummaryrefslogtreecommitdiffstats
path: root/Bootloaders/Printer
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-03-06 19:48:27 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-03-06 19:48:27 +0000
commit7d4062fa54461c92ab2df02d630b33f672378780 (patch)
treed6ef24fbad6456546ecc63d248db535ad9a9f6d0 /Bootloaders/Printer
parent2e7fc37ad25448a3652d18a3d38c5151fd8e0db7 (diff)
downloadlufa-7d4062fa54461c92ab2df02d630b33f672378780.tar.gz
lufa-7d4062fa54461c92ab2df02d630b33f672378780.tar.bz2
lufa-7d4062fa54461c92ab2df02d630b33f672378780.zip
Use a temporary variable for the Printer bootloader HEX parser when combining the current and previous data tokens to form a data word, to simplify the code.
Diffstat (limited to 'Bootloaders/Printer')
-rw-r--r--Bootloaders/Printer/BootloaderPrinter.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Bootloaders/Printer/BootloaderPrinter.c b/Bootloaders/Printer/BootloaderPrinter.c
index fba323c2b..5d4a89bd3 100644
--- a/Bootloaders/Printer/BootloaderPrinter.c
+++ b/Bootloaders/Printer/BootloaderPrinter.c
@@ -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;
}