char PcdReset(void)
{
RC522RST=1;
delay_cycles(50);
RC522RST=0;//硬件复位
delay_cycles(50);
RC522RST=1;
delay_cycles(50);
WriteRawRC(CommandReg,PCD_RESETPHASE);//复位
WriteRawRC(ModeReg,0x3D); //和Mifare卡通讯
WriteRawRC(TReloadRegL,30);
WriteRawRC(TReloadRegH,0);
WriteRawRC(TModeReg,0x8D);
WriteRawRC(TPrescalerReg,0x3E);
WriteRawRC(TxAutoReg,0x40);//必须要
return MI_OK;
}
char M500PcdConfigISOType(unsigned char type)
{
if (type == 'A'){ //ISO14443_A
ClearBitMask(Status2Reg,0x08);
WriteRawRC(ModeReg,0x3D);//3F
WriteRawRC(RxSelReg,0x86);//84
WriteRawRC(RFCfgReg,0x7F); //4F
WriteRawRC(TReloadRegL,30);//
WriteRawRC(TReloadRegH,0);
WriteRawRC(TModeReg,0x8D);
WriteRawRC(TPrescalerReg,0x3E);
delay_us(100);
PcdAntennaOn();
}
else{
return -1;
}
return MI_OK;
}
|