/* Program a Half Word to FLASH. 
Status bit polling is used to detect end of operation. */
void flash_program_half_word(uint32_t address, uint16_t data)
/* Program a Half Word to FLASH. 
Status bit polling is used to detect end of operation. */
void flash_program_half_word(uint32_t address, uint16_t data)
{
	flash_wait_for_last_operation();
	if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) {
		FLASH_CR2 |= FLASH_CR_PG;
	} else {
		FLASH_CR |= FLASH_CR_PG;
	}
	MMIO16(address) = data;
	flash_wait_for_last_operation();
	if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) {
		FLASH_CR2 &= ~FLASH_CR_PG;
	} else {
		FLASH_CR &= ~FLASH_CR_PG;
	}
}