最近在玩Mifare Plus芯片的时候,发现激活卡片后给它发送Deselect Virtual card的命令,直接就返回FF的错误码,以下是命令函数:
UINT8 Mifare_Plus_Deselect(void)
{
UINT8 status = PN512_NoError;
// SetBitMask(PN512_TxModeReg,0x80); // TXCRC enable
// SetBitMask(PN512_RxModeReg,0x80); // RXCRC enable
// ClearBitMask(PN512_Status2Reg,0x08); // disable crypto 1 unit
//************* Cmd Sequence **********************************//
FlushFIFO();
vSPI_Write(PN512_FIFODataReg,MIFARE_CMD_DESELECT_VIRTUAL_CARD); // send deselect virtual card command
vSetPN512Timer(60); // 6 ms Time out
status = vPcdCmd(PN512_TRANSCEIVE,K_ParityErrBit);
return status;
}
按照NXP的规则,如果是SL0的卡,那么运行这条指令是返回错误的,只有SL3的卡片才会返回正确,那么问题来了,当卡片运行T = CL协议的时候,datasheet里面提到此时只能运行两条指令,分别是Write Perso 和 Commit Perso指令,但是当我运行Write Perso的时候,也是返回FF,这就不对了,以下是write Perso函数:
UINT8 MifarePlus_WritePerso( void )
{
UINT8 i;
UINT8 status = PN512_NoError;
// SetBitMask(PN512_TxModeReg,0x80); // TXCRC enable
// SetBitMask(PN512_RxModeReg,0x80); // RXCRC enable
// ClearBitMask(PN512_Status2Reg,0x08); // disable crypto 1 unit
//************* Cmd Sequence **********************************//
FlushFIFO();
vSPI_Write(PN512_FIFODataReg, MIFARE_CMD_WRITE_PERSO); //write perso command
vSPI_Write(PN512_FIFODataReg, MIFARE_CMD_WRITE_PERSO_ADDRESS1); //address 1
vSPI_Write(PN512_FIFODataReg, MIFARE_CMD_WRITE_PERSO_ADDRESS2); //address 2
for(i = 0; i < 16; i++)
{
vSPI_Write(PN512_FIFODataReg,0x00);
}
vSetPN512Timer(100); // 6 ms Time out
status = vPcdCmd(PN512_TRANSCEIVE, K_ParityErrBit|K_CRCErrBit);
return status;
}
谁有不同见解,欢迎一起探讨 |
楼主解决了吗?最近在高mifare plus卡,一点头绪没有,能否提供例程给参考,NXP的手册能否发我一份,我也是SL3的卡片,我的邮箱308735647@qq.com,谢谢