?? pcdanticoll.c
字號:
#include <reg52.h>
#include "rc500.h"
char PcdAnticoll(uchar *snr)
{
uchar i;
uchar snr_check=0;
char status=MI_OK;
idata struct TranSciveBuffer{uchar MfCommand;
uchar MfLength;
uchar MfData[5];
}MfComData;
struct TranSciveBuffer *pi;
pi=&MfComData;
PcdSetTmo(106);
WriteRC(RegDecoderControl,0x28);
ClearBitMask(RegControl,0x08);
WriteRC(RegChannelRedundancy,0x03);
MfComData.MfCommand=PCD_TRANSCEIVE;
MfComData.MfLength=2;
MfComData.MfData[0]=PICC_ANTICOLL1;
MfComData.MfData[1]=0x20;
status=PcdComTransceive(pi);
if(!status)
{
for(i=0;i<4;i++)
{
snr_check^=MfComData.MfData[i];
}
if(snr_check!=MfComData.MfData[i])
{
status=MI_SERNRERR;
}
else
{
for(i=0;i<4;i++)
{
*(snr+i)=MfComData.MfData[i];
}
}
}
ClearBitMask(RegDecoderControl,0x20);
return status;
}