From aef891541ac7f5406c227997621fbd100a6e20dc Mon Sep 17 00:00:00 2001 From: gilphilbert Date: Sat, 3 Jul 2021 23:38:46 -0700 Subject: [PATCH] add passive i2c mode --- PN532/PN532.cpp | 18 ++++++++++++++++++ PN532/PN532.h | 1 + 2 files changed, 19 insertions(+) diff --git a/PN532/PN532.cpp b/PN532/PN532.cpp index 7275c09..17701f1 100644 --- a/PN532/PN532.cpp +++ b/PN532/PN532.cpp @@ -385,6 +385,24 @@ bool PN532::setRFField(uint8_t autoRFCA, uint8_t rFOnOff) /***** ISO14443A Commands ******/ +/**************************************************************************/ +/*! + Puts PN532 into passive detection state with IRQ while waiting for an ISO14443A target + + @param cardBaudRate Baud rate of the card + + @returns 1 if everything executed properly, 0 for an error +*/ +bool PN532::startPassiveTargetIDDetection(uint8_t cardbaudrate) { + pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET; + pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later) + pn532_packetbuffer[2] = cardbaudrate; + + if (HAL(writeCommand)(pn532_packetbuffer, 3)) { + return 0x0; // command failed + } +} + /**************************************************************************/ /*! Waits for an ISO14443A target to enter the field diff --git a/PN532/PN532.h b/PN532/PN532.h index 5ca3655..946b316 100644 --- a/PN532/PN532.h +++ b/PN532/PN532.h @@ -159,6 +159,7 @@ class PN532 // ISO14443A functions bool inListPassiveTarget(); + bool startPassiveTargetIDDetection(uint8_t cardbaudrate); bool readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength, uint16_t timeout = 1000, bool inlist = false); bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response, uint8_t *responseLength);