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

RFID编程

开发平台:

C/C++

  1. #include<reg52.h>
  2. #include<rc500.h>
  3. char PcdTransfer(uchar addr)
  4. {
  5.     char status;
  6.     idata struct TranSciveBuffer{uchar MfCommand;
  7.                                  uchar MfLength;
  8.                                  uchar MfData[2];
  9.                                 }MfComData;
  10.     struct TranSciveBuffer *pi;
  11.     pi=&MfComData;
  12.     PcdSetTmo(4);
  13.     MfComData.MfCommand=PCD_TRANSCEIVE;
  14.     MfComData.MfLength=2;
  15.     MfComData.MfData[0]=PICC_TRANSFER;
  16.     MfComData.MfData[1]=addr;
  17.     status=PcdComTransceive(pi);
  18.     if (status!=MI_NOTAGERR)
  19.     {
  20.         if(MfComData.MfLength!=4)
  21.         {
  22.            status=MI_BITCOUNTERR;
  23.         }
  24.         else
  25.         {
  26.            MfComData.MfData[0]&=0x0f;
  27.            switch(MfComData.MfData[0])
  28.            {
  29.               case 0x00:
  30.                  status=MI_NOTAUTHERR;
  31.                  break;
  32.               case 0x0a:
  33.                  status=MI_OK;
  34.                  break;
  35.               case 0x01:
  36.                  status=MI_VALERR;
  37.                  break;
  38.               default:
  39.                  status=MI_CODEERR;
  40.                  break;
  41.            }
  42.         }
  43.      }
  44.    return status;
  45. }