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 commandif(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));}
1 回答
富国沪深
TA贡献1790条经验 获得超9个赞
pCmdInRam是一个函数指针类型
定义了一个指向函数的指针就是FnCmdInRam
FnCmdInRam = (void*)((dword)&CmdInRam); 这句里面FnCmdInRam指向了CmdInRam这个函数
所以最后的
return(FnCmdInRam(0x40));
其实就是
return(Flash_Cmd(0x40));这样的
添加回答
举报
0/150
提交
取消