/* Erase complete Flash Memory Return Value: 0 - OK, 1 - Failed  */
uint32_t EraseChip(void)
/* Erase complete Flash Memory Return Value: 0 - OK, 1 - Failed  */
uint32_t EraseChip(void)
{
    cortex_int_state_t state = cortex_int_get_and_disable();
    int status = FLASH_EraseAll(&g_flash, kFLASH_apiEraseKey);
    if (status == kStatus_Success)
    {
        status = FLASH_VerifyEraseAll(&g_flash, kFLASH_marginValueNormal);
    }
    cortex_int_restore(state);
    return status;
}