// erase fun
INTU8 STORELOC_Erase(INTU32 u32addr)
{
FMC->ISPCMD.FCTRL = 2;
FMC->ISPCMD.FCEN = 0;
FMC->ISPCMD.FOEN = 1;
FMC->ISPADR = u32addr;
FMC->ISPTRG.ISPGO = 1;
if (FMC->ISPCON.ISPFF == 1)
{
FMC->ISPCON.ISPFF = 0;
return FALSE;
}
return TRUE;
}
INTU8 STORELOC_Write(INTU32 u32addr, INTU32 u32data)
{
FMC->ISPCMD.FCTRL = 1;
FMC->ISPCMD.FCEN = 0;
FMC->ISPCMD.FOEN = 1;
FMC->ISPADR = u32addr;
FMC->ISPDAT = u32data;
FMC->ISPTRG.ISPGO = 1;
if (FMC->ISPCON.ISPFF == 1)
{
FMC->ISPCON.ISPFF = 1;
return FALSE;
}
return TRUE;
}
void APP_Program(INTU8 page,INTU32* PBuf)
{
INTU16 i,j;
INTU32 addr;
UNLOCKREG();
addr=page*512+STORELOC_DATA_BASE; //STORELOC_DATA_BASE=0x8000
STORELOC_Erase(addr);
for (i=0,j=0;i<512;i+=4)
{
STORELOC_Write(addr+i,PBuf[j++]);
}
dfu.deviceState=DEVICE_IDLE;
dfu.dfuRecvCnt=0;
}
发现0X8000后面的数据不会变,都是FF |