Uint16 CsmUnlock()
{
volatile Uint16 temp;
// Load the key registers with the current password
// These are defined in Example_Flash2802x_CsmKeys.asm
EALLOW;
CsmRegs.KEY0 = PRG_key0;
CsmRegs.KEY1 = PRG_key1;
CsmRegs.KEY2 = PRG_key2;
CsmRegs.KEY3 = PRG_key3;
CsmRegs.KEY4 = PRG_key4;
CsmRegs.KEY5 = PRG_key5;
CsmRegs.KEY6 = PRG_key6;
CsmRegs.KEY7 = PRG_key7;
EDIS;
// Perform a dummy read of the password locations
// if they match the key values, the CSM will unlock
temp = CsmPwl.PSWD0;
temp = CsmPwl.PSWD1;
temp = CsmPwl.PSWD2;
temp = CsmPwl.PSWD3;
temp = CsmPwl.PSWD4;
temp = CsmPwl.PSWD5;
temp = CsmPwl.PSWD6;
temp = CsmPwl.PSWD7;
// If the CSM unlocked, return succes, otherwise return
// failure.
if ( (CsmRegs.CSMSCR.all & 0x0001) == 0) return STATUS_SUCCESS;
else return STATUS_FAIL_CSM_LOCKED;
}
程序中 要对一块flash写操作,先要解锁。 那么写完flash 如何再次上锁?