move self-test reference from ram to flash
This commit is contained in:
33
MFRC522.cpp
33
MFRC522.cpp
@@ -322,39 +322,14 @@ bool MFRC522::PCD_PerformSelfTest() {
|
|||||||
// Determine firmware version (see section 9.3.4.8 in spec)
|
// Determine firmware version (see section 9.3.4.8 in spec)
|
||||||
byte version = PCD_ReadRegister(VersionReg);
|
byte version = PCD_ReadRegister(VersionReg);
|
||||||
|
|
||||||
// Reference values based on firmware version; taken from 16.1.1 in spec.
|
|
||||||
// Version 1.0
|
|
||||||
byte referenceV1_0[] = {
|
|
||||||
0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
|
|
||||||
0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
|
|
||||||
0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A,
|
|
||||||
0x14, 0xAF, 0x30, 0x61, 0xC9, 0x70, 0xDB, 0x2E,
|
|
||||||
0x64, 0x22, 0x72, 0xB5, 0xBD, 0x65, 0xF4, 0xEC,
|
|
||||||
0x22, 0xBC, 0xD3, 0x72, 0x35, 0xCD, 0xAA, 0x41,
|
|
||||||
0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
|
|
||||||
0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79
|
|
||||||
};
|
|
||||||
|
|
||||||
// Version 2.0
|
|
||||||
byte referenceV2_0[] = {
|
|
||||||
0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
|
|
||||||
0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
|
|
||||||
0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82,
|
|
||||||
0x51, 0x3A, 0xEB, 0x02, 0x0C, 0xA5, 0x00, 0x49,
|
|
||||||
0x7C, 0x84, 0x4D, 0xB3, 0xCC, 0xD2, 0x1B, 0x81,
|
|
||||||
0x5D, 0x48, 0x76, 0xD5, 0x71, 0x61, 0x21, 0xA9,
|
|
||||||
0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
|
|
||||||
0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pick the appropriate reference values
|
// Pick the appropriate reference values
|
||||||
byte *reference;
|
const byte *reference;
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 0x91: // Version 1.0
|
case 0x91: // Version 1.0
|
||||||
reference = referenceV1_0;
|
reference = MFRC522_firmware_referenceV1_0;
|
||||||
break;
|
break;
|
||||||
case 0x92: // Version 2.0
|
case 0x92: // Version 2.0
|
||||||
reference = referenceV2_0;
|
reference = MFRC522_firmware_referenceV2_0;
|
||||||
break;
|
break;
|
||||||
default: // Unknown version
|
default: // Unknown version
|
||||||
return false;
|
return false;
|
||||||
@@ -362,7 +337,7 @@ bool MFRC522::PCD_PerformSelfTest() {
|
|||||||
|
|
||||||
// Verify that the results match up to our expectations
|
// Verify that the results match up to our expectations
|
||||||
for (i = 0; i < 64; i++) {
|
for (i = 0; i < 64; i++) {
|
||||||
if (result[i] != reference[i]) {
|
if (result[i] != pgm_read_byte(&(reference[i]))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
MFRC522.h
25
MFRC522.h
@@ -78,6 +78,31 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
|
// Firmware data for self-test
|
||||||
|
// Reference values based on firmware version; taken from 16.1.1 in spec.
|
||||||
|
// Version 1.0
|
||||||
|
const byte MFRC522_firmware_referenceV1_0[] PROGMEM = {
|
||||||
|
0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
|
||||||
|
0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
|
||||||
|
0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A,
|
||||||
|
0x14, 0xAF, 0x30, 0x61, 0xC9, 0x70, 0xDB, 0x2E,
|
||||||
|
0x64, 0x22, 0x72, 0xB5, 0xBD, 0x65, 0xF4, 0xEC,
|
||||||
|
0x22, 0xBC, 0xD3, 0x72, 0x35, 0xCD, 0xAA, 0x41,
|
||||||
|
0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
|
||||||
|
0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79
|
||||||
|
};
|
||||||
|
// Version 2.0
|
||||||
|
const byte MFRC522_firmware_referenceV2_0[] PROGMEM = {
|
||||||
|
0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
|
||||||
|
0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
|
||||||
|
0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82,
|
||||||
|
0x51, 0x3A, 0xEB, 0x02, 0x0C, 0xA5, 0x00, 0x49,
|
||||||
|
0x7C, 0x84, 0x4D, 0xB3, 0xCC, 0xD2, 0x1B, 0x81,
|
||||||
|
0x5D, 0x48, 0x76, 0xD5, 0x71, 0x61, 0x21, 0xA9,
|
||||||
|
0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
|
||||||
|
0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F
|
||||||
|
};
|
||||||
|
|
||||||
class MFRC522 {
|
class MFRC522 {
|
||||||
public:
|
public:
|
||||||
// MFRC522 registers. Described in chapter 9 of the datasheet.
|
// MFRC522 registers. Described in chapter 9 of the datasheet.
|
||||||
|
|||||||
Reference in New Issue
Block a user