HomeGPT v.1.0
HomeGPT revolutionizes home automation with advanced features such as facial recognition for secure access, mood-responsive lighting, RFID-enabled garage entry, and clap-activated door closures. This system elevates the living experience by seamlessly blending security, convenience, and ambiance-enhancing technology.
Loading...
Searching...
No Matches
MFRC522.h
Go to the documentation of this file.
1// Copyright (C) 2021 twyleg
2#pragma once
3
4#include "bcm2835/ispi.h"
5#include "bcm2835/igpio.h"
6
7#include <stdint.h>
8#include <stdio.h>
9#include <string>
10
11namespace mfrc522 {
12
13using namespace std;
14
15typedef uint16_t word;
16
17// Firmware data for self-test
18// Reference values based on firmware version; taken from 16.1.1 in spec.
19// Version 1.0
20
21const uint8_t MFRC522_firmware_referenceV1_0[] = {
22 0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
23 0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
24 0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A,
25 0x14, 0xAF, 0x30, 0x61, 0xC9, 0x70, 0xDB, 0x2E,
26 0x64, 0x22, 0x72, 0xB5, 0xBD, 0x65, 0xF4, 0xEC,
27 0x22, 0xBC, 0xD3, 0x72, 0x35, 0xCD, 0xAA, 0x41,
28 0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
29 0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79
30};
31
32// Version 2.0
33const uint8_t MFRC522_firmware_referenceV2_0[] = {
34 0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
35 0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
36 0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82,
37 0x51, 0x3A, 0xEB, 0x02, 0x0C, 0xA5, 0x00, 0x49,
38 0x7C, 0x84, 0x4D, 0xB3, 0xCC, 0xD2, 0x1B, 0x81,
39 0x5D, 0x48, 0x76, 0xD5, 0x71, 0x61, 0x21, 0xA9,
40 0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
41 0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F
42};
43
44
45
46class MFRC522 {
47public:
48 // MFRC522 registers. Described in chapter 9 of the datasheet.
49 // When using SPI all addresses are shifted one bit left in the "SPI address uint8_t" (section 8.1.2.3)
51 // Page 0: Command and status
52 // 0x00 // reserved for future use
53 CommandReg = 0x01 << 1, // starts and stops command execution
54 ComIEnReg = 0x02 << 1, // enable and disable interrupt request control bits
55 DivIEnReg = 0x03 << 1, // enable and disable interrupt request control bits
56 ComIrqReg = 0x04 << 1, // interrupt request bits
57 DivIrqReg = 0x05 << 1, // interrupt request bits
58 ErrorReg = 0x06 << 1, // error bits showing the error status of the last command executed
59 Status1Reg = 0x07 << 1, // communication status bits
60 Status2Reg = 0x08 << 1, // receiver and transmitter status bits
61 FIFODataReg = 0x09 << 1, // input and output of 64 byte FIFO buffer
62 FIFOLevelReg = 0x0A << 1, // number of bytes stored in the FIFO buffer
63 WaterLevelReg = 0x0B << 1, // level for FIFO underflow and overflow warning
64 ControlReg = 0x0C << 1, // miscellaneous control registers
65 BitFramingReg = 0x0D << 1, // adjustments for bit-oriented frames
66 CollReg = 0x0E << 1, // bit position of the first bit-collision detected on the RF interface
67 // 0x0F // reserved for future use
68
69 // Page 1: Command
70 // 0x10 // reserved for future use
71 ModeReg = 0x11 << 1, // defines general modes for transmitting and receiving
72 TxModeReg = 0x12 << 1, // defines transmission data rate and framing
73 RxModeReg = 0x13 << 1, // defines reception data rate and framing
74 TxControlReg = 0x14 << 1, // controls the logical behavior of the antenna driver pins TX1 and TX2
75 TxASKReg = 0x15 << 1, // controls the setting of the transmission modulation
76 TxSelReg = 0x16 << 1, // selects the internal sources for the antenna driver
77 RxSelReg = 0x17 << 1, // selects internal receiver settings
78 RxThresholdReg = 0x18 << 1, // selects thresholds for the bit decoder
79 DemodReg = 0x19 << 1, // defines demodulator settings
80 // 0x1A // reserved for future use
81 // 0x1B // reserved for future use
82 MfTxReg = 0x1C << 1, // controls some MIFARE communication transmit parameters
83 MfRxReg = 0x1D << 1, // controls some MIFARE communication receive parameters
84 // 0x1E // reserved for future use
85 SerialSpeedReg = 0x1F << 1, // selects the speed of the serial UART interface
86
87 // Page 2: Configuration
88 // 0x20 // reserved for future use
89 CRCResultRegH = 0x21 << 1, // shows the MSB and LSB values of the CRC calculation
90 CRCResultRegL = 0x22 << 1,
91 // 0x23 // reserved for future use
92 ModWidthReg = 0x24 << 1, // controls the ModWidth setting?
93 // 0x25 // reserved for future use
94 RFCfgReg = 0x26 << 1, // configures the receiver gain
95 GsNReg = 0x27 << 1, // selects the conductance of the antenna driver pins TX1 and TX2 for modulation
96 CWGsPReg = 0x28 << 1, // defines the conductance of the p-driver output during periods of no modulation
97 ModGsPReg = 0x29 << 1, // defines the conductance of the p-driver output during periods of modulation
98 TModeReg = 0x2A << 1, // defines settings for the internal timer
99 TPrescalerReg = 0x2B << 1, // the lower 8 bits of the TPrescaler value. The 4 high bits are in TModeReg.
100 TReloadRegH = 0x2C << 1, // defines the 16-bit timer reload value
101 TReloadRegL = 0x2D << 1,
102 TCounterValueRegH = 0x2E << 1, // shows the 16-bit timer value
103 TCounterValueRegL = 0x2F << 1,
104
105 // Page 3: Test Registers
106 // 0x30 // reserved for future use
107 TestSel1Reg = 0x31 << 1, // general test signal configuration
108 TestSel2Reg = 0x32 << 1, // general test signal configuration
109 TestPinEnReg = 0x33 << 1, // enables pin output driver on pins D1 to D7
110 TestPinValueReg = 0x34 << 1, // defines the values for D1 to D7 when it is used as an I/O bus
111 TestBusReg = 0x35 << 1, // shows the status of the internal test bus
112 AutoTestReg = 0x36 << 1, // controls the digital self test
113 VersionReg = 0x37 << 1, // shows the software version
114 AnalogTestReg = 0x38 << 1, // controls the pins AUX1 and AUX2
115 TestDAC1Reg = 0x39 << 1, // defines the test value for TestDAC1
116 TestDAC2Reg = 0x3A << 1, // defines the test value for TestDAC2
117 TestADCReg = 0x3B << 1 // shows the value of ADC I and Q channels
118 // 0x3C // reserved for production tests
119 // 0x3D // reserved for production tests
120 // 0x3E // reserved for production tests
121 // 0x3F // reserved for production tests
122 };
123
124 // MFRC522 commands. Described in chapter 10 of the datasheet.
126 PCD_Idle = 0x00, // no action, cancels current command execution
127 PCD_Mem = 0x01, // stores 25 bytes into the internal buffer
128 PCD_GenerateRandomID = 0x02, // generates a 10-byte random ID number
129 PCD_CalcCRC = 0x03, // activates the CRC coprocessor or performs a self test
130 PCD_Transmit = 0x04, // transmits data from the FIFO buffer
131 PCD_NoCmdChange = 0x07, // no command change, can be used to modify the CommandReg register bits without affecting the command, for example, the PowerDown bit
132 PCD_Receive = 0x08, // activates the receiver circuits
133 PCD_Transceive = 0x0C, // transmits data from FIFO buffer to antenna and automatically activates the receiver after transmission
134 PCD_MFAuthent = 0x0E, // performs the MIFARE standard authentication as a reader
135 PCD_SoftReset = 0x0F // resets the MFRC522
136 };
137
138 // MFRC522 RxGain[2:0] masks, defines the receiver's signal voltage gain factor (on the PCD).
139 // Described in 9.3.3.6 / table 98 of the datasheet at http://www.nxp.com/documents/data_sheet/MFRC522.pdf
141 RxGain_18dB = 0x00 << 4, // 000b - 18 dB, minimum
142 RxGain_23dB = 0x01 << 4, // 001b - 23 dB
143 RxGain_18dB_2 = 0x02 << 4, // 010b - 18 dB, it seems 010b is a duplicate for 000b
144 RxGain_23dB_2 = 0x03 << 4, // 011b - 23 dB, it seems 011b is a duplicate for 001b
145 RxGain_33dB = 0x04 << 4, // 100b - 33 dB, average, and typical default
146 RxGain_38dB = 0x05 << 4, // 101b - 38 dB
147 RxGain_43dB = 0x06 << 4, // 110b - 43 dB
148 RxGain_48dB = 0x07 << 4, // 111b - 48 dB, maximum
149 RxGain_min = 0x00 << 4, // 000b - 18 dB, minimum, convenience for RxGain_18dB
150 RxGain_avg = 0x04 << 4, // 100b - 33 dB, average, convenience for RxGain_33dB
151 RxGain_max = 0x07 << 4 // 111b - 48 dB, maximum, convenience for RxGain_48dB
152 };
153
154 // Commands sent to the PICC.
156 // The commands used by the PCD to manage communication with several PICCs (ISO 14443-3, Type A, section 6.4)
157 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.
158 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.
159 PICC_CMD_CT = 0x88, // Cascade Tag. Not really a command, but used during anti collision.
160 PICC_CMD_SEL_CL1 = 0x93, // Anti collision/Select, Cascade Level 1
161 PICC_CMD_SEL_CL2 = 0x95, // Anti collision/Select, Cascade Level 2
162 PICC_CMD_SEL_CL3 = 0x97, // Anti collision/Select, Cascade Level 3
163 PICC_CMD_HLTA = 0x50, // HaLT command, Type A. Instructs an ACTIVE PICC to go to state HALT.
164 // The commands used for MIFARE Classic (from http://www.nxp.com/documents/data_sheet/MF1S503x.pdf, Section 9)
165 // Use PCD_MFAuthent to authenticate access to a sector, then use these commands to read/write/modify the blocks on the sector.
166 // The read/write commands can also be used for MIFARE Ultralight.
167 PICC_CMD_MF_AUTH_KEY_A = 0x60, // Perform authentication with Key A
168 PICC_CMD_MF_AUTH_KEY_B = 0x61, // Perform authentication with Key B
169 PICC_CMD_MF_READ = 0x30, // Reads one 16 byte block from the authenticated sector of the PICC. Also used for MIFARE Ultralight.
170 PICC_CMD_MF_WRITE = 0xA0, // Writes one 16 byte block to the authenticated sector of the PICC. Called "COMPATIBILITY WRITE" for MIFARE Ultralight.
171 PICC_CMD_MF_DECREMENT = 0xC0, // Decrements the contents of a block and stores the result in the internal data register.
172 PICC_CMD_MF_INCREMENT = 0xC1, // Increments the contents of a block and stores the result in the internal data register.
173 PICC_CMD_MF_RESTORE = 0xC2, // Reads the contents of a block into the internal data register.
174 PICC_CMD_MF_TRANSFER = 0xB0, // Writes the contents of the internal data register to a block.
175 // The commands used for MIFARE Ultralight (from http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf, Section 8.6)
176 // The PICC_CMD_MF_READ and PICC_CMD_MF_WRITE can also be used for MIFARE Ultralight.
177 PICC_CMD_UL_WRITE = 0xA2 // Writes one 4 byte page to the PICC.
178 };
179
180 // MIFARE constants that does not fit anywhere else
182 MF_ACK = 0xA, // The MIFARE Classic uses a 4 bit ACK/NAK. Any other value than 0xA is NAK.
183 MF_KEY_SIZE = 6 // A Mifare Crypto1 key is 6 bytes.
184 };
185
186 // PICC types we can detect. Remember to update PICC_GetTypeName() if you add more.
189 PICC_TYPE_ISO_14443_4 = 1, // PICC compliant with ISO/IEC 14443-4
190 PICC_TYPE_ISO_18092 = 2, // PICC compliant with ISO/IEC 18092 (NFC)
191 PICC_TYPE_MIFARE_MINI = 3, // MIFARE Classic protocol, 320 bytes
192 PICC_TYPE_MIFARE_1K = 4, // MIFARE Classic protocol, 1KB
193 PICC_TYPE_MIFARE_4K = 5, // MIFARE Classic protocol, 4KB
194 PICC_TYPE_MIFARE_UL = 6, // MIFARE Ultralight or Ultralight C
195 PICC_TYPE_MIFARE_PLUS = 7, // MIFARE Plus
196 PICC_TYPE_TNP3XXX = 8, // Only mentioned in NXP AN 10833 MIFARE Type Identification Procedure
197 PICC_TYPE_NOT_COMPLETE = 255 // SAK indicates UID is not complete.
198 };
199
200 // Return codes from the functions in this class. Remember to update GetStatusCodeName() if you add more.
202 STATUS_OK = 1, // Success
203 STATUS_ERROR = 2, // Error in communication
204 STATUS_COLLISION = 3, // Collission detected
205 STATUS_TIMEOUT = 4, // Timeout in communication.
206 STATUS_NO_ROOM = 5, // A buffer is not big enough.
207 STATUS_INTERNAL_ERROR = 6, // Internal error in the code. Should not happen ;-)
208 STATUS_INVALID = 7, // Invalid argument.
209 STATUS_CRC_WRONG = 8, // The CRC_A does not match
210 STATUS_MIFARE_NACK = 9 // A MIFARE PICC responded with NAK.
211 };
212
213 // A struct used for passing the UID of a PICC.
214 typedef struct {
215 uint8_t size; // Number of bytes in the UID. 4, 7 or 10.
216 uint8_t uidByte[10];
217 uint8_t sak; // The SAK (Select acknowledge) byte returned from the PICC after successful selection.
218 } Uid;
219
220 // A struct used for passing a MIFARE Crypto1 key
221 typedef struct {
222 uint8_t keyByte[MF_KEY_SIZE];
223 } MIFARE_Key;
224
225 // Member variables
226 Uid uid; // Used by PICC_ReadCardSerial().
227
228 ISpi& mSpi;
229 IGpio& mResetPin;
230
231 // Size of the MFRC522 FIFO
232 static const uint8_t FIFO_SIZE = 64; // The FIFO is 64 bytes.
233
235 // Functions for setting up the Raspberry Pi
237 MFRC522(ISpi&, IGpio& resetPin);
239 // Basic interface functions for communicating with the MFRC522
241 void PCD_WriteRegister(uint8_t reg, uint8_t value);
242 void PCD_WriteRegister(uint8_t reg, uint8_t count, uint8_t *values);
243 uint8_t PCD_ReadRegister(uint8_t reg);
244 void PCD_ReadRegister(uint8_t reg, uint8_t count, uint8_t *values, uint8_t rxAlign = 0);
245 void setBitMask(unsigned char reg, unsigned char mask);
246 void PCD_SetRegisterBitMask(uint8_t reg, uint8_t mask);
247 void PCD_ClearRegisterBitMask(uint8_t reg, uint8_t mask);
248 uint8_t PCD_CalculateCRC(uint8_t *data, uint8_t length, uint8_t *result);
249
251 // Functions for manipulating the MFRC522
253 void PCD_Init();
254 void PCD_Reset();
258 void PCD_SetAntennaGain(uint8_t mask);
260
262 // Functions for communicating with PICCs
264 uint8_t PCD_TransceiveData(uint8_t *sendData, uint8_t sendLen, uint8_t *backData, uint8_t *backLen, uint8_t *validBits = NULL, uint8_t rxAlign = 0, bool checkCRC = false);
265 uint8_t PCD_CommunicateWithPICC(uint8_t command, uint8_t waitIRq, uint8_t *sendData, uint8_t sendLen, uint8_t *backData = NULL, uint8_t *backLen = NULL, uint8_t *validBits = NULL, uint8_t rxAlign = 0, bool checkCRC = false);
266 uint8_t PICC_RequestA(uint8_t *bufferATQA, uint8_t *bufferSize);
267 uint8_t PICC_WakeupA(uint8_t *bufferATQA, uint8_t *bufferSize);
268 uint8_t PICC_REQA_or_WUPA(uint8_t command, uint8_t *bufferATQA, uint8_t *bufferSize);
269 uint8_t PICC_Select(Uid *uid, uint8_t validBits = 0);
270 uint8_t PICC_HaltA();
271
273 // Functions for communicating with MIFARE PICCs
275 uint8_t PCD_Authenticate(uint8_t command, uint8_t blockAddr, MIFARE_Key *key, Uid *uid);
277 uint8_t MIFARE_Read(uint8_t blockAddr, uint8_t *buffer, uint8_t *bufferSize);
278 uint8_t MIFARE_Write(uint8_t blockAddr, uint8_t *buffer, uint8_t bufferSize);
279 uint8_t MIFARE_Decrement(uint8_t blockAddr, long delta);
280 uint8_t MIFARE_Increment(uint8_t blockAddr, long delta);
281 uint8_t MIFARE_Restore(uint8_t blockAddr);
282 uint8_t MIFARE_Transfer(uint8_t blockAddr);
283 uint8_t MIFARE_Ultralight_Write(uint8_t page, uint8_t *buffer, uint8_t bufferSize);
284 uint8_t MIFARE_GetValue(uint8_t blockAddr, long *value);
285 uint8_t MIFARE_SetValue(uint8_t blockAddr, long value);
286
288 // Support functions
290 uint8_t PCD_MIFARE_Transceive(uint8_t *sendData, uint8_t sendLen, bool acceptTimeout = false);
291 // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory
292 //const char *GetStatusCodeName(uint8_t code);
293 const string GetStatusCodeName(uint8_t code);
294 uint8_t PICC_GetType(uint8_t sak);
295 // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory
296 //const char *PICC_GetTypeName(uint8_t type);
297 const string PICC_GetTypeName(uint8_t type);
299 void PICC_DumpMifareClassicToSerial(Uid *uid, uint8_t piccType, MIFARE_Key *key);
302 void MIFARE_SetAccessBits(uint8_t *accessBitBuffer, uint8_t g0, uint8_t g1, uint8_t g2, uint8_t g3);
303 bool MIFARE_OpenUidBackdoor(bool logErrors);
304 bool MIFARE_SetUid(uint8_t *newUid, uint8_t uidSize, bool logErrors);
305 bool MIFARE_UnbrickUidSector(bool logErrors);
306
308 // Convenience functions - does not add extra functionality
312
313private:
314 uint8_t MIFARE_TwoStepHelper(uint8_t command, uint8_t blockAddr, long data);
315};
316
317}
uint8_t MIFARE_Read(uint8_t blockAddr, uint8_t *buffer, uint8_t *bufferSize)
ISpi & mSpi
Definition: mfrc522.h:228
PICC_Type
Definition: mfrc522.h:187
@ PICC_TYPE_UNKNOWN
Definition: mfrc522.h:188
@ PICC_TYPE_TNP3XXX
Definition: mfrc522.h:196
@ PICC_TYPE_ISO_18092
Definition: mfrc522.h:190
@ PICC_TYPE_MIFARE_MINI
Definition: mfrc522.h:191
@ PICC_TYPE_MIFARE_4K
Definition: mfrc522.h:193
@ PICC_TYPE_ISO_14443_4
Definition: mfrc522.h:189
@ PICC_TYPE_MIFARE_1K
Definition: mfrc522.h:192
@ PICC_TYPE_MIFARE_UL
Definition: mfrc522.h:194
@ PICC_TYPE_MIFARE_PLUS
Definition: mfrc522.h:195
@ PICC_TYPE_NOT_COMPLETE
Definition: mfrc522.h:197
const string GetStatusCodeName(uint8_t code)
uint8_t MIFARE_SetValue(uint8_t blockAddr, long value)
void PCD_ClearRegisterBitMask(uint8_t reg, uint8_t mask)
void PCD_SetAntennaGain(uint8_t mask)
bool MIFARE_SetUid(uint8_t *newUid, uint8_t uidSize, bool logErrors)
bool MIFARE_UnbrickUidSector(bool logErrors)
PCD_RxGain
Definition: mfrc522.h:140
@ RxGain_23dB
Definition: mfrc522.h:142
@ RxGain_18dB
Definition: mfrc522.h:141
@ RxGain_18dB_2
Definition: mfrc522.h:143
@ RxGain_min
Definition: mfrc522.h:149
@ RxGain_avg
Definition: mfrc522.h:150
@ RxGain_33dB
Definition: mfrc522.h:145
@ RxGain_23dB_2
Definition: mfrc522.h:144
@ RxGain_max
Definition: mfrc522.h:151
@ RxGain_48dB
Definition: mfrc522.h:148
@ RxGain_38dB
Definition: mfrc522.h:146
@ RxGain_43dB
Definition: mfrc522.h:147
uint8_t PCD_CommunicateWithPICC(uint8_t command, uint8_t waitIRq, uint8_t *sendData, uint8_t sendLen, uint8_t *backData=NULL, uint8_t *backLen=NULL, uint8_t *validBits=NULL, uint8_t rxAlign=0, bool checkCRC=false)
uint8_t PICC_REQA_or_WUPA(uint8_t command, uint8_t *bufferATQA, uint8_t *bufferSize)
uint8_t MIFARE_Transfer(uint8_t blockAddr)
MIFARE_Misc
Definition: mfrc522.h:181
@ MF_KEY_SIZE
Definition: mfrc522.h:183
@ MF_ACK
Definition: mfrc522.h:182
void PCD_StopCrypto1()
uint8_t PICC_RequestA(uint8_t *bufferATQA, uint8_t *bufferSize)
void PICC_DumpMifareUltralightToSerial()
uint8_t MIFARE_Write(uint8_t blockAddr, uint8_t *buffer, uint8_t bufferSize)
uint8_t PICC_GetType(uint8_t sak)
uint8_t PCD_ReadRegister(uint8_t reg)
uint8_t MIFARE_Decrement(uint8_t blockAddr, long delta)
uint8_t PCD_CalculateCRC(uint8_t *data, uint8_t length, uint8_t *result)
void MIFARE_SetAccessBits(uint8_t *accessBitBuffer, uint8_t g0, uint8_t g1, uint8_t g2, uint8_t g3)
Uid uid
Definition: mfrc522.h:226
void PICC_DumpMifareClassicToSerial(Uid *uid, uint8_t piccType, MIFARE_Key *key)
uint8_t PCD_TransceiveData(uint8_t *sendData, uint8_t sendLen, uint8_t *backData, uint8_t *backLen, uint8_t *validBits=NULL, uint8_t rxAlign=0, bool checkCRC=false)
uint8_t PCD_GetAntennaGain()
uint8_t PICC_Select(Uid *uid, uint8_t validBits=0)
uint8_t PCD_MIFARE_Transceive(uint8_t *sendData, uint8_t sendLen, bool acceptTimeout=false)
PCD_Register
Definition: mfrc522.h:50
@ RxSelReg
Definition: mfrc522.h:77
@ TReloadRegL
Definition: mfrc522.h:101
@ SerialSpeedReg
Definition: mfrc522.h:85
@ CWGsPReg
Definition: mfrc522.h:96
@ RFCfgReg
Definition: mfrc522.h:94
@ TxASKReg
Definition: mfrc522.h:75
@ ComIEnReg
Definition: mfrc522.h:54
@ ComIrqReg
Definition: mfrc522.h:56
@ Status1Reg
Definition: mfrc522.h:59
@ TestDAC1Reg
Definition: mfrc522.h:115
@ TCounterValueRegH
Definition: mfrc522.h:102
@ ModeReg
Definition: mfrc522.h:71
@ TxControlReg
Definition: mfrc522.h:74
@ TModeReg
Definition: mfrc522.h:98
@ AnalogTestReg
Definition: mfrc522.h:114
@ MfTxReg
Definition: mfrc522.h:82
@ TestBusReg
Definition: mfrc522.h:111
@ TestSel1Reg
Definition: mfrc522.h:107
@ DemodReg
Definition: mfrc522.h:79
@ CRCResultRegL
Definition: mfrc522.h:90
@ AutoTestReg
Definition: mfrc522.h:112
@ Status2Reg
Definition: mfrc522.h:60
@ TReloadRegH
Definition: mfrc522.h:100
@ DivIrqReg
Definition: mfrc522.h:57
@ ModWidthReg
Definition: mfrc522.h:92
@ TestADCReg
Definition: mfrc522.h:117
@ TestPinValueReg
Definition: mfrc522.h:110
@ ControlReg
Definition: mfrc522.h:64
@ VersionReg
Definition: mfrc522.h:113
@ CRCResultRegH
Definition: mfrc522.h:89
@ TPrescalerReg
Definition: mfrc522.h:99
@ TestPinEnReg
Definition: mfrc522.h:109
@ ErrorReg
Definition: mfrc522.h:58
@ GsNReg
Definition: mfrc522.h:95
@ TCounterValueRegL
Definition: mfrc522.h:103
@ MfRxReg
Definition: mfrc522.h:83
@ DivIEnReg
Definition: mfrc522.h:55
@ TxModeReg
Definition: mfrc522.h:72
@ TestDAC2Reg
Definition: mfrc522.h:116
@ CollReg
Definition: mfrc522.h:66
@ TxSelReg
Definition: mfrc522.h:76
@ RxModeReg
Definition: mfrc522.h:73
@ WaterLevelReg
Definition: mfrc522.h:63
@ FIFOLevelReg
Definition: mfrc522.h:62
@ RxThresholdReg
Definition: mfrc522.h:78
@ FIFODataReg
Definition: mfrc522.h:61
@ CommandReg
Definition: mfrc522.h:53
@ TestSel2Reg
Definition: mfrc522.h:108
@ BitFramingReg
Definition: mfrc522.h:65
@ ModGsPReg
Definition: mfrc522.h:97
void PCD_ReadRegister(uint8_t reg, uint8_t count, uint8_t *values, uint8_t rxAlign=0)
void PICC_DumpMifareClassicSectorToSerial(Uid *uid, MIFARE_Key *key, uint8_t sector)
uint8_t PCD_Authenticate(uint8_t command, uint8_t blockAddr, MIFARE_Key *key, Uid *uid)
bool PICC_IsNewCardPresent()
void PCD_WriteRegister(uint8_t reg, uint8_t count, uint8_t *values)
void PICC_DumpToSerial(Uid *uid)
PICC_Command
Definition: mfrc522.h:155
@ PICC_CMD_MF_RESTORE
Definition: mfrc522.h:173
@ PICC_CMD_UL_WRITE
Definition: mfrc522.h:177
@ PICC_CMD_CT
Definition: mfrc522.h:159
@ PICC_CMD_SEL_CL2
Definition: mfrc522.h:161
@ PICC_CMD_MF_DECREMENT
Definition: mfrc522.h:171
@ PICC_CMD_HLTA
Definition: mfrc522.h:163
@ PICC_CMD_MF_READ
Definition: mfrc522.h:169
@ PICC_CMD_SEL_CL3
Definition: mfrc522.h:162
@ PICC_CMD_MF_WRITE
Definition: mfrc522.h:170
@ PICC_CMD_MF_AUTH_KEY_B
Definition: mfrc522.h:168
@ PICC_CMD_MF_AUTH_KEY_A
Definition: mfrc522.h:167
@ PICC_CMD_REQA
Definition: mfrc522.h:157
@ PICC_CMD_SEL_CL1
Definition: mfrc522.h:160
@ PICC_CMD_MF_INCREMENT
Definition: mfrc522.h:172
@ PICC_CMD_WUPA
Definition: mfrc522.h:158
@ PICC_CMD_MF_TRANSFER
Definition: mfrc522.h:174
MFRC522(ISpi &, IGpio &resetPin)
IGpio & mResetPin
Definition: mfrc522.h:229
uint8_t MIFARE_Restore(uint8_t blockAddr)
bool PCD_PerformSelfTest()
static const uint8_t FIFO_SIZE
Definition: mfrc522.h:232
bool PICC_ReadCardSerial()
uint8_t MIFARE_GetValue(uint8_t blockAddr, long *value)
void setBitMask(unsigned char reg, unsigned char mask)
PCD_Command
Definition: mfrc522.h:125
@ PCD_SoftReset
Definition: mfrc522.h:135
@ PCD_NoCmdChange
Definition: mfrc522.h:131
@ PCD_Mem
Definition: mfrc522.h:127
@ PCD_MFAuthent
Definition: mfrc522.h:134
@ PCD_GenerateRandomID
Definition: mfrc522.h:128
@ PCD_Transmit
Definition: mfrc522.h:130
@ PCD_Idle
Definition: mfrc522.h:126
@ PCD_Transceive
Definition: mfrc522.h:133
@ PCD_CalcCRC
Definition: mfrc522.h:129
@ PCD_Receive
Definition: mfrc522.h:132
bool MIFARE_OpenUidBackdoor(bool logErrors)
uint8_t PICC_HaltA()
uint8_t PICC_WakeupA(uint8_t *bufferATQA, uint8_t *bufferSize)
StatusCode
Definition: mfrc522.h:201
@ STATUS_INVALID
Definition: mfrc522.h:208
@ STATUS_INTERNAL_ERROR
Definition: mfrc522.h:207
@ STATUS_NO_ROOM
Definition: mfrc522.h:206
@ STATUS_OK
Definition: mfrc522.h:202
@ STATUS_ERROR
Definition: mfrc522.h:203
@ STATUS_MIFARE_NACK
Definition: mfrc522.h:210
@ STATUS_COLLISION
Definition: mfrc522.h:204
@ STATUS_TIMEOUT
Definition: mfrc522.h:205
@ STATUS_CRC_WRONG
Definition: mfrc522.h:209
const string PICC_GetTypeName(uint8_t type)
void PCD_WriteRegister(uint8_t reg, uint8_t value)
uint8_t MIFARE_Increment(uint8_t blockAddr, long delta)
void PCD_SetRegisterBitMask(uint8_t reg, uint8_t mask)
uint8_t MIFARE_Ultralight_Write(uint8_t page, uint8_t *buffer, uint8_t bufferSize)
Definition: igpio.h:6
uint16_t word
Definition: mfrc522.h:15
const uint8_t MFRC522_firmware_referenceV1_0[]
Definition: mfrc522.h:21
const uint8_t MFRC522_firmware_referenceV2_0[]
Definition: mfrc522.h:33
Definition: igpio.h:8
Definition: ispi.h:8
Definition: mfrc522.h:221
Definition: mfrc522.h:214