/* Erase a Page of FLASH. 
Note that the page sizes differ between devices. See the reference manual or the FLASH programming manual for details. */
void flash_erase_page(uint32_t page_address)
/* Erase a Page of FLASH. 
Note that the page sizes differ between devices. See the reference manual or the FLASH programming manual for details. */
void flash_erase_page(uint32_t page_address)
{
	flash_wait_for_last_operation();
	if ((desig_get_flash_size() > 512)
	    && (page_address >= FLASH_BASE+0x00080000)) {
		FLASH_CR2 |= FLASH_CR_PER;
		FLASH_AR2 = page_address;
		FLASH_CR2 |= FLASH_CR_STRT;
	} else  {
		FLASH_CR |= FLASH_CR_PER;
		FLASH_AR = page_address;
		FLASH_CR |= FLASH_CR_STRT;
	}
	flash_wait_for_last_operation();
	if ((desig_get_flash_size() > 512)
	    && (page_address >= FLASH_BASE+0x00080000)) {
		FLASH_CR2 &= ~FLASH_CR_PER;
	} else {
		FLASH_CR &= ~FLASH_CR_PER;
	}
}