int eraseAddress = 0x1000; int eraseEnd=0x2400; int sectorSize = 0x400; unsigned long PrepareCommand[4]; unsigned long results[3]; PrepareCommand[0]=50; PrepareCommand[1]=eraseAddress/sectorSize; PrepareCommand[2]=eraseEnd/sectorSize; iap_entry (PrepareCommand,results); unsigned long EraseCommand[4]; EraseCommand[0]=52; EraseCommand[1]=eraseAddress/sectorSize; EraseCommand[2]=eraseEnd/sectorSize; EraseCommand[3]=12000; iap_entry (EraseCommand,results); iap_entry (PrepareCommand,results); unsigned long CopyCommand[5]; CopyCommand[0]=51; CopyCommand[4]=12000; int startDestAddress=0x1000; int startSrcAddress=0x2800; int ProgramLength=0x1800; int idx=0; while(ProgramLength-idx*1024>0) { CopyCommand[1]=startDestAddress+idx*1024; CopyCommand[2]=startSrcAddress+idx*1024; //Needs to be a power of 2 greater than 64, up to 1024 if(ProgramLength-idx*1024>1024) { CopyCommand[3]=1024; } else { CopyCommand[3]=ProgramLength-idx*1024; } idx++; iap_entry (CopyCommand,results); } |
while(ProgramLength-idx*1024>0) { int temp[1024]; |
printf("Result Message: %d",results[0]); |
int eraseAddress = 0x1000; int eraseEnd=0x2400; int sectorSize = 0x400; unsigned long PrepareCommand[4]; unsigned long results[3]; PrepareCommand[0]=50; PrepareCommand[1]=eraseAddress/sectorSize; PrepareCommand[2]=eraseEnd/sectorSize; iap_entry (PrepareCommand,results); unsigned long EraseCommand[4]; EraseCommand[0]=52; EraseCommand[1]=eraseAddress/sectorSize; EraseCommand[2]=eraseEnd/sectorSize; EraseCommand[3]=12000; iap_entry (EraseCommand,results); iap_entry (PrepareCommand,results); unsigned long CopyCommand[5]; CopyCommand[0]=51; CopyCommand[4]=12000; int startDestAddress=0x1000; int startSrcAddress=0x2800; int ProgramLength=0x1800; int idx=0; while(ProgramLength-idx*1024>0) { int temp[1024]; CopyCommand[1]=startDestAddress+idx*1024; //Add a memcpy to move to RAM memcpy(temp, (void *) startSrcAddress+idx*1024, 1024); CopyCommand[2]=*temp; //Needs to be a power of 2 greater than 64, up to 1024 if(ProgramLength-idx*1024>1024) { CopyCommand[3]=1024; } else { CopyCommand[3]=ProgramLength-idx*1024; } idx++; iap_entry (CopyCommand,results); } |