可以读取M1卡的序列号,其他区块的读写还要继续研究

This commit is contained in:
2021-09-07 21:29:14 +08:00
parent a53edf3c01
commit 4d5efd5759
7 changed files with 8418 additions and 7347 deletions
+37
View File
@@ -7,15 +7,52 @@
#include "APP_IDcard.h"
window *idcard_window;
char idcard_str[32];
void APP_IDcard_init(window *a_window)
{
idcard_window=a_window;
RC522_Init();
}
unsigned char CT[2];
unsigned char SN[4];
unsigned char RFID[16];
unsigned char status;
unsigned char s=0x08;
char KEY[6]={0xff,0xff,0xff,0xff,0xff,0xff};
uint32_t card_number_D=0;
void APP_IDcard_loop()
{
status = PcdRequest(PICC_REQALL,CT);
if(status==MI_OK)
{
status=MI_ERR;
status = PcdAnticoll(SN);
}
if (status==MI_OK)
{
status=MI_ERR;
card_number_D=(SN[2]<<16)+(SN[1]<<8)+(SN[0]);
PcdRead(0,RFID);
sprintf(idcard_str,"CardId:%d",card_number_D);
LCD_ShowString(idcard_window->x, idcard_window->y+16, idcard_str, 16, GREEN, RED);
status=MI_ERR;
status =PcdAuthState(0,0,KEY,SN);
}
if(status==MI_OK)
{
LCD_ShowString(idcard_window->x, idcard_window->y+32, "KEY_OK", 16, GREEN, RED);
status=MI_ERR;
status=PcdRead(0,RFID);
}
if(status==MI_OK)
{
sprintf(idcard_str,"%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x",RFID[0],RFID[1],RFID[2],RFID[3],RFID[4],RFID[5],RFID[6],RFID[7],RFID[8],RFID[9],RFID[10],RFID[11],RFID[12],RFID[13],RFID[14],RFID[15]);
LCD_ShowString(idcard_window->x, idcard_window->y+32, idcard_str, 16, GREEN, RED);
}
}