voidReadProtectMemory(uchar*p)
{uchari=4;
Command(0x34,0xff,0xff);
do{*p=ReceiveData();
p++;}while(i--);
}
/************写主存储器************/
voidWriteMainMemory(ucharAddress,ucharData)
{Command(0x38,Address,Data);
Process();
}
/**************写保护存储器**********/
voidWriteProtectMemory(ucharAddress,ucharData)
{Command(0x3c,Address,Data);
Process();
}
/**************读安全存储器************/
voidReadSafeMemory(uchar*p)
{uchari;
Command(0x31,0xff,0xff);
for(i=0;i《4;i++)
{*p=ReceiveData();
p++;}
}
/*************写安全存储器***************/
voidWriteSafeMemory(ucharAddress,ucharData)
{Command(0x39,Address,Data);//Address=0,1,2,3
Process();
}
/**************校验密码*******************/
ucharVerifyPassword(uchar*p)
{uchartemp[4];//暂存4字节保护密码;
uchari;
ReadSafeMemory(temp);//读安全代码以取得错误计数器
if((temp[0]&0x07)!=0)
{if((temp[0]&0x07)==0x07)i=0x06;
if((temp[0]&0x07)==0x06)i=0x04;
if((temp[0]&0x07)==0x04)i=0x00;
WriteSafeMemory(0,i);
for(i=1;i《4;i++,p++)
{Command(0x33,i,*p);
Process();}
WriteSafeMemory(0,0xff);
ReadSafeMemory(temp);
if((temp[0]&0x07)==0x07)return(0x1);
}
return(0);
}
//*************SLE4442函数结束*****************//
//*************数据变换**********//
voidChange(uchar*Source,uchar*Destination,ucharN)
{uchari,temp;
for(i=0;i{temp=Source[i];
Destination[i]=temp》》4;
Destination[2*i+1]=temp&0x0f;}
}
//***********密码错误报警***********************//
voidBuzzle_Password(void)
{uchari;
for(i=0;i《2;i++)
{Voice(0);
DelayMs(1000);
Voice(1);
DelayMs(1000);}
}
//**********非法卡错误报警*************************//
voidBuzzle_Card(void)
{uchari;
for(i=0;i《2;i++)
{Voice(0);
DelayMs(3000);}
}
//*************余额不足报警**********************//
voidBuzzle_Money(void)
{uchari;
for(i=0;i《1;i++)
{Buzzle_Password();
Buzzle_Card();}
}
//*********************读卡函数********************//
//说明:
//函数使用的数组参数用来存放读出的余额值;
//返回值信息:
//0:卡坏!
//1:非法卡(特征值不正确)
//2:非法卡(特征值正确,帐号不正确)
//3:读卡成功!
ucharRead_Card(uchar*p)