MFRC522 RFID Reader 1.0.0
This is a library for the MFRC522 RFID reader.
Loading...
Searching...
No Matches
MFRC522.h
Go to the documentation of this file.
1
10#ifndef MFRC522_h
11#define MFRC522_h
12
13#include "require_cpp11.h"
14#include "deprecated.h"
15// Enable integer limits
16#define __STDC_LIMIT_MACROS
17#include <stdint.h>
18#include <Arduino.h>
19#include <SPI.h>
20
21#ifndef MFRC522_SPICLOCK
22#define MFRC522_SPICLOCK (4000000u) // MFRC522 accept upto 10MHz, set to 4MHz.
23#endif
24
25// Firmware data for self-test
26// Reference values based on firmware version
27// Hint: if needed, you can remove unused self-test data to save flash memory
28//
29// Version 0.0 (0x90)
30// Philips Semiconductors; Preliminary Specification Revision 2.0 - 01 August 2005; 16.1 self-test
31const byte MFRC522_firmware_referenceV0_0[] PROGMEM = {
32 0x00, 0x87, 0x98, 0x0f, 0x49, 0xFF, 0x07, 0x19,
33 0xBF, 0x22, 0x30, 0x49, 0x59, 0x63, 0xAD, 0xCA,
34 0x7F, 0xE3, 0x4E, 0x03, 0x5C, 0x4E, 0x49, 0x50,
35 0x47, 0x9A, 0x37, 0x61, 0xE7, 0xE2, 0xC6, 0x2E,
36 0x75, 0x5A, 0xED, 0x04, 0x3D, 0x02, 0x4B, 0x78,
37 0x32, 0xFF, 0x58, 0x3B, 0x7C, 0xE9, 0x00, 0x94,
38 0xB4, 0x4A, 0x59, 0x5B, 0xFD, 0xC9, 0x29, 0xDF,
39 0x35, 0x96, 0x98, 0x9E, 0x4F, 0x30, 0x32, 0x8D
40};
41// Version 1.0 (0x91)
42// NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 self-test
43const byte MFRC522_firmware_referenceV1_0[] PROGMEM = {
44 0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
45 0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
46 0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A,
47 0x14, 0xAF, 0x30, 0x61, 0xC9, 0x70, 0xDB, 0x2E,
48 0x64, 0x22, 0x72, 0xB5, 0xBD, 0x65, 0xF4, 0xEC,
49 0x22, 0xBC, 0xD3, 0x72, 0x35, 0xCD, 0xAA, 0x41,
50 0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
51 0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79
52};
53// Version 2.0 (0x92)
54// NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 self-test
55const byte MFRC522_firmware_referenceV2_0[] PROGMEM = {
56 0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
57 0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
58 0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82,
59 0x51, 0x3A, 0xEB, 0x02, 0x0C, 0xA5, 0x00, 0x49,
60 0x7C, 0x84, 0x4D, 0xB3, 0xCC, 0xD2, 0x1B, 0x81,
61 0x5D, 0x48, 0x76, 0xD5, 0x71, 0x61, 0x21, 0xA9,
62 0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
63 0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F
64};
65// Clone
66// Fudan Semiconductor FM17522 (0x88)
67const byte FM17522_firmware_reference[] PROGMEM = {
68 0x00, 0xD6, 0x78, 0x8C, 0xE2, 0xAA, 0x0C, 0x18,
69 0x2A, 0xB8, 0x7A, 0x7F, 0xD3, 0x6A, 0xCF, 0x0B,
70 0xB1, 0x37, 0x63, 0x4B, 0x69, 0xAE, 0x91, 0xC7,
71 0xC3, 0x97, 0xAE, 0x77, 0xF4, 0x37, 0xD7, 0x9B,
72 0x7C, 0xF5, 0x3C, 0x11, 0x8F, 0x15, 0xC3, 0xD7,
73 0xC1, 0x5B, 0x00, 0x2A, 0xD0, 0x75, 0xDE, 0x9E,
74 0x51, 0x64, 0xAB, 0x3E, 0xE9, 0x15, 0xB5, 0xAB,
75 0x56, 0x9A, 0x98, 0x82, 0x26, 0xEA, 0x2A, 0x62
76};
77
78class MFRC522 {
79public:
80 // Size of the MFRC522 FIFO
81 static constexpr byte FIFO_SIZE = 64; // The FIFO is 64 bytes.
82 // Default value for unused pin
83 static constexpr uint8_t UNUSED_PIN = UINT8_MAX;
84
85 // MFRC522 registers. Described in chapter 9 of the datasheet.
86 // When using SPI all addresses are shifted one bit left in the "SPI address byte" (section 8.1.2.3)
87 enum PCD_Register : byte {
88 // Page 0: Command and status
89 // 0x00 // reserved for future use
90 CommandReg = 0x01 << 1, // starts and stops command execution
91 ComIEnReg = 0x02 << 1, // enable and disable interrupt request control bits
92 DivIEnReg = 0x03 << 1, // enable and disable interrupt request control bits
93 ComIrqReg = 0x04 << 1, // interrupt request bits
94 DivIrqReg = 0x05 << 1, // interrupt request bits
95 ErrorReg = 0x06 << 1, // error bits showing the error status of the last command executed
96 Status1Reg = 0x07 << 1, // communication status bits
97 Status2Reg = 0x08 << 1, // receiver and transmitter status bits
98 FIFODataReg = 0x09 << 1, // input and output of 64 byte FIFO buffer
99 FIFOLevelReg = 0x0A << 1, // number of bytes stored in the FIFO buffer
100 WaterLevelReg = 0x0B << 1, // level for FIFO underflow and overflow warning
101 ControlReg = 0x0C << 1, // miscellaneous control registers
102 BitFramingReg = 0x0D << 1, // adjustments for bit-oriented frames
103 CollReg = 0x0E << 1, // bit position of the first bit-collision detected on the RF interface
104 // 0x0F // reserved for future use
105
106 // Page 1: Command
107 // 0x10 // reserved for future use
108 ModeReg = 0x11 << 1, // defines general modes for transmitting and receiving
109 TxModeReg = 0x12 << 1, // defines transmission data rate and framing
110 RxModeReg = 0x13 << 1, // defines reception data rate and framing
111 TxControlReg = 0x14 << 1, // controls the logical behavior of the antenna driver pins TX1 and TX2
112 TxASKReg = 0x15 << 1, // controls the setting of the transmission modulation
113 TxSelReg = 0x16 << 1, // selects the internal sources for the antenna driver
114 RxSelReg = 0x17 << 1, // selects internal receiver settings
115 RxThresholdReg = 0x18 << 1, // selects thresholds for the bit decoder
116 DemodReg = 0x19 << 1, // defines demodulator settings
117 // 0x1A // reserved for future use
118 // 0x1B // reserved for future use
119 MfTxReg = 0x1C << 1, // controls some MIFARE communication transmit parameters
120 MfRxReg = 0x1D << 1, // controls some MIFARE communication receive parameters
121 // 0x1E // reserved for future use
122 SerialSpeedReg = 0x1F << 1, // selects the speed of the serial UART interface
123
124 // Page 2: Configuration
125 // 0x20 // reserved for future use
126 CRCResultRegH = 0x21 << 1, // shows the MSB and LSB values of the CRC calculation
127 CRCResultRegL = 0x22 << 1,
128 // 0x23 // reserved for future use
129 ModWidthReg = 0x24 << 1, // controls the ModWidth setting?
130 // 0x25 // reserved for future use
131 RFCfgReg = 0x26 << 1, // configures the receiver gain
132 GsNReg = 0x27 << 1, // selects the conductance of the antenna driver pins TX1 and TX2 for modulation
133 CWGsPReg = 0x28 << 1, // defines the conductance of the p-driver output during periods of no modulation
134 ModGsPReg = 0x29 << 1, // defines the conductance of the p-driver output during periods of modulation
135 TModeReg = 0x2A << 1, // defines settings for the internal timer
136 TPrescalerReg = 0x2B << 1, // the lower 8 bits of the TPrescaler value. The 4 high bits are in TModeReg.
137 TReloadRegH = 0x2C << 1, // defines the 16-bit timer reload value
138 TReloadRegL = 0x2D << 1,
139 TCounterValueRegH = 0x2E << 1, // shows the 16-bit timer value
140 TCounterValueRegL = 0x2F << 1,
141
142 // Page 3: Test Registers
143 // 0x30 // reserved for future use
144 TestSel1Reg = 0x31 << 1, // general test signal configuration
145 TestSel2Reg = 0x32 << 1, // general test signal configuration
146 TestPinEnReg = 0x33 << 1, // enables pin output driver on pins D1 to D7
147 TestPinValueReg = 0x34 << 1, // defines the values for D1 to D7 when it is used as an I/O bus
148 TestBusReg = 0x35 << 1, // shows the status of the internal test bus
149 AutoTestReg = 0x36 << 1, // controls the digital self-test
150 VersionReg = 0x37 << 1, // shows the software version
151 AnalogTestReg = 0x38 << 1, // controls the pins AUX1 and AUX2
152 TestDAC1Reg = 0x39 << 1, // defines the test value for TestDAC1
153 TestDAC2Reg = 0x3A << 1, // defines the test value for TestDAC2
154 TestADCReg = 0x3B << 1 // shows the value of ADC I and Q channels
155 // 0x3C // reserved for production tests
156 // 0x3D // reserved for production tests
157 // 0x3E // reserved for production tests
158 // 0x3F // reserved for production tests
159 };
160
161 // MFRC522 commands. Described in chapter 10 of the datasheet.
162 enum PCD_Command : byte {
163 PCD_Idle = 0x00, // no action, cancels current command execution
164 PCD_Mem = 0x01, // stores 25 bytes into the internal buffer
165 PCD_GenerateRandomID = 0x02, // generates a 10-byte random ID number
166 PCD_CalcCRC = 0x03, // activates the CRC coprocessor or performs a self-test
167 PCD_Transmit = 0x04, // transmits data from the FIFO buffer
168 PCD_NoCmdChange = 0x07, // no command change, can be used to modify the CommandReg register bits without affecting the command, for example, the PowerDown bit
169 PCD_Receive = 0x08, // activates the receiver circuits
170 PCD_Transceive = 0x0C, // transmits data from FIFO buffer to antenna and automatically activates the receiver after transmission
171 PCD_MFAuthent = 0x0E, // performs the MIFARE standard authentication as a reader
172 PCD_SoftReset = 0x0F // resets the MFRC522
173 };
174
175 // MFRC522 RxGain[2:0] masks, defines the receiver's signal voltage gain factor (on the PCD).
176 // Described in 9.3.3.6 / table 98 of the datasheet at http://www.nxp.com/documents/data_sheet/MFRC522.pdf
177 enum PCD_RxGain : byte {
178 RxGain_18dB = 0x00 << 4, // 000b - 18 dB, minimum
179 RxGain_23dB = 0x01 << 4, // 001b - 23 dB
180 RxGain_18dB_2 = 0x02 << 4, // 010b - 18 dB, it seems 010b is a duplicate for 000b
181 RxGain_23dB_2 = 0x03 << 4, // 011b - 23 dB, it seems 011b is a duplicate for 001b
182 RxGain_33dB = 0x04 << 4, // 100b - 33 dB, average, and typical default
183 RxGain_38dB = 0x05 << 4, // 101b - 38 dB
184 RxGain_43dB = 0x06 << 4, // 110b - 43 dB
185 RxGain_48dB = 0x07 << 4, // 111b - 48 dB, maximum
186 RxGain_min = 0x00 << 4, // 000b - 18 dB, minimum, convenience for RxGain_18dB
187 RxGain_avg = 0x04 << 4, // 100b - 33 dB, average, convenience for RxGain_33dB
188 RxGain_max = 0x07 << 4 // 111b - 48 dB, maximum, convenience for RxGain_48dB
189 };
190
191 // Commands sent to the PICC.
192 enum PICC_Command : byte {
193 // The commands used by the PCD to manage communication with several PICCs (ISO 14443-3, Type A, section 6.4)
194 PICC_CMD_REQA = 0x26, // REQuest command, Type A. Invites PICCs in state IDLE to go to READY and prepare for anticollision or selection. 7 bit frame.
195 PICC_CMD_WUPA = 0x52, // Wake-UP command, Type A. Invites PICCs in state IDLE and HALT to go to READY(*) and prepare for anticollision or selection. 7 bit frame.
196 PICC_CMD_CT = 0x88, // Cascade Tag. Not really a command, but used during anti collision.
197 PICC_CMD_SEL_CL1 = 0x93, // Anti collision/Select, Cascade Level 1
198 PICC_CMD_SEL_CL2 = 0x95, // Anti collision/Select, Cascade Level 2
199 PICC_CMD_SEL_CL3 = 0x97, // Anti collision/Select, Cascade Level 3
200 PICC_CMD_HLTA = 0x50, // HaLT command, Type A. Instructs an ACTIVE PICC to go to state HALT.
201 PICC_CMD_RATS = 0xE0, // Request command for Answer To Reset.
202 // The commands used for MIFARE Classic (from http://www.mouser.com/ds/2/302/MF1S503x-89574.pdf, Section 9)
203 // Use PCD_MFAuthent to authenticate access to a sector, then use these commands to read/write/modify the blocks on the sector.
204 // The read/write commands can also be used for MIFARE Ultralight.
205 PICC_CMD_MF_AUTH_KEY_A = 0x60, // Perform authentication with Key A
206 PICC_CMD_MF_AUTH_KEY_B = 0x61, // Perform authentication with Key B
207 PICC_CMD_MF_READ = 0x30, // Reads one 16 byte block from the authenticated sector of the PICC. Also used for MIFARE Ultralight.
208 PICC_CMD_MF_WRITE = 0xA0, // Writes one 16 byte block to the authenticated sector of the PICC. Called "COMPATIBILITY WRITE" for MIFARE Ultralight.
209 PICC_CMD_MF_DECREMENT = 0xC0, // Decrements the contents of a block and stores the result in the internal data register.
210 PICC_CMD_MF_INCREMENT = 0xC1, // Increments the contents of a block and stores the result in the internal data register.
211 PICC_CMD_MF_RESTORE = 0xC2, // Reads the contents of a block into the internal data register.
212 PICC_CMD_MF_TRANSFER = 0xB0, // Writes the contents of the internal data register to a block.
213 // The commands used for MIFARE Ultralight (from http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf, Section 8.6)
214 // The PICC_CMD_MF_READ and PICC_CMD_MF_WRITE can also be used for MIFARE Ultralight.
215 PICC_CMD_UL_WRITE = 0xA2 // Writes one 4 byte page to the PICC.
216 };
217
218 // MIFARE constants that does not fit anywhere else
220 MF_ACK = 0xA, // The MIFARE Classic uses a 4 bit ACK/NAK. Any other value than 0xA is NAK.
221 MF_KEY_SIZE = 6 // A Mifare Crypto1 key is 6 bytes.
222 };
223
224 // PICC types we can detect. Remember to update PICC_GetTypeName() if you add more.
225 // last value set to 0xff, then compiler uses less ram, it seems some optimisations are triggered
226 enum PICC_Type : byte {
228 PICC_TYPE_ISO_14443_4 , // PICC compliant with ISO/IEC 14443-4
229 PICC_TYPE_ISO_18092 , // PICC compliant with ISO/IEC 18092 (NFC)
230 PICC_TYPE_MIFARE_MINI , // MIFARE Classic protocol, 320 bytes
231 PICC_TYPE_MIFARE_1K , // MIFARE Classic protocol, 1KB
232 PICC_TYPE_MIFARE_4K , // MIFARE Classic protocol, 4KB
233 PICC_TYPE_MIFARE_UL , // MIFARE Ultralight or Ultralight C
234 PICC_TYPE_MIFARE_PLUS , // MIFARE Plus
235 PICC_TYPE_MIFARE_DESFIRE, // MIFARE DESFire
236 PICC_TYPE_TNP3XXX , // Only mentioned in NXP AN 10833 MIFARE Type Identification Procedure
237 PICC_TYPE_NOT_COMPLETE = 0xff // SAK indicates UID is not complete.
238 };
239
240 // Return codes from the functions in this class. Remember to update GetStatusCodeName() if you add more.
241 // last value set to 0xff, then compiler uses less ram, it seems some optimisations are triggered
242 enum StatusCode : byte {
243 STATUS_OK , // Success
244 STATUS_ERROR , // Error in communication
245 STATUS_COLLISION , // Collission detected
246 STATUS_TIMEOUT , // Timeout in communication.
247 STATUS_NO_ROOM , // A buffer is not big enough.
248 STATUS_INTERNAL_ERROR , // Internal error in the code. Should not happen ;-)
249 STATUS_INVALID , // Invalid argument.
250 STATUS_CRC_WRONG , // The CRC_A does not match
251 STATUS_MIFARE_NACK = 0xff // A MIFARE PICC responded with NAK.
252 };
253
254 // A struct used for passing the UID of a PICC.
255 typedef struct {
256 byte size; // Number of bytes in the UID. 4, 7 or 10.
257 byte uidByte[10];
258 byte sak; // The SAK (Select acknowledge) byte returned from the PICC after successful selection.
259 } Uid;
260
261 // A struct used for passing a MIFARE Crypto1 key
262 typedef struct {
263 byte keyByte[MF_KEY_SIZE];
264 } MIFARE_Key;
265
266 // Member variables
267 Uid uid; // Used by PICC_ReadCardSerial().
268
270 // Functions for setting up the Arduino
272 MFRC522();
273 MFRC522(byte resetPowerDownPin);
274 MFRC522(byte chipSelectPin, byte resetPowerDownPin);
275
277 // Basic interface functions for communicating with the MFRC522
279 void PCD_WriteRegister(PCD_Register reg, byte value);
280 void PCD_WriteRegister(PCD_Register reg, byte count, byte *values);
282 void PCD_ReadRegister(PCD_Register reg, byte count, byte *values, byte rxAlign = 0);
283 void PCD_SetRegisterBitMask(PCD_Register reg, byte mask);
284 void PCD_ClearRegisterBitMask(PCD_Register reg, byte mask);
285 StatusCode PCD_CalculateCRC(byte *data, byte length, byte *result);
286
288 // Functions for manipulating the MFRC522
290 void PCD_Init();
291 void PCD_Init(byte resetPowerDownPin);
292 void PCD_Init(byte chipSelectPin, byte resetPowerDownPin);
293 void PCD_Reset();
294 void PCD_AntennaOn();
295 void PCD_AntennaOff();
296 byte PCD_GetAntennaGain();
297 void PCD_SetAntennaGain(byte mask);
298 bool PCD_PerformSelfTest();
299
301 // Power control functions
303 void PCD_SoftPowerDown();
304 void PCD_SoftPowerUp();
305
307 // Functions for communicating with PICCs
309 StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
310 StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData = nullptr, byte *backLen = nullptr, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false);
311 StatusCode PICC_RequestA(byte *bufferATQA, byte *bufferSize);
312 StatusCode PICC_WakeupA(byte *bufferATQA, byte *bufferSize);
313 StatusCode PICC_REQA_or_WUPA(byte command, byte *bufferATQA, byte *bufferSize);
314 virtual StatusCode PICC_Select(Uid *uid, byte validBits = 0);
316
318 // Functions for communicating with MIFARE PICCs
320 StatusCode PCD_Authenticate(byte command, byte blockAddr, MIFARE_Key *key, Uid *uid);
321 void PCD_StopCrypto1();
322 StatusCode MIFARE_Read(byte blockAddr, byte *buffer, byte *bufferSize);
323 StatusCode MIFARE_Write(byte blockAddr, byte *buffer, byte bufferSize);
324 StatusCode MIFARE_Ultralight_Write(byte page, byte *buffer, byte bufferSize);
325 StatusCode MIFARE_Decrement(byte blockAddr, int32_t delta);
326 StatusCode MIFARE_Increment(byte blockAddr, int32_t delta);
327 StatusCode MIFARE_Restore(byte blockAddr);
328 StatusCode MIFARE_Transfer(byte blockAddr);
329 StatusCode MIFARE_GetValue(byte blockAddr, int32_t *value);
330 StatusCode MIFARE_SetValue(byte blockAddr, int32_t value);
331 StatusCode PCD_NTAG216_AUTH(byte *passWord, byte pACK[]);
332
334 // Support functions
336 StatusCode PCD_MIFARE_Transceive(byte *sendData, byte sendLen, bool acceptTimeout = false);
337 // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory
338 //const char *GetStatusCodeName(byte code);
339 static const __FlashStringHelper *GetStatusCodeName(StatusCode code);
340 static PICC_Type PICC_GetType(byte sak);
341 // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory
342 //const char *PICC_GetTypeName(byte type);
343 static const __FlashStringHelper *PICC_GetTypeName(PICC_Type type);
344
345 // Support functions for debuging
350 void PICC_DumpMifareClassicSectorToSerial(Uid *uid, MIFARE_Key *key, byte sector);
352
353 // Advanced functions for MIFARE
354 void MIFARE_SetAccessBits(byte *accessBitBuffer, byte g0, byte g1, byte g2, byte g3);
355 bool MIFARE_OpenUidBackdoor(bool logErrors);
356 bool MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors);
357 bool MIFARE_UnbrickUidSector(bool logErrors);
358
360 // Convenience functions - does not add extra functionality
362 virtual bool PICC_IsNewCardPresent();
363 virtual bool PICC_ReadCardSerial();
364
365protected:
366 byte _chipSelectPin; // Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low)
367 byte _resetPowerDownPin; // Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low)
368 StatusCode MIFARE_TwoStepHelper(byte command, byte blockAddr, int32_t data);
369};
370
371#endif
const byte MFRC522_firmware_referenceV0_0[] PROGMEM
Definition: MFRC522.h:31
Definition: MFRC522.h:78
void PCD_AntennaOn()
Definition: MFRC522.cpp:278
StatusCode MIFARE_Write(byte blockAddr, byte *buffer, byte bufferSize)
Definition: MFRC522.cpp:966
StatusCode MIFARE_Transfer(byte blockAddr)
Definition: MFRC522.cpp:1105
void PCD_AntennaOff()
Definition: MFRC522.cpp:288
void PICC_DumpMifareClassicSectorToSerial(Uid *uid, MIFARE_Key *key, byte sector)
Definition: MFRC522.cpp:1488
void PCD_StopCrypto1()
Definition: MFRC522.cpp:910
bool PCD_PerformSelfTest()
Definition: MFRC522.cpp:321
bool MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors)
Definition: MFRC522.cpp:1775
static const __FlashStringHelper * GetStatusCodeName(StatusCode code)
Definition: MFRC522.cpp:1279
static constexpr byte FIFO_SIZE
Definition: MFRC522.h:81
byte _resetPowerDownPin
Definition: MFRC522.h:367
virtual bool PICC_IsNewCardPresent()
Definition: MFRC522.cpp:1904
void PICC_DumpDetailsToSerial(Uid *uid)
Definition: MFRC522.cpp:1418
PCD_Register
Definition: MFRC522.h:87
@ CWGsPReg
Definition: MFRC522.h:133
@ MfTxReg
Definition: MFRC522.h:119
@ RFCfgReg
Definition: MFRC522.h:131
@ CommandReg
Definition: MFRC522.h:90
@ TestADCReg
Definition: MFRC522.h:154
@ TModeReg
Definition: MFRC522.h:135
@ SerialSpeedReg
Definition: MFRC522.h:122
@ ErrorReg
Definition: MFRC522.h:95
@ TestDAC1Reg
Definition: MFRC522.h:152
@ ModeReg
Definition: MFRC522.h:108
@ GsNReg
Definition: MFRC522.h:132
@ FIFOLevelReg
Definition: MFRC522.h:99
@ DemodReg
Definition: MFRC522.h:116
@ TestBusReg
Definition: MFRC522.h:148
@ TestSel1Reg
Definition: MFRC522.h:144
@ VersionReg
Definition: MFRC522.h:150
@ CRCResultRegH
Definition: MFRC522.h:126
@ CRCResultRegL
Definition: MFRC522.h:127
@ TestDAC2Reg
Definition: MFRC522.h:153
@ RxThresholdReg
Definition: MFRC522.h:115
@ TestPinEnReg
Definition: MFRC522.h:146
@ RxSelReg
Definition: MFRC522.h:114
@ TxSelReg
Definition: MFRC522.h:113
@ TxControlReg
Definition: MFRC522.h:111
@ ComIrqReg
Definition: MFRC522.h:93
@ RxModeReg
Definition: MFRC522.h:110
@ TPrescalerReg
Definition: MFRC522.h:136
@ Status2Reg
Definition: MFRC522.h:97
@ MfRxReg
Definition: MFRC522.h:120
@ AutoTestReg
Definition: MFRC522.h:149
@ DivIrqReg
Definition: MFRC522.h:94
@ ControlReg
Definition: MFRC522.h:101
@ Status1Reg
Definition: MFRC522.h:96
@ TestPinValueReg
Definition: MFRC522.h:147
@ BitFramingReg
Definition: MFRC522.h:102
@ TCounterValueRegH
Definition: MFRC522.h:139
@ TestSel2Reg
Definition: MFRC522.h:145
@ TReloadRegH
Definition: MFRC522.h:137
@ TxASKReg
Definition: MFRC522.h:112
@ ModGsPReg
Definition: MFRC522.h:134
@ TxModeReg
Definition: MFRC522.h:109
@ ModWidthReg
Definition: MFRC522.h:129
@ TCounterValueRegL
Definition: MFRC522.h:140
@ ComIEnReg
Definition: MFRC522.h:91
@ WaterLevelReg
Definition: MFRC522.h:100
@ AnalogTestReg
Definition: MFRC522.h:151
@ TReloadRegL
Definition: MFRC522.h:138
@ CollReg
Definition: MFRC522.h:103
@ DivIEnReg
Definition: MFRC522.h:92
@ FIFODataReg
Definition: MFRC522.h:98
static constexpr uint8_t UNUSED_PIN
Definition: MFRC522.h:83
void PCD_DumpVersionToSerial()
Definition: MFRC522.cpp:1349
byte PCD_ReadRegister(PCD_Register reg)
Definition: MFRC522.cpp:79
StatusCode PICC_RequestA(byte *bufferATQA, byte *bufferSize)
Definition: MFRC522.cpp:556
PCD_RxGain
Definition: MFRC522.h:177
@ RxGain_48dB
Definition: MFRC522.h:185
@ RxGain_avg
Definition: MFRC522.h:187
@ RxGain_max
Definition: MFRC522.h:188
@ RxGain_18dB
Definition: MFRC522.h:178
@ RxGain_33dB
Definition: MFRC522.h:182
@ RxGain_min
Definition: MFRC522.h:186
@ RxGain_23dB
Definition: MFRC522.h:179
@ RxGain_43dB
Definition: MFRC522.h:184
@ RxGain_23dB_2
Definition: MFRC522.h:181
@ RxGain_18dB_2
Definition: MFRC522.h:180
@ RxGain_38dB
Definition: MFRC522.h:183
void PCD_SetAntennaGain(byte mask)
Definition: MFRC522.cpp:308
StatusCode PICC_REQA_or_WUPA(byte command, byte *bufferATQA, byte *bufferSize)
Definition: MFRC522.cpp:580
StatusCode PCD_Authenticate(byte command, byte blockAddr, MIFARE_Key *key, Uid *uid)
Definition: MFRC522.cpp:880
StatusCode MIFARE_Read(byte blockAddr, byte *buffer, byte *bufferSize)
Definition: MFRC522.cpp:931
void PICC_DumpToSerial(Uid *uid)
Definition: MFRC522.cpp:1373
StatusCode MIFARE_Ultralight_Write(byte page, byte *buffer, byte bufferSize)
Definition: MFRC522.cpp:1001
void PCD_ClearRegisterBitMask(PCD_Register reg, byte mask)
Definition: MFRC522.cpp:142
virtual StatusCode PICC_Select(Uid *uid, byte validBits=0)
Definition: MFRC522.cpp:619
StatusCode PCD_CalculateCRC(byte *data, byte length, byte *result)
Definition: MFRC522.cpp:156
StatusCode
Definition: MFRC522.h:242
@ STATUS_TIMEOUT
Definition: MFRC522.h:246
@ STATUS_COLLISION
Definition: MFRC522.h:245
@ STATUS_OK
Definition: MFRC522.h:243
@ STATUS_NO_ROOM
Definition: MFRC522.h:247
@ STATUS_INTERNAL_ERROR
Definition: MFRC522.h:248
@ STATUS_INVALID
Definition: MFRC522.h:249
@ STATUS_ERROR
Definition: MFRC522.h:244
@ STATUS_CRC_WRONG
Definition: MFRC522.h:250
@ STATUS_MIFARE_NACK
Definition: MFRC522.h:251
StatusCode MIFARE_TwoStepHelper(byte command, byte blockAddr, int32_t data)
Definition: MFRC522.cpp:1074
StatusCode PICC_HaltA()
Definition: MFRC522.cpp:836
bool MIFARE_OpenUidBackdoor(bool logErrors)
Definition: MFRC522.cpp:1705
MIFARE_Misc
Definition: MFRC522.h:219
@ MF_ACK
Definition: MFRC522.h:220
@ MF_KEY_SIZE
Definition: MFRC522.h:221
StatusCode MIFARE_Restore(byte blockAddr)
Definition: MFRC522.cpp:1062
void PCD_Reset()
Definition: MFRC522.cpp:262
void PCD_SoftPowerDown()
Definition: MFRC522.cpp:407
MFRC522()
Definition: MFRC522.cpp:16
PCD_Command
Definition: MFRC522.h:162
@ PCD_NoCmdChange
Definition: MFRC522.h:168
@ PCD_Receive
Definition: MFRC522.h:169
@ PCD_Mem
Definition: MFRC522.h:164
@ PCD_GenerateRandomID
Definition: MFRC522.h:165
@ PCD_CalcCRC
Definition: MFRC522.h:166
@ PCD_SoftReset
Definition: MFRC522.h:172
@ PCD_MFAuthent
Definition: MFRC522.h:171
@ PCD_Transceive
Definition: MFRC522.h:170
@ PCD_Transmit
Definition: MFRC522.h:167
@ PCD_Idle
Definition: MFRC522.h:163
byte PCD_GetAntennaGain()
Definition: MFRC522.cpp:299
void PCD_WriteRegister(PCD_Register reg, byte value)
Definition: MFRC522.cpp:46
StatusCode PCD_MIFARE_Transceive(byte *sendData, byte sendLen, bool acceptTimeout=false)
Definition: MFRC522.cpp:1233
StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits=nullptr, byte rxAlign=0, bool checkCRC=false)
Definition: MFRC522.cpp:438
virtual bool PICC_ReadCardSerial()
Definition: MFRC522.cpp:1926
static const __FlashStringHelper * PICC_GetTypeName(PICC_Type type)
Definition: MFRC522.cpp:1327
void PICC_DumpMifareClassicToSerial(Uid *uid, PICC_Type piccType, MIFARE_Key *key)
Definition: MFRC522.cpp:1447
PICC_Type
Definition: MFRC522.h:226
@ PICC_TYPE_NOT_COMPLETE
Definition: MFRC522.h:237
@ PICC_TYPE_MIFARE_PLUS
Definition: MFRC522.h:234
@ PICC_TYPE_TNP3XXX
Definition: MFRC522.h:236
@ PICC_TYPE_MIFARE_MINI
Definition: MFRC522.h:230
@ PICC_TYPE_ISO_14443_4
Definition: MFRC522.h:228
@ PICC_TYPE_ISO_18092
Definition: MFRC522.h:229
@ PICC_TYPE_MIFARE_4K
Definition: MFRC522.h:232
@ PICC_TYPE_MIFARE_UL
Definition: MFRC522.h:233
@ PICC_TYPE_MIFARE_1K
Definition: MFRC522.h:231
@ PICC_TYPE_MIFARE_DESFIRE
Definition: MFRC522.h:235
@ PICC_TYPE_UNKNOWN
Definition: MFRC522.h:227
StatusCode MIFARE_GetValue(byte blockAddr, int32_t *value)
Definition: MFRC522.cpp:1131
PICC_Command
Definition: MFRC522.h:192
@ PICC_CMD_MF_WRITE
Definition: MFRC522.h:208
@ PICC_CMD_SEL_CL3
Definition: MFRC522.h:199
@ PICC_CMD_MF_READ
Definition: MFRC522.h:207
@ PICC_CMD_RATS
Definition: MFRC522.h:201
@ PICC_CMD_MF_INCREMENT
Definition: MFRC522.h:210
@ PICC_CMD_MF_TRANSFER
Definition: MFRC522.h:212
@ PICC_CMD_MF_DECREMENT
Definition: MFRC522.h:209
@ PICC_CMD_MF_AUTH_KEY_A
Definition: MFRC522.h:205
@ PICC_CMD_MF_AUTH_KEY_B
Definition: MFRC522.h:206
@ PICC_CMD_WUPA
Definition: MFRC522.h:195
@ PICC_CMD_SEL_CL1
Definition: MFRC522.h:197
@ PICC_CMD_SEL_CL2
Definition: MFRC522.h:198
@ PICC_CMD_MF_RESTORE
Definition: MFRC522.h:211
@ PICC_CMD_CT
Definition: MFRC522.h:196
@ PICC_CMD_HLTA
Definition: MFRC522.h:200
@ PICC_CMD_UL_WRITE
Definition: MFRC522.h:215
@ PICC_CMD_REQA
Definition: MFRC522.h:194
void MIFARE_SetAccessBits(byte *accessBitBuffer, byte g0, byte g1, byte g2, byte g3)
Definition: MFRC522.cpp:1678
void PICC_DumpMifareUltralightToSerial()
Definition: MFRC522.cpp:1636
static PICC_Type PICC_GetType(byte sak)
Definition: MFRC522.cpp:1300
StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData=nullptr, byte *backLen=nullptr, byte *validBits=nullptr, byte rxAlign=0, bool checkCRC=false)
Definition: MFRC522.cpp:456
StatusCode PCD_NTAG216_AUTH(byte *passWord, byte pACK[])
Definition: MFRC522.cpp:1186
void PCD_SetRegisterBitMask(PCD_Register reg, byte mask)
Definition: MFRC522.cpp:131
StatusCode PICC_WakeupA(byte *bufferATQA, byte *bufferSize)
Definition: MFRC522.cpp:568
Uid uid
Definition: MFRC522.h:267
void PCD_SoftPowerUp()
Definition: MFRC522.cpp:413
void PCD_Init()
Definition: MFRC522.cpp:193
StatusCode MIFARE_Decrement(byte blockAddr, int32_t delta)
Definition: MFRC522.cpp:1034
StatusCode MIFARE_SetValue(byte blockAddr, int32_t value)
Definition: MFRC522.cpp:1156
StatusCode MIFARE_Increment(byte blockAddr, int32_t delta)
Definition: MFRC522.cpp:1048
bool MIFARE_UnbrickUidSector(bool logErrors)
Definition: MFRC522.cpp:1877
byte _chipSelectPin
Definition: MFRC522.h:366
Definition: MFRC522.h:262
Definition: MFRC522.h:255
byte size
Definition: MFRC522.h:256
byte sak
Definition: MFRC522.h:258