/* Flushes a partially written page of data to physical FLASH, if a page boundary has been crossed. */
static void FlushPageIfRequired(void)
/* Flushes a partially written page of data to physical FLASH, if a page boundary has been crossed. */
static void FlushPageIfRequired(void)
{
	if (!PageDirty)
	  return;
	uint32_t NewPageStartAddress = (HEXParser.CurrAddress & ~(SPM_PAGESIZE - 1));
	if (HEXParser.PageStartAddress != NewPageStartAddress)
	{
		BootloaderAPI_WritePage(HEXParser.PageStartAddress);
		HEXParser.PageStartAddress = NewPageStartAddress;
		PageDirty = false;
	}
}