/* Erase a Sector of FLASH This performs all operations necessary to erase a sector in FLASH memory. The page should be checked to ensure that it was properly erased. A sector must first be fully erased before attempting to program it. See the reference manual or the FLASH programming manual for details.  */
void flash_erase_sector(uint8_t sector)
/* Erase a Sector of FLASH This performs all operations necessary to erase a sector in FLASH memory. The page should be checked to ensure that it was properly erased. A sector must first be fully erased before attempting to program it. See the reference manual or the FLASH programming manual for details.  */
void flash_erase_sector(uint8_t sector)
{
	flash_wait_for_last_operation();
	FLASH_CR &= ~(FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT);
	FLASH_CR |= (sector & FLASH_CR_PNB_MASK) << FLASH_CR_PNB_SHIFT;
	FLASH_CR |= FLASH_CR_PER;
	FLASH_CR |= FLASH_CR_START;
	flash_wait_for_last_operation();
	FLASH_CR &= ~FLASH_CR_PER;
	FLASH_CR &= ~(FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT);
}