Permalink
Browse files

Added setPassiveActivationRetries()

  • Loading branch information...
1 parent e051660 commit 4dfe14bdce4320151d2925f05ab1b5681ef71020 K. Townsend committed Jul 23, 2012
Showing with 30 additions and 0 deletions.
  1. +29 −0 Adafruit_PN532.cpp
  2. +1 −0 Adafruit_PN532.h
View
@@ -20,6 +20,8 @@
@section HISTORY
+ v1.4 - Added setPassiveActivationRetries()
+
v1.2 - Added writeGPIO()
- Added readGPIO()
@@ -370,6 +372,33 @@ boolean Adafruit_PN532::SAMConfig(void) {
return (pn532_packetbuffer[5] == 0x15);
}
+/**************************************************************************/
+/*!
+ Sets the MxRtyPassiveActivation byte of the RFConfiguration register
+
+ @param maxRetries 0xFF to wait forever, 0x00..0xFE to timeout
+ after mxRetries
+
+ @returns 1 if everything executed properly, 0 for an error
+*/
+/**************************************************************************/
+boolean Adafruit_PN532::setPassiveActivationRetries(uint8_t maxRetries) {
+ pn532_packetbuffer[0] = PN532_COMMAND_RFCONFIGURATION;
+ pn532_packetbuffer[1] = 5; // Config item 5 (MaxRetries)
+ pn532_packetbuffer[2] = 0xFF; // MxRtyATR (default = 0xFF)
+ pn532_packetbuffer[3] = 0x01; // MxRtyPSL (default = 0x01)
+ pn532_packetbuffer[4] = maxRetries;
+
+#ifdef MIFAREDEBUG
+ Serial.print("Setting MxRtyPassiveActivation to "); Serial.print(maxRetries, DEC); Serial.println(" ");
+#endif
+
+ if (! sendCommandCheckAck(pn532_packetbuffer, 5))
+ return 0x0; // no ACK
+
+ return 1;
+}
+
/***** ISO14443A Commands ******/
/**************************************************************************/
View
@@ -148,6 +148,7 @@ class Adafruit_PN532{
boolean sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen, uint16_t timeout = 1000);
boolean writeGPIO(uint8_t pinstate);
uint8_t readGPIO(void);
+ boolean setPassiveActivationRetries(uint8_t maxRetries);
// ISO14443A functions
boolean readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength);

0 comments on commit 4dfe14b

Please sign in to comment.