欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
51單片機NFC—RC522程序
[打印本頁]
作者:
美琴的備胎
時間:
2021-5-9 16:03
標(biāo)題:
51單片機NFC—RC522程序
/*-----------------------------------------------
名稱:MF RC522
內(nèi)容:通過標(biāo)準(zhǔn)程序靜態(tài)顯示字符
引腳定義如下:
sbit MF522_NSS =P2^4 ; //RC500片選 SDA
sbit MF522_SCK = P2^5;
sbit MF522_SI = P2^3; //MOSI
sbit MF522_SO = P2^2; //MISO
sbit MF522_RST = P2^1;
------------------------------------------------*/
#include "lpcreg.h"
#include "main.h"
#include "mfrc522.h"
#include <STDIO.H>
#include <string.h>
unsigned char code data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01,0xFE};
//M1卡的某一塊寫為如下格式,則該塊為錢包,可接收扣款和充值命令
//4字節(jié)金額(低字節(jié)在前)+4字節(jié)金額取反+4字節(jié)金額+1字節(jié)塊地址+1字節(jié)塊地址取反+1字節(jié)塊地址+1字節(jié)塊地址取反
unsigned char code data2[4] = {0,0,0,0x01};
unsigned char code DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
unsigned char g_ucTempbuf[20];
void delay1(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main( )
{
unsigned char status,i;
unsigned int temp;
InitializeSystem( );
PcdReset();
PcdAntennaOff();
PcdAntennaOn();
while ( 1 )
{
status = PcdRequest(PICC_REQALL, g_ucTempbuf);//尋卡
if (status != MI_OK)
{
InitializeSystem( );
PcdReset();
PcdAntennaOff();
PcdAntennaOn();
continue;
}
/****卡類型***********/
printf("card type:");
for(i=0;i<2;i++)
{
temp=g_ucTempbuf[i];
printf("%X",temp);
}
printf("\ncard type end \n");
status = PcdAnticoll(g_ucTempbuf);//防沖撞
if (status != MI_OK)
{ continue; }
////////以下為超級終端打印出的內(nèi)容////////////////////////
/****卡序列**********/
printf("card number:"); //超級終端顯示,
for(i=0;i<4;i++)
{
temp=g_ucTempbuf[i];
printf("%X",temp);
}
if((g_ucTempbuf[0]==0xac) && (g_ucTempbuf[1]==0x9b) && (g_ucTempbuf[2]==0xca) && (g_ucTempbuf[3]==0x85))
printf("\nOKK,this prog is ready!\n");
printf("\ncard number end \n");
///////////////////////////////////////////////////////////
status = PcdSelect(g_ucTempbuf);//選定卡片
if (status != MI_OK)
{ continue; }
status = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey, g_ucTempbuf);//驗證卡片密碼
if (status != MI_OK)
{ continue; }
status = PcdWrite(1, data1);//寫塊
if (status != MI_OK)
{ continue; }
復(fù)制代碼
MFRC522測試程序.zip
2021-5-9 16:03 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
88.68 KB, 下載次數(shù): 53, 下載積分: 黑幣 -5
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1