資源簡介
基于SI522的軟復位休眠模式(ACD模式),當有卡時會喚醒SI522,進行選卡,讀卡等操作,支持4字節和7字節UID類型的卡。工程簡潔明了,希望可以給有需要的人幫助。

代碼片段和文件信息
#include?“si522_app.h“
uint8?DefKeyA[6]={0xff0xff0xff0xff0xff0xff};?//KEYA
uint8?DefConData[4]={0xFF0x070x800x69?};??????//控制
uint8?DefKeyB[6]={0xff0xff0xff0xff0xff0xff};?//KEYB
uint8?DefVlaue[16]=
{
0xff0xff0xff0xff0xff0xff??//KEYA
0xFF0x070x800x69????????????//控制
0xff0xff0xff0xff0xff0xff???//KEYB
};
/*
*尋卡、防沖撞以及選卡
*/
uint8?FindAnticollSelect(unsigned?char?*typeunsigned?char?*idunsigned?int?*len)??
{
unsigned?char?ij;
unsigned?int?type_t;
unsigned?char?card_type[2]={0x00};
unsigned?char?card_id[10]={0x00};
??if(PcdRequest(0x52card_type)==MI_OK)
{
???type_t=((card_type[0]<<8)?|?(card_type[1]));
?for(j=0;j<2;j++)
?{
???*(type+j)?=?card_type[j];
?} ?
????switch(type_t)
{
case?0x4400:?
???if(UL_PcdAnticoll(card_id)==MI_OK)
?{
for(i=0;i<7;i++)
{
*(id+i)?=?card_id[i];
}
*len=7;
return?1; ?
?}
break;
case?0x0400:?
if(PcdAnticoll(card_id)==MI_OK)
{
for(i=0;i<4;i++)
{
*(id+i)?=?card_id[i];
}
*len=4;
if(PcdSelect(card_id)==MI_OK)
{
return?1;
}
}
break;
case?0x0200:
break;
case?0x0800:
break;
case?0x4403:
break;
default:
break;
}
?
}
return?0;
}
/**
*??讀卡
*/
uint8?ReadCard(uint8?authmodeuint8?blockuint8*?keyuint8*?redata)
{
uint8?type_buff[2];
uint8?idbuff[7];
uint16?id_len;
// uint8?data_buff[16];
if(FindAnticollSelect(type_buffidbuff&id_len)==1)
{
??if(PcdAuthState(authmodeblockkeyidbuff)==MI_OK)
{
??if(PcdRead(blockredata)==MI_OK)
{
// ?uart_sendnbyte(data_buff16);
?return?1;
}
}
}
return?0?;
}
/**
*??寫卡
*/
uint8?WriteCard(uint8?authmodeuint8?blockuint8*?keyuint8*?wrdata)
{
uint8?type_buff[2];
??uint8?idbuff[7];
uint16?id_len;
if(FindAnticollSelect(type_buffidbuff&id_len)==1)
{
??if(PcdAuthState(authmodeblockkeyidbuff)==MI_OK)
{
??if(PcdWrite(blockwrdata)==MI_OK)
{
??return?1;
}
}
}
return?0?;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2166??2019-11-22?15:44??ReadCard_V1.0\App\522\si522_app.c
?????文件????????336??2019-11-22?11:35??ReadCard_V1.0\App\522\si522_app.h
?????文件???????3743??2019-11-22?17:36??ReadCard_V1.0\App\data_handle\data_handle.c
?????文件????????922??2019-11-22?17:12??ReadCard_V1.0\App\data_handle\data_handle.h
?????文件????????868??2019-11-22?15:37??ReadCard_V1.0\Hardware\gpio\gpio.c
?????文件????????101??2019-09-05?08:53??ReadCard_V1.0\Hardware\gpio\gpio.h
?????文件???????9585??2019-11-22?18:01??ReadCard_V1.0\Hardware\si522\si522.c
?????文件???????9561??2019-11-22?14:49??ReadCard_V1.0\Hardware\si522\si522.h
?????文件???????8988??2019-11-25?17:19??ReadCard_V1.0\Hardware\si522\si522_operate.c
?????文件????????527??2019-11-22?14:32??ReadCard_V1.0\Hardware\si522\si522_operate.h
?????文件???????2097??2019-11-22?16:12??ReadCard_V1.0\Hardware\si522\si522_reg_ctrl.c
?????文件????????241??2019-11-22?11:49??ReadCard_V1.0\Hardware\si522\si522_reg_ctrl.h
?????文件????????830??2019-11-22?16:08??ReadCard_V1.0\Hardware\sleep\sleep.c
?????文件????????232??2019-09-27?18:59??ReadCard_V1.0\Hardware\sleep\sleep.h
?????文件???????1287??2019-11-22?15:19??ReadCard_V1.0\Hardware\spi\spi.c
?????文件????????131??2019-11-22?15:16??ReadCard_V1.0\Hardware\spi\spi.h
?????文件????????631??2019-11-22?15:37??ReadCard_V1.0\Hardware\timer0\timer.c
?????文件????????331??2019-09-27?16:05??ReadCard_V1.0\Hardware\timer0\timer.h
?????文件????????973??2019-11-22?15:49??ReadCard_V1.0\Hardware\uart\uart.c
?????文件????????224??2019-09-28?08:27??ReadCard_V1.0\Hardware\uart\uart.h
?????文件???????9137??2019-11-25?17:19??ReadCard_V1.0\Listings\data_handle.lst
?????文件???????2352??2019-11-25?17:19??ReadCard_V1.0\Listings\gpio.lst
?????文件???????4870??2019-11-25?17:19??ReadCard_V1.0\Listings\main.lst
?????文件??????14724??2019-11-08?11:45??ReadCard_V1.0\Listings\rc522.lst
?????文件???????5715??2019-11-22?11:33??ReadCard_V1.0\Listings\rc522_app.lst
?????文件??????19183??2019-11-08?11:45??ReadCard_V1.0\Listings\rc522_operate.lst
?????文件?????177697??2019-11-25?17:19??ReadCard_V1.0\Listings\RJM8L151.m51
?????文件??????12574??2019-10-24?14:38??ReadCard_V1.0\Listings\rjm8l151_adc.lst
?????文件???????8021??2019-10-24?14:38??ReadCard_V1.0\Listings\rjm8l151_compare.lst
?????文件???????4790??2019-10-24?14:38??ReadCard_V1.0\Listings\rjm8l151_crc.lst
............此處省略135個文件信息
評論
共有 條評論