/* Execute ISP commands to erase then write User Configuration.  */
int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
/* Execute ISP commands to erase then write User Configuration.  */
int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
{
    int   i;
    FMC_ENABLE_CFG_UPDATE();
    FMC_Erase(FMC_CONFIG_BASE);
    if ((FMC_Read(FMC_CONFIG_BASE) != 0xFFFFFFFF) || (FMC_Read(FMC_CONFIG_BASE+4) != 0xFFFFFFFF) ||
            (FMC_Read(FMC_CONFIG_BASE+8) != 0xFFFF5A5A))
    {
        FMC_DISABLE_CFG_UPDATE();
        return -1;
    }
    for (i = 0; i < u32Count; i++)
    {
        FMC_Write(FMC_CONFIG_BASE+i*4UL, u32Config[i]);
        if (FMC_Read(FMC_CONFIG_BASE+i*4UL) != u32Config[i])
        {
            FMC_DISABLE_CFG_UPDATE();
            return -1;
        }
    }
    FMC_DISABLE_CFG_UPDATE();
    return 0;
}