From a2c9c18e83b678b35902f5e7bf15790715a6588e Mon Sep 17 00:00:00 2001 From: kkloesener Date: Tue, 3 Nov 2020 21:34:17 +0100 Subject: [PATCH] adding PCD_DumpVersionToSerial --- MFRC522_I2C.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MFRC522_I2C.cpp b/MFRC522_I2C.cpp index c1d0931..6cf346a 100644 --- a/MFRC522_I2C.cpp +++ b/MFRC522_I2C.cpp @@ -1213,6 +1213,29 @@ const __FlashStringHelper *MFRC522::PICC_GetTypeName(byte piccType ///< One of t } } // End PICC_GetTypeName() +/** + * Dumps debug info about the connected PCD to Serial. + * Shows all known firmware versions + */ +void MFRC522::PCD_DumpVersionToSerial() { + // Get the MFRC522 firmware version + byte v = _dev->PCD_ReadRegister(VersionReg); + Serial.print(F("Firmware Version: 0x")); + Serial.print(v, HEX); + // Lookup which version + switch(v) { + case 0x88: Serial.println(F(" = (clone)")); break; + case 0x90: Serial.println(F(" = v0.0")); break; + case 0x91: Serial.println(F(" = v1.0")); break; + case 0x92: Serial.println(F(" = v2.0")); break; + case 0x12: Serial.println(F(" = counterfeit chip")); break; + default: Serial.println(F(" = (unknown)")); + } + // When 0x00 or 0xFF is returned, communication probably failed + if ((v == 0x00) || (v == 0xFF)) + Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?")); +} // End PCD_DumpVersionToSerial() + /** * Dumps debug info about the selected PICC to Serial. * On success the PICC is halted after dumping the data.