RC522飞利浦原厂代码 提供给有需要的朋友下载
单片机源程序如下:
- #include <string.h>
- #include <stdio.h>
- #include <absacc.h>
- #include <intrins.h>
- #include "RegCtrl.h"
- #include "reg52.h"
- #include "main.h"
- #include "Mifare.h"
- #include "Rc522Reg.h"
- #include "OpCtrl.h"
- /*Initialize the processor and RC522*/
- void SysInit(void)
- {
- T2CON = 0x04;
- PCON = 0x80;
- SCON = 0x70;
- TMOD = 0x22;
- TH1 = BAUD_9600; //set serial port baudrate to 9600bps
- TL1 = TH1;
- TR1 = 1;
- EA=0; //disable all interrupt
- Rc522Init();
- }
- //Just for test
- void main(void)
- {
- short status;
- unsigned char idata tmp[16],i,key[6];
- SysInit();
- memset(key,0xff,6);
- /* Request */
- status = Request(ISO14443_3_REQALL, tmp);
- if(status)
- goto end;
- /*anticollision and select the card*/
- status = AnticollSelect(0, tmp);
- if(status)
- goto end;
- /*authenticaiton the key A of sector 1 (block 4~block 7)*/
- status = Authentication(MIFARE_AUTHENT_A,key, tmp, 6);
- if(status)
- goto end;
- /*if passed authenticaiton you can read the data in this sector*/
- status = Read(6, tmp);
- if(status)
- goto end;
- memset(tmp,0x33,16);
- /*write function test*/
- status = Write(6, tmp);
- if(status)
- goto end;
- memset(tmp,0,16);
- /*to check if the data has been writen successfully*/
- status = Read(6, tmp);
- if(status)
- goto end;
- /*Initialize a block value, then you can do increment and decrement operation*/
- memset(tmp,0xff,4);
- status = InitBlock(6,tmp);
- if(status)
- goto end;
- /*to check if the data has been initialized successfully*/
- status = Read(6, tmp);
- if(status)
- goto end;
- /*decrement operation test*/
- tmp[0]=2;
- tmp[1]=0;
- tmp[2]=0;
- tmp[3]=0;
- status = ValueOper(MIFARE_DECREMENT, 6, tmp, 6);
- if(status)
- goto end;
- /*check if the decrement operation is ok*/
- status = Read(6, tmp);
- if(status)
- goto end;
- /*Increment operation test*/
- tmp[0]=2;
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
RC522飞利浦原厂代码.zip
(23.25 KB, 下载次数: 29)
|