34 #include <mraa/common.hpp> 35 #include <mraa/i2c.hpp> 37 #include <mraa/gpio.hpp> 39 #define PN532_I2C_BUS 0 40 #define PN532_DEFAULT_I2C_ADDR (0x48 >> 1) 42 #define PN532_PREAMBLE (0x00) 43 #define PN532_STARTCODE1 (0x00) 44 #define PN532_STARTCODE2 (0xFF) 45 #define PN532_POSTAMBLE (0x00) 47 #define PN532_HOSTTOPN532 (0xD4) 48 #define PN532_PN532TOHOST (0xD5) 83 CMD_GETFIRMWAREVERSION = 0x02,
84 CMD_GETGENERALSTATUS = 0x04,
85 CMD_READREGISTER = 0x06,
86 CMD_WRITEREGISTER = 0x08,
89 CMD_SETSERIALBAUDRATE = 0x10,
90 CMD_SETPARAMETERS = 0x12,
91 CMD_SAMCONFIGURATION = 0x14,
93 CMD_RFCONFIGURATION = 0x32,
94 CMD_RFREGULATIONTEST = 0x58,
95 CMD_INJUMPFORDEP = 0x56,
96 CMD_INJUMPFORPSL = 0x46,
97 CMD_INLISTPASSIVETARGET = 0x4A,
100 CMD_INDATAEXCHANGE = 0x40,
101 CMD_INCOMMUNICATETHRU = 0x42,
102 CMD_INDESELECT = 0x44,
103 CMD_INRELEASE = 0x52,
105 CMD_INAUTOPOLL = 0x60,
106 CMD_TGINITASTARGET = 0x8C,
107 CMD_TGSETGENERALBYTES = 0x92,
108 CMD_TGGETDATA = 0x86,
109 CMD_TGSETDATA = 0x8E,
110 CMD_TGSETMETADATA = 0x94,
111 CMD_TGGETINITIATORCOMMAND = 0x88,
112 CMD_TGRESPONSETOINITIATOR = 0x90,
113 CMD_TGGETTARGETSTATUS = 0x8A
120 RSP_INDATAEXCHANGE = 0x41,
121 RSP_INLISTPASSIVETARGET = 0x4B
128 MIFARE_CMD_AUTH_A = 0x60,
129 MIFARE_CMD_AUTH_B = 0x61,
130 MIFARE_CMD_READ = 0x30,
131 MIFARE_CMD_WRITE = 0xA0,
132 MIFARE_CMD_TRANSFER = 0xB0,
133 MIFARE_CMD_DECREMENT = 0xC0,
134 MIFARE_CMD_INCREMENT = 0xC1,
135 MIFARE_CMD_STORE = 0xC2,
136 MIFARE_ULTRALIGHT_CMD_WRITE = 0xA2
143 NDEF_URIPREFIX_NONE = 0x00,
144 NDEF_URIPREFIX_HTTP_WWWDOT = 0x01,
145 NDEF_URIPREFIX_HTTPS_WWWDOT = 0x02,
146 NDEF_URIPREFIX_HTTP = 0x03,
147 NDEF_URIPREFIX_HTTPS = 0x04,
148 NDEF_URIPREFIX_TEL = 0x05,
149 NDEF_URIPREFIX_MAILTO = 0x06,
150 NDEF_URIPREFIX_FTP_ANONAT = 0x07,
151 NDEF_URIPREFIX_FTP_FTPDOT = 0x08,
152 NDEF_URIPREFIX_FTPS = 0x09,
153 NDEF_URIPREFIX_SFTP = 0x0A,
154 NDEF_URIPREFIX_SMB = 0x0B,
155 NDEF_URIPREFIX_NFS = 0x0C,
156 NDEF_URIPREFIX_FTP = 0x0D,
157 NDEF_URIPREFIX_DAV = 0x0E,
158 NDEF_URIPREFIX_NEWS = 0x0F,
159 NDEF_URIPREFIX_TELNET = 0x10,
160 NDEF_URIPREFIX_IMAP = 0x11,
161 NDEF_URIPREFIX_RTSP = 0x12,
162 NDEF_URIPREFIX_URN = 0x13,
163 NDEF_URIPREFIX_POP = 0x14,
164 NDEF_URIPREFIX_SIP = 0x15,
165 NDEF_URIPREFIX_SIPS = 0x16,
166 NDEF_URIPREFIX_TFTP = 0x17,
167 NDEF_URIPREFIX_BTSPP = 0x18,
168 NDEF_URIPREFIX_BTL2CAP = 0x19,
169 NDEF_URIPREFIX_BTGOEP = 0x1A,
170 NDEF_URIPREFIX_TCPOBEX = 0x1B,
171 NDEF_URIPREFIX_IRDAOBEX = 0x1C,
172 NDEF_URIPREFIX_FILE = 0x1D,
173 NDEF_URIPREFIX_URN_EPC_ID = 0x1E,
174 NDEF_URIPREFIX_URN_EPC_TAG = 0x1F,
175 NDEF_URIPREFIX_URN_EPC_PAT = 0x20,
176 NDEF_URIPREFIX_URN_EPC_RAW = 0x21,
177 NDEF_URIPREFIX_URN_EPC = 0x22,
178 NDEF_URIPREFIX_URN_NFC = 0x23
185 BAUD_MIFARE_ISO14443A = 0x00
193 TAG_TYPE_UNKNOWN = 0,
194 TAG_TYPE_MIFARE_CLASSIC = 1,
206 PN532(
int irq,
int reset,
int bus=PN532_I2C_BUS,
207 uint8_t address=PN532_DEFAULT_I2C_ADDR);
239 uint16_t timeout=1000);
272 uint8_t * uidLength, uint16_t timeout);
286 uint8_t * response, uint8_t * responseLength);
329 uint32_t blockNumber,
472 mraa::Gpio m_gpioIRQ;
473 mraa::Gpio m_gpioReset;
479 void readData(uint8_t* buff, uint8_t n);
483 static void dataReadyISR(
void *ctx);
485 volatile bool m_irqRcvd;
492 uint8_t m_inListedTag;
uint16_t getATQA()
Definition: pn532.hpp:430
NDEF_URI_T
Definition: pn532.hpp:142
bool readAck()
Tries to read/verify the ACK packet.
Definition: pn532.cxx:1398
uint32_t getFirmwareVersion()
Checks the firmware version of the PN5xx chip.
Definition: pn532.cxx:153
bool mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data)
Definition: pn532.cxx:820
bool readPassiveTargetID(BAUD_T cardbaudrate, uint8_t *uid, uint8_t *uidLength, uint16_t timeout)
Definition: pn532.cxx:290
BAUD_T
Definition: pn532.hpp:184
void readData(uint8_t *buff, uint8_t n)
Reads n bytes of data from the PN532 via SPI or I2C.
Definition: pn532.cxx:1458
bool isReady()
Return true if the PN532 is ready with a response.
Definition: pn532.cxx:1413
API for the PN532 based NFC/RFID reader/writer.
Definition: pn532.hpp:75
void writeCommand(uint8_t *cmd, uint8_t cmdlen)
Writes a command to the PN532, automatically inserting the preamble and required frame details (check...
Definition: pn532.cxx:1497
bool SAMConfig(void)
Configures the SAM (Secure Access Module)
Definition: pn532.cxx:230
bool setPassiveActivationRetries(uint8_t maxRetries)
Definition: pn532.cxx:257
bool mifareclassic_WriteNDEFURI(uint8_t sectorNumber, NDEF_URI_T uriIdentifier, const char *url)
Definition: pn532.cxx:967
bool init()
Definition: pn532.cxx:83
bool mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data)
Definition: pn532.cxx:885
TAG_TYPE_T tagType()
Definition: pn532.cxx:1562
bool ntag2xx_ReadPage(uint8_t page, uint8_t *buffer)
Definition: pn532.cxx:1147
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void mifareDebug(bool enable)
Definition: pn532.hpp:462
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock)
Definition: pn532.cxx:711
PN532(int irq, int reset, int bus=PN532_I2C_BUS, uint8_t address=PN532_DEFAULT_I2C_ADDR)
Definition: pn532.cxx:47
bool ntag2xx_WriteNDEFURI(NDEF_URI_T uriIdentifier, char *url, uint8_t dataLen)
Definition: pn532.cxx:1298
bool mifareclassic_IsFirstBlock(uint32_t uiBlock)
Definition: pn532.cxx:697
PN532_RSP_T
Definition: pn532.hpp:119
~PN532()
Definition: pn532.cxx:77
mraa::I2c & i2cContext()
Definition: pn532.hpp:447
bool waitForReady(uint16_t timeout)
Waits until the PN532 is ready.
Definition: pn532.cxx:1432
MIFARE_CMD_T
Definition: pn532.hpp:127
bool mifareclassic_FormatNDEF(void)
Definition: pn532.cxx:924
uint8_t getSAK()
Definition: pn532.hpp:439
PN532_CMD_T
Definition: pn532.hpp:81
bool ntag2xx_WritePage(uint8_t page, uint8_t *data)
Definition: pn532.cxx:1235
bool inListPassiveTarget()
'InLists' a passive target. PN532 acting as reader/initiator, peer acting as card/responder.
Definition: pn532.cxx:482
bool mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen, uint32_t blockNumber, uint8_t keyNumber, uint8_t *keyData)
Definition: pn532.cxx:739
TAG_TYPE_T
Definition: pn532.hpp:192
void pn532Debug(bool enable)
Definition: pn532.hpp:454
bool sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen, uint16_t timeout=1000)
Sends a command and waits a specified period for the ACK.
Definition: pn532.cxx:196
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength)
Exchanges an APDU with the currently inlisted peer.
Definition: pn532.cxx:392