/* Erase Sector in Flash Memory Parameter: adr: Sector Address Return Value: 0 - OK, 1 - Failed  */
uint32_t EraseSector(uint32_t adr)
/* Erase Sector in Flash Memory Parameter: adr: Sector Address Return Value: 0 - OK, 1 - Failed  */
uint32_t EraseSector(uint32_t adr)
{
    cortex_int_state_t state = cortex_int_get_and_disable();
    int status = FLASH_Erase(&g_flash, adr, g_flash.PFlashSectorSize, kFLASH_ApiEraseKey);
    if (status == kStatus_Success)
    {
        status = FLASH_VerifyErase(&g_flash, adr, g_flash.PFlashSectorSize);
    }
    cortex_int_restore(state);
    return status;
}