PN532 NFC library for Seeed Studio's NFC Shield

Fork of PN532 by Yihui Xiong

Committer:
yihui
Date:
Thu Nov 21 04:30:49 2013 +0000
Revision:
3:4189a10038e6
sync with https://github.com/Seeed-Studio/PN532/releases/tag/v0.9.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 3:4189a10038e6 1 #include "Ndef.h"
yihui 3:4189a10038e6 2 #include "PN532_debug.h"
yihui 3:4189a10038e6 3
yihui 3:4189a10038e6 4 // Borrowed from Adafruit_NFCShield_I2C
yihui 3:4189a10038e6 5 void PrintHex(const uint8_t * data, const long numuint8_ts)
yihui 3:4189a10038e6 6 {
yihui 3:4189a10038e6 7 uint32_t szPos;
yihui 3:4189a10038e6 8 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 3:4189a10038e6 9 {
yihui 3:4189a10038e6 10 DMSG("0x");
yihui 3:4189a10038e6 11 // Append leading 0 for small values
yihui 3:4189a10038e6 12 if (data[szPos] <= 0xF)
yihui 3:4189a10038e6 13 DMSG("0");
yihui 3:4189a10038e6 14 DMSG_HEX(data[szPos]&0xff);
yihui 3:4189a10038e6 15 if ((numuint8_ts > 1) && (szPos != numuint8_ts - 1))
yihui 3:4189a10038e6 16 {
yihui 3:4189a10038e6 17 DMSG(" ");
yihui 3:4189a10038e6 18 }
yihui 3:4189a10038e6 19 }
yihui 3:4189a10038e6 20 DMSG("");
yihui 3:4189a10038e6 21 }
yihui 3:4189a10038e6 22
yihui 3:4189a10038e6 23 // Borrowed from Adafruit_NFCShield_I2C
yihui 3:4189a10038e6 24 void PrintHexChar(const uint8_t * data, const long numuint8_ts)
yihui 3:4189a10038e6 25 {
yihui 3:4189a10038e6 26 uint32_t szPos;
yihui 3:4189a10038e6 27 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 3:4189a10038e6 28 {
yihui 3:4189a10038e6 29 // Append leading 0 for small values
yihui 3:4189a10038e6 30 DMSG_HEX(data[szPos]);
yihui 3:4189a10038e6 31 }
yihui 3:4189a10038e6 32 DMSG(" ");
yihui 3:4189a10038e6 33 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 3:4189a10038e6 34 {
yihui 3:4189a10038e6 35 if (data[szPos] <= 0x1F)
yihui 3:4189a10038e6 36 DMSG(".");
yihui 3:4189a10038e6 37 else
yihui 3:4189a10038e6 38 DMSG("%c", (char)data[szPos]);
yihui 3:4189a10038e6 39 }
yihui 3:4189a10038e6 40 DMSG("\n");
yihui 3:4189a10038e6 41 }
yihui 3:4189a10038e6 42
yihui 3:4189a10038e6 43 // Note if buffer % blockSize != 0, last block will not be written
yihui 3:4189a10038e6 44 void DumpHex(const uint8_t * data, const long numuint8_ts, const unsigned int blockSize)
yihui 3:4189a10038e6 45 {
yihui 3:4189a10038e6 46 int i;
yihui 3:4189a10038e6 47 for (i = 0; i < (numuint8_ts / blockSize); i++)
yihui 3:4189a10038e6 48 {
yihui 3:4189a10038e6 49 PrintHexChar(data, blockSize);
yihui 3:4189a10038e6 50 data += blockSize;
yihui 3:4189a10038e6 51 }
yihui 3:4189a10038e6 52 }