可以读取M1卡的序列号,其他区块的读写还要继续研究
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
APP_IDcard.c:11:6:APP_IDcard_init 16 static
|
APP_IDcard.c:12:6:APP_IDcard_init 16 static
|
||||||
APP_IDcard.c:17:6:APP_IDcard_loop 4 static
|
APP_IDcard.c:25:6:APP_IDcard_loop 112 static
|
||||||
|
|||||||
Binary file not shown.
+7878
-6873
File diff suppressed because it is too large
Load Diff
+496
-471
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -423,7 +423,7 @@ char PcdSelect ( uint8_t * pSnr )
|
|||||||
* = MI_OK,成功
|
* = MI_OK,成功
|
||||||
* 调用 :外部调用
|
* 调用 :外部调用
|
||||||
*/
|
*/
|
||||||
char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, uint8_t * pKey, uint8_t * pSnr )
|
char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, char * pKey, uint8_t * pSnr )
|
||||||
{
|
{
|
||||||
char cStatus;
|
char cStatus;
|
||||||
uint8_t uc, ucComMF522Buf [ MAXRLEN ];
|
uint8_t uc, ucComMF522Buf [ MAXRLEN ];
|
||||||
|
|||||||
@@ -127,5 +127,9 @@
|
|||||||
|
|
||||||
|
|
||||||
void RC522_Init( void ); //初始化
|
void RC522_Init( void ); //初始化
|
||||||
|
char PcdRequest ( uint8_t ucReq_code, uint8_t * pTagType );
|
||||||
|
char PcdAnticoll ( uint8_t * pSnr );
|
||||||
|
char PcdRead ( uint8_t ucAddr, uint8_t * pData );
|
||||||
|
char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, char * pKey, uint8_t * pSnr );
|
||||||
|
|
||||||
#endif /* RS522_H_ */
|
#endif /* RS522_H_ */
|
||||||
|
|||||||
@@ -7,15 +7,52 @@
|
|||||||
#include "APP_IDcard.h"
|
#include "APP_IDcard.h"
|
||||||
|
|
||||||
window *idcard_window;
|
window *idcard_window;
|
||||||
|
char idcard_str[32];
|
||||||
|
|
||||||
void APP_IDcard_init(window *a_window)
|
void APP_IDcard_init(window *a_window)
|
||||||
{
|
{
|
||||||
idcard_window=a_window;
|
idcard_window=a_window;
|
||||||
RC522_Init();
|
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()
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user