/* Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 4096 bytes.  */
int32_t FMC_Erase(uint32_t u32PageAddr)
/* Execute FMC_ISPCMD_PAGE_ERASE command to erase a flash page. The page size is 4096 bytes.  */
int32_t FMC_Erase(uint32_t u32PageAddr)
{
    int32_t  ret = 0;
    int32_t i32TimeOutCnt;
    g_FMC_i32ErrCode = 0;
    FMC->ISPCMD = FMC_ISPCMD_PAGE_ERASE;
    FMC->ISPADDR = u32PageAddr;
    FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk;
    i32TimeOutCnt = FMC_TIMEOUT_ERASE;
    while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk)
    {
        if (i32TimeOutCnt-- <= 0)
        {
            g_FMC_i32ErrCode = -1;
            ret = -1;
            break;
        }
    }
    if (FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk)
    {
        FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk;
        g_FMC_i32ErrCode = -1;
        ret = -1;
    }
    return ret;
}