PcdAnticoll.c
上传用户:hbtfgg
上传日期:2021-12-10
资源大小:16k
文件大小:1k
源码类别:

RFID编程

开发平台:

C/C++

  1. #include <reg52.h>
  2. #include "rc500.h"
  3. char PcdAnticoll(uchar *snr)
  4. {
  5.     uchar i;
  6.     uchar snr_check=0;
  7.     char status=MI_OK;
  8.     idata struct TranSciveBuffer{uchar MfCommand;
  9.                                  uchar MfLength;
  10.                                  uchar MfData[5];
  11.                                 }MfComData;
  12.     struct TranSciveBuffer *pi;
  13.     pi=&MfComData;
  14.     PcdSetTmo(106);
  15.     WriteRC(RegDecoderControl,0x28);
  16.     ClearBitMask(RegControl,0x08);
  17.     WriteRC(RegChannelRedundancy,0x03);
  18.     MfComData.MfCommand=PCD_TRANSCEIVE;
  19.     MfComData.MfLength=2;
  20.     MfComData.MfData[0]=PICC_ANTICOLL1;
  21.     MfComData.MfData[1]=0x20;
  22.     status=PcdComTransceive(pi);
  23.     if(!status)
  24.     {
  25.       for(i=0;i<4;i++)
  26.          {
  27.              snr_check^=MfComData.MfData[i];
  28.          }
  29.          if(snr_check!=MfComData.MfData[i])
  30.          {
  31.              status=MI_SERNRERR;
  32.          }
  33.          else
  34.          {
  35.              for(i=0;i<4;i++)
  36.              {
  37.               *(snr+i)=MfComData.MfData[i];
  38.              }
  39.          }
  40.     }
  41.     ClearBitMask(RegDecoderControl,0x20);
  42.     return status;
  43. }