PcdAuthState.c
资源名称:RC500.rar [点击查看]
上传用户:hbtfgg
上传日期:2021-12-10
资源大小:16k
文件大小:1k
源码类别:
RFID编程
开发平台:
C/C++
- #include <reg52.h>
- #include "rc500.h"
- char PcdAuthState(uchar auth_mode,uchar block,uchar *snr)
- {
- char status=MI_OK;
- uchar i;
- idata struct TranSciveBuffer{uchar MfCommand;
- uchar MfLength;
- uchar MfData[6];
- }MfComData;
- struct TranSciveBuffer *pi;
- pi=&MfComData;
- WriteRC(RegChannelRedundancy,0x07);
- if(status==MI_OK)
- {
- PcdSetTmo(106);
- MfComData.MfCommand=PCD_AUTHENT1;
- MfComData.MfLength=6;
- MfComData.MfData[0]=auth_mode;
- MfComData.MfData[1]=block;
- for(i=0;i<4;i++)
- {
- MfComData.MfData[i+2]=*(snr+i);
- }
- if((status=PcdComTransceive(pi))==MI_OK)
- {
- if (ReadRC(RegSecondaryStatus)&0x07)
- {
- status = MI_BITCOUNTERR;
- }
- else
- {
- MfComData.MfCommand=PCD_AUTHENT2;
- MfComData.MfLength=0;
- if((status=PcdComTransceive(pi))==MI_OK)
- {
- if(ReadRC(RegControl)&0x08)
- status=MI_OK;
- else
- status=MI_AUTHERR;
- }
- }
- }
- }
- return status;
- }