typedef byte (*pCmdInRam)(byte cmd);
typedef struct {
unsigned char code[100];
} CmdInRam_t;
CmdInRam_t CmdInRam;
pCmdInRam FnCmdInRam; // FnCmdInRam 函数的指针
byte result;
byte Flash_Cmd(byte Cmd)
{
FCMD = Cmd;
FSTAT = 0x80; // launch command
if(FSTAT&0x30)
{
return 0xFF;
}
while(!FSTAT_FCCF){}
return 0x01;
}
// sector erase (1k bytes)
byte Flash_Erase(dword addr)
{
FnCmdInRam = (void*)((dword)&CmdInRam);
CmdInRam = *(CmdInRam_t *)(Flash_Cmd);
FSTAT = 0x30;
*(dword *)addr = 0x55;
return(FnCmdInRam(0x40));
}
富国沪深