iso14443b.c

来自「这是SLRC632的全部源代码.包括读typea typeb书..全功能支持」· C语言 代码 · 共 52 行

C
52
字号
#include <REGX52.H>
#include <main.h>
#include <iso14443b.h>
#include <src632.h>
#include <string.h>
#include <intrins.h>

extern unsigned char g_cFWI;
extern struct TranSciveBuffer{unsigned char MfCommand;
                              unsigned int  MfLength;
                              unsigned char MfData[64];
                             };

//////////////////////////////////////////////////////////////////////
//REQUEST B
//////////////////////////////////////////////////////////////////////
char M531PiccRequestB(unsigned char req_code, 
                      unsigned char AFI, 
                      unsigned char N, 
                      unsigned char *ATQB)
{
    char  status;
    struct TranSciveBuffer MfComData;
    struct TranSciveBuffer *pi;
    pi=&MfComData;

    ClearBitMask(RegControl,0x08);      // disable crypto 1 unit   
    
    SetBitMask(RegTxControl,0x03);      // Tx2RF-En, Tx1RF-En enable

    PcdSetTmo(5);
    MfComData.MfCommand = PCD_TRANSCEIVE;
    MfComData.MfLength  = 3;
    MfComData.MfData[0] = ISO14443B_ANTICOLLISION;     	       // APf code
    MfComData.MfData[1] = AFI;                // 
    MfComData.MfData[2] = ((req_code<<3)&0x08) | (N&0x07);  // PARAM
 
    status = PcdComTransceive(pi);

    if (status!=MI_OK && status!=MI_NOTAGERR)
    {   status = MI_COLLERR;   }
    
    if (MfComData.MfLength != 96)
    {   status = MI_COM_ERR;   }
    
    if (status == MI_OK) 
    {	
    	memcpy(ATQB, &MfComData.MfData[0], 16);
        PcdSetTmo(ATQB[11]>>4); 
    } 	
    return status;
}   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?