I notice examples of Flash Programming.
////////////////////////////////////
This example:
#define IPSFLASH(x) (*(long*)(0x44000000 + (x)))
int runInRam(char cmd, long *addr, long val)
{
CFMSTAT = PVIOL | ACCERR;
IPSFLASH(addr)=val;
CFMCMD=cmd;
CFMSTAT=CBEIF;
while(!(CFMSTAT & (CCIF|PVIOL|ACCERR)));
return CFMSTAT & (PVIOL|ACCERR);
}
void runEND(void) {} // leave this immediately after runInRam
int flashProg(long *dest,long *src,int n)
{
char buf[200];
int(*ramCopy)(char,long,long) = (int(*)(char,long,long))buf;
memcpy(buf,(void*)runInRam, (char*)runEND - (char*)runInRam);
while(n--)
{
if(ramCopy(CMDPROG, dest++. *src++)) return -1;
}
return 0;
}
//////////////////////////////////
I know the function runInRam has to run in RAM. My question is how is the ramCopy function defined.
Thanks,