Merge pull request #125 from Rotzbua/master
readme wrong pin at mega; fix #114
This commit is contained in:
@@ -326,6 +326,9 @@ bool MFRC522::PCD_PerformSelfTest() {
|
||||
case 0x88: // Fudan Semiconductor FM17522 clone
|
||||
reference = FM17522_firmware_reference;
|
||||
break;
|
||||
case 0x90: // Version 0.0
|
||||
reference = MFRC522_firmware_referenceV0_0;
|
||||
break;
|
||||
case 0x91: // Version 1.0
|
||||
reference = MFRC522_firmware_referenceV1_0;
|
||||
break;
|
||||
|
||||
25
MFRC522.h
25
MFRC522.h
@@ -79,8 +79,23 @@
|
||||
#include <SPI.h>
|
||||
|
||||
// Firmware data for self-test
|
||||
// Reference values based on firmware version; taken from 16.1.1 in spec.
|
||||
// Version 1.0
|
||||
// Reference values based on firmware version
|
||||
// Hint: if needed, you can remove unused self-test data to save flash memory
|
||||
//
|
||||
// Version 0.0 (0x90)
|
||||
// Philips Semiconductors; Preliminary Specification Revision 2.0 - 01 August 2005; 16.1 Sefttest
|
||||
const byte MFRC522_firmware_referenceV0_0[] PROGMEM = {
|
||||
0x00, 0x87, 0x98, 0x0f, 0x49, 0xFF, 0x07, 0x19,
|
||||
0xBF, 0x22, 0x30, 0x49, 0x59, 0x63, 0xAD, 0xCA,
|
||||
0x7F, 0xE3, 0x4E, 0x03, 0x5C, 0x4E, 0x49, 0x50,
|
||||
0x47, 0x9A, 0x37, 0x61, 0xE7, 0xE2, 0xC6, 0x2E,
|
||||
0x75, 0x5A, 0xED, 0x04, 0x3D, 0x02, 0x4B, 0x78,
|
||||
0x32, 0xFF, 0x58, 0x3B, 0x7C, 0xE9, 0x00, 0x94,
|
||||
0xB4, 0x4A, 0x59, 0x5B, 0xFD, 0xC9, 0x29, 0xDF,
|
||||
0x35, 0x96, 0x98, 0x9E, 0x4F, 0x30, 0x32, 0x8D
|
||||
};
|
||||
// Version 1.0 (0x91)
|
||||
// NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 Self test
|
||||
const byte MFRC522_firmware_referenceV1_0[] PROGMEM = {
|
||||
0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
|
||||
0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
|
||||
@@ -91,7 +106,8 @@ const byte MFRC522_firmware_referenceV1_0[] PROGMEM = {
|
||||
0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
|
||||
0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79
|
||||
};
|
||||
// Version 2.0
|
||||
// Version 2.0 (0x92)
|
||||
// NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 Self test
|
||||
const byte MFRC522_firmware_referenceV2_0[] PROGMEM = {
|
||||
0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
|
||||
0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
|
||||
@@ -102,7 +118,8 @@ const byte MFRC522_firmware_referenceV2_0[] PROGMEM = {
|
||||
0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
|
||||
0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F
|
||||
};
|
||||
// Fudan Semiconductor FM17522
|
||||
// Clone
|
||||
// Fudan Semiconductor FM17522 (0x88)
|
||||
const byte FM17522_firmware_reference[] PROGMEM = {
|
||||
0x00, 0xD6, 0x78, 0x8C, 0xE2, 0xAA, 0x0C, 0x18,
|
||||
0x2A, 0xB8, 0x7A, 0x7F, 0xD3, 0x6A, 0xCF, 0x0B,
|
||||
|
||||
@@ -28,11 +28,11 @@ The following table shows the typical pin layout used:
|
||||
+-----------+----------+-------------+---------+---------+---------------+-----------+--------+
|
||||
| SPI SS | SDA [3]_ | 10 [2]_ | 53 [2]_ | D10 | 10 | 10 | 10 |
|
||||
+-----------+----------+-------------+---------+---------+---------------+-----------+--------+
|
||||
| SPI MOSI | MOSI | 11 / ICSP-4 | 52 | D11 | ICSP-4 | 16 | 11 |
|
||||
| SPI MOSI | MOSI | 11 / ICSP-4 | 51 | D11 | ICSP-4 | 16 | 11 |
|
||||
+-----------+----------+-------------+---------+---------+---------------+-----------+--------+
|
||||
| SPI MISO | MISO | 12 / ICSP-1 | 51 | D12 | ICSP-1 | 14 | 12 |
|
||||
| SPI MISO | MISO | 12 / ICSP-1 | 50 | D12 | ICSP-1 | 14 | 12 |
|
||||
+-----------+----------+-------------+---------+---------+---------------+-----------+--------+
|
||||
| SPI SCK | SCK | 13 / ICSP-3 | 50 | D13 | ICSP-3 | 15 | 13 |
|
||||
| SPI SCK | SCK | 13 / ICSP-3 | 52 | D13 | ICSP-3 | 15 | 13 |
|
||||
+-----------+----------+-------------+---------+---------+---------------+-----------+--------+
|
||||
|
||||
.. [1] Configurable, typically defined as RST_PIN in sketch/program.
|
||||
|
||||
81
examples/firmware_check/firmware_check.ino
Normal file
81
examples/firmware_check/firmware_check.ino
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Example sketch/program to test your firmware.
|
||||
* ----------------------------------------------------------------------------
|
||||
* This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
|
||||
* for further details and other examples.
|
||||
*
|
||||
* NOTE: The library file MFRC522.h has a lot of useful info. The functions are
|
||||
* documented in MFRC522.cpp. Please read it.
|
||||
*
|
||||
* Released into the public domain.
|
||||
*
|
||||
* Typical pin layout used:
|
||||
* -----------------------------------------------------------------------------------------
|
||||
* MFRC522 Arduino Arduino Arduino Arduino Arduino
|
||||
* Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro
|
||||
* Signal Pin Pin Pin Pin Pin Pin
|
||||
* -----------------------------------------------------------------------------------------
|
||||
* RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
|
||||
* SPI SS SDA(SS) 10 53 D10 10 10
|
||||
* SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
|
||||
* SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
|
||||
* SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
|
||||
*
|
||||
* @author Rotzbua
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600); // Initialize serial communications with the PC
|
||||
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
|
||||
SPI.begin(); // Init SPI bus
|
||||
mfrc522.PCD_Init(); // Init MFRC522 module
|
||||
|
||||
Serial.println(F("*****************************"));
|
||||
Serial.println(F("MFRC522 Digital self test"));
|
||||
Serial.println(F("*****************************"));
|
||||
ShowReaderVersion(); // Show version of PCD - MFRC522 Card Reader
|
||||
Serial.println(F("Performing test..."));
|
||||
bool result = mfrc522.PCD_PerformSelfTest();
|
||||
Serial.println(F("-----------------------------"));
|
||||
Serial.print(F("Result: "));
|
||||
if (result)
|
||||
Serial.println(F("OK"));
|
||||
else
|
||||
Serial.println(F("DEFECT or UNKNOWN"));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {} // nothing to do
|
||||
|
||||
/**
|
||||
* Helper to print MFRC522 module info
|
||||
*/
|
||||
void ShowReaderVersion() {
|
||||
// Get the MFRC522 firmware version
|
||||
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
|
||||
Serial.print(F("Firmware Version: 0x"));
|
||||
Serial.print(v, HEX);
|
||||
if (v == 0x88)
|
||||
Serial.print(F(" = (clone)"));
|
||||
else if (v == 0x90)
|
||||
Serial.print(F(" = v0.0"));
|
||||
else if (v == 0x91)
|
||||
Serial.print(F(" = v1.0"));
|
||||
else if (v == 0x92)
|
||||
Serial.print(F(" = v2.0"));
|
||||
else
|
||||
Serial.print(F(" = (unknown)"));
|
||||
Serial.println();
|
||||
// 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?"));
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name=MFRC522
|
||||
#date as version
|
||||
version=20150405
|
||||
#date as version - no leading zero
|
||||
version=2015.9.4
|
||||
author=GithubCommunity
|
||||
maintainer=miguelbalboa
|
||||
sentence=Arduino RFID Library for MFRC522 (SPI)
|
||||
|
||||
Reference in New Issue
Block a user