6回答

2收藏

[教程] 使用Raspberry PI驱动ITEAD PN532 NFC Module

Raspberry Pi Raspberry Pi 8767 人阅读 | 6 人回复 | 2013-06-27

ITEAD PN532 NFC模块上带了双排插针,可以通过连接线直接连接到树莓派上,然后使用我们提供的ITEAD PN532 NFC SPI Library来驱动模块进行无接触的近场通讯操作,比如读写13.56M的IC卡。

首先,在安装我们提供的库之前,我们要对树莓派的配置进行一些修改,使SPI模块可以开机自启动:
cd /etc/modprobe.d/
进入配置文件夹
sudo nano raspi-blacklist.conf
以超级用户打开配置文件
#blachlist sip-bcm2708
注释掉该行,实现SPI模块开机加载

然后,就可以解压我们提供的库,我们以放置到桌面为例:
cd /home/pi/Desktop/ITEAD_PN532_NFC
进入库文件夹
make install
安装ITEAD PN532 NFC库这样我们的库就已经编译安装完成了,之后如果需要使用到这个库,只要在工程文件中包含进nfc.h即可调用库里的各函数。编译时,在命令行中添加-lNFC就可以将这些调用的库函数编译处理了。
以我们库里提供的DEMO为例子:
gcc readID.c –o readID –lNFC
编译readID例程文件
sudo ./readID
运行编译完的例程文件 – 这样,只要将13.56M的IC卡靠近NFC模块,就会在显示器上显示出这张卡的ID号了。

下面这个库提供的一些功能函数的简单说明:

FUNCTIONS:
Begin(): Begin to communicate with the ITEAD NFC module
Parameters:NULL
Return:NULL
Usage:begin();

SAMConfig(): Configure RPI to read RFID tags and cards
Parameters:NULL
Return: false or true
Usage:SAMConfig();

getFirmwareVersion(): Get the firmware version of the NFC module
Parameters:NULL
Return: the number of the firmware version(fail will return 0);
Usage: I = getFirmwareVersion();

readPassiveTargetID(uint8_t cardbaudrate): Get the passive target card ID
Parameters: cardbaudrate;
Return: the ID of the card(fail will return 0);
Usage: I = readPassiveTargetID(PN532_MIFARE_ISO14443A);

authenticateBlock(cardnumber, cid, blockaddress, authtype, * keys): Authenticate the block
Authenticate the block
authenticateBlock(cardnumber, cid, blockaddress, authtype, * keys)

Parameters:
-uint8_t cardnumber: 1 or 2;
-uint32_t cid: Card NUID;
-uint8_t blockaddress:0 to 63;
-uint8_t authtype: Either KEY_A or KEY_B;
-uint8_t * keys
Return: true or false;
Usage: authenticateBlock(1,id,0x08,KEY_A,keys);
readMemoryBlock(cardnumber, blockaddress, block): Read a block(16 bytes) from the tag and stores in the parameter
Parameter:
-uint8_t cardnumber, can be 1 or 2;
-blockaddress, range from 0 to 63;
-uint8_t* block, will save 16bytes that read from tag.  
Return: true or false
Usage: readMemoryBlock(1,0x08,block);

writeMemoryBlock( cardnumber, blockaddress, * block): Write a block(16 bytes) to the tag
Parameter:
-uint8_t cardnumber,can be 1 or 2;
-blockaddress,range from 0 to 63;
-uint8_t* block,saves 16bytes that will write to the tag.
Return: true or false
Usage: writeMemoryBlock(1,0x08,writeBuffer);

分享到:
回复

使用道具 举报

回答|共 6 个

倒序浏览

沙发

ukonline2000

发表于 2013-6-27 13:34:49 | 只看该作者

不错,不错
博客站点:http://ukonline2000.com
网店:http://ukonline2000.taobao.com
板凳

奔跑-350257

发表于 2013-6-27 14:19:12 | 只看该作者

哪里有更详细的资料啊?
地板

haothree

发表于 2013-6-27 16:29:10 | 只看该作者

gdmgb520 发表于 2013-6-27 14:19
哪里有更详细的资料啊?

你具体指哪方面的资料呢?
5#

奔跑-350257

发表于 2013-6-28 22:01:37 | 只看该作者

haothree 发表于 2013-6-27 16:29
你具体指哪方面的资料呢?

"我们提供的ITEAD PN532 NFC SPI Library来驱动模块"

请问你们提供的库在哪里可以获得?
6#

haothree

发表于 2013-7-2 09:23:32 | 只看该作者

gdmgb520 发表于 2013-6-28 22:01
"我们提供的ITEAD PN532 NFC SPI Library来驱动模块"

请问你们提供的库在哪里可以获得? ...

请看这里http://imall.iteadstudio.com/prototyping/basic-module/im130625002.html
7#

deyu260

发表于 2013-11-19 01:23:21 | 只看该作者

haothree 发表于 2013-7-2 09:23
请看这里http://imall.iteadstudio.com/prototyping/basic-module/im130625002.html

请教下 图中raspberry pi的数据线是软驱线吗
您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条