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

RFID编程

开发平台:

C/C++

  1. #include<reg52.h>
  2. #include<rc500.h>
  3. char PcdRead(uchar addr,uchar *readdata)
  4. {
  5.     char status;
  6.     uchar i;
  7.     idata struct TranSciveBuffer{uchar MfCommand;
  8.                                  uchar MfLength;
  9.                                  uchar MfData[16];
  10.                                 }MfComData;
  11.     struct TranSciveBuffer *pi;
  12.     pi=&MfComData;
  13.     PcdSetTmo(4);
  14.     WriteRC(RegChannelRedundancy,0x0F);
  15.     MfComData.MfCommand=PCD_TRANSCEIVE;
  16.     MfComData.MfLength=2;
  17.     MfComData.MfData[0]=PICC_READ;
  18.     MfComData.MfData[1]=addr;
  19.     status=PcdComTransceive(pi);
  20.     if(status==MI_OK)
  21.     {
  22.         if(MfComData.MfLength!=0x80)
  23.         {
  24.             status = MI_BITCOUNTERR;
  25.         }
  26.         else
  27.         {
  28.             for(i=0;i<16;i++)
  29.             {
  30.                 *(readdata+i)=MfComData.MfData[i];
  31.             }
  32.         }
  33.     }
  34.     return status;
  35. }