some additional fixes
Fork of PN532 by
Revision 2:f618fb2169c4, committed 2013-10-17
- Comitter:
- yihui
- Date:
- Thu Oct 17 06:51:32 2013 +0000
- Parent:
- 1:b8cab5222fd0
- Child:
- 3:4189a10038e6
- Commit message:
- PN532::readPassiveTargetID() add timeout parameter
Changed in this revision
PN532.cpp | Show annotated file Show diff for this revision Revisions of this file |
PN532.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/PN532.cpp Thu Oct 17 06:37:26 2013 +0000 +++ b/PN532.cpp Thu Oct 17 06:51:32 2013 +0000 @@ -2,7 +2,6 @@ /*! @file PN532.cpp @author Adafruit Industries & Seeed Technology Inc. - @license BSD (see license.txt) NXP's PN532 NFC/13.56MHz RFID Transceiver @@ -293,7 +292,7 @@ @returns 1 if everything executed properly, 0 for an error */ /**************************************************************************/ -bool PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength) +bool PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength, uint16_t timeout) { pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET; pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later) @@ -304,7 +303,9 @@ } // read data packet - HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer)); + if (HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer), timeout) < 0) { + return 0x0; + } // check some basic stuff /* ISO14443A card response should be in the following format:
--- a/PN532.h Thu Oct 17 06:37:26 2013 +0000 +++ b/PN532.h Thu Oct 17 06:51:32 2013 +0000 @@ -1,21 +1,12 @@ /**************************************************************************/ /*! @file PN532.h - @author Adafruit Industries - @license BSD (see license.txt) - - This is a library for the Adafruit PN532 NFC/RFID shield - This library works with the Adafruit NFC breakout - ----> https://www.adafruit.com/products/364 + @author Adafruit Industries & Seeed Technology Inc. - Check out the links above for our tutorials and wiring diagrams - These chips use I2C to communicate - - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! + NXP's PN532 NFC/13.56MHz RFID Transceiver @section HISTORY + v1.6 - Ported to mbed v1.3 - Modified to work with I2C @@ -170,7 +161,7 @@ // ISO14443A functions bool inListPassiveTarget(); - bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength); + bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength, uint16_t timeout = 1000); bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength); // Mifare Classic functions