request.c
来自「飞利浦RC522芯片源代码。该芯片主要针对三表市场和手持设备」· C语言 代码 · 共 51 行
C
51 行
/*************************************************
Function: Request
Description:
REQA, request to see if have a ISO14443A card in the field
Parameter:
req_code command code(ISO14443_3_REQALL or ISO14443_3_REQIDL)
atq the buffer to save the answer to request from the card
Return:
short status of implement
**************************************************/
short Request(unsigned char req_code, unsigned char *atq)
{
char status = STATUS_SUCCESS;
/************* initialize *****************/
RcModifyReg(JREG_STATUS2, 0, JBIT_CRYPTO1ON); /* disable Crypto if activated before */
RcSetReg(JREG_COLL, JBIT_VALUESAFTERCOLL); //active values after coll
RcModifyReg(JREG_TXMODE, 0, JBIT_CRCEN); //disable TxCRC and RxCRC
RcModifyReg(JREG_RXMODE, 0, JBIT_CRCEN);
RcSetReg(JREG_BITFRAMING, REQUEST_BITS);
/* set necessary parameters for transmission */
ResetInfo(MInfo);
SerBuffer[0] = req_code;
MInfo.nBytesToSend = 1;
/* Set timeout for REQA, ANTICOLL, SELECT*/
SetTimeOut(300);
status = M522PcdCmd(JCMD_TRANSCEIVE,
SerBuffer,
&MInfo);
if (status) // error occured
{
*atq = 0;
}
else
{
if (MInfo.nBytesReceived != 2) // 2 bytes expected
{
*atq = 0;
status = STATUS_BITCOUNT_ERROR;
}
else
{
status = STATUS_SUCCESS;
memcpy(atq,SerBuffer,2);
}
}
return status;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?