MFRC522 RFID Reader 1.0.0
This is a library for the MFRC522 RFID reader.
Loading...
Searching...
No Matches
MFRC522Extended Class Reference

#include <MFRC522Extended.h>

Inherits MFRC522.

Classes

struct  Ats
 
struct  PcbBlock
 
struct  TagInfo
 

Public Types

enum  TagBitRates : byte { BITRATE_106KBITS = 0x00 , BITRATE_212KBITS = 0x01 , BITRATE_424KBITS = 0x02 , BITRATE_848KBITS = 0x03 }
 
- Public Types inherited from MFRC522
enum  PCD_Register : byte {
  CommandReg = 0x01 << 1 , ComIEnReg = 0x02 << 1 , DivIEnReg = 0x03 << 1 , ComIrqReg = 0x04 << 1 ,
  DivIrqReg = 0x05 << 1 , ErrorReg = 0x06 << 1 , Status1Reg = 0x07 << 1 , Status2Reg = 0x08 << 1 ,
  FIFODataReg = 0x09 << 1 , FIFOLevelReg = 0x0A << 1 , WaterLevelReg = 0x0B << 1 , ControlReg = 0x0C << 1 ,
  BitFramingReg = 0x0D << 1 , CollReg = 0x0E << 1 , ModeReg = 0x11 << 1 , TxModeReg = 0x12 << 1 ,
  RxModeReg = 0x13 << 1 , TxControlReg = 0x14 << 1 , TxASKReg = 0x15 << 1 , TxSelReg = 0x16 << 1 ,
  RxSelReg = 0x17 << 1 , RxThresholdReg = 0x18 << 1 , DemodReg = 0x19 << 1 , MfTxReg = 0x1C << 1 ,
  MfRxReg = 0x1D << 1 , SerialSpeedReg = 0x1F << 1 , CRCResultRegH = 0x21 << 1 , CRCResultRegL = 0x22 << 1 ,
  ModWidthReg = 0x24 << 1 , RFCfgReg = 0x26 << 1 , GsNReg = 0x27 << 1 , CWGsPReg = 0x28 << 1 ,
  ModGsPReg = 0x29 << 1 , TModeReg = 0x2A << 1 , TPrescalerReg = 0x2B << 1 , TReloadRegH = 0x2C << 1 ,
  TReloadRegL = 0x2D << 1 , TCounterValueRegH = 0x2E << 1 , TCounterValueRegL = 0x2F << 1 , TestSel1Reg = 0x31 << 1 ,
  TestSel2Reg = 0x32 << 1 , TestPinEnReg = 0x33 << 1 , TestPinValueReg = 0x34 << 1 , TestBusReg = 0x35 << 1 ,
  AutoTestReg = 0x36 << 1 , VersionReg = 0x37 << 1 , AnalogTestReg = 0x38 << 1 , TestDAC1Reg = 0x39 << 1 ,
  TestDAC2Reg = 0x3A << 1 , TestADCReg = 0x3B << 1
}
 
enum  PCD_Command : byte {
  PCD_Idle = 0x00 , PCD_Mem = 0x01 , PCD_GenerateRandomID = 0x02 , PCD_CalcCRC = 0x03 ,
  PCD_Transmit = 0x04 , PCD_NoCmdChange = 0x07 , PCD_Receive = 0x08 , PCD_Transceive = 0x0C ,
  PCD_MFAuthent = 0x0E , PCD_SoftReset = 0x0F
}
 
enum  PCD_RxGain : byte {
  RxGain_18dB = 0x00 << 4 , RxGain_23dB = 0x01 << 4 , RxGain_18dB_2 = 0x02 << 4 , RxGain_23dB_2 = 0x03 << 4 ,
  RxGain_33dB = 0x04 << 4 , RxGain_38dB = 0x05 << 4 , RxGain_43dB = 0x06 << 4 , RxGain_48dB = 0x07 << 4 ,
  RxGain_min = 0x00 << 4 , RxGain_avg = 0x04 << 4 , RxGain_max = 0x07 << 4
}
 
enum  PICC_Command : byte {
  PICC_CMD_REQA = 0x26 , PICC_CMD_WUPA = 0x52 , PICC_CMD_CT = 0x88 , PICC_CMD_SEL_CL1 = 0x93 ,
  PICC_CMD_SEL_CL2 = 0x95 , PICC_CMD_SEL_CL3 = 0x97 , PICC_CMD_HLTA = 0x50 , PICC_CMD_RATS = 0xE0 ,
  PICC_CMD_MF_AUTH_KEY_A = 0x60 , PICC_CMD_MF_AUTH_KEY_B = 0x61 , PICC_CMD_MF_READ = 0x30 , PICC_CMD_MF_WRITE = 0xA0 ,
  PICC_CMD_MF_DECREMENT = 0xC0 , PICC_CMD_MF_INCREMENT = 0xC1 , PICC_CMD_MF_RESTORE = 0xC2 , PICC_CMD_MF_TRANSFER = 0xB0 ,
  PICC_CMD_UL_WRITE = 0xA2
}
 
enum  MIFARE_Misc { MF_ACK = 0xA , MF_KEY_SIZE = 6 }
 
enum  PICC_Type : byte {
  PICC_TYPE_UNKNOWN , PICC_TYPE_ISO_14443_4 , PICC_TYPE_ISO_18092 , PICC_TYPE_MIFARE_MINI ,
  PICC_TYPE_MIFARE_1K , PICC_TYPE_MIFARE_4K , PICC_TYPE_MIFARE_UL , PICC_TYPE_MIFARE_PLUS ,
  PICC_TYPE_MIFARE_DESFIRE , PICC_TYPE_TNP3XXX , PICC_TYPE_NOT_COMPLETE = 0xff
}
 
enum  StatusCode : byte {
  STATUS_OK , STATUS_ERROR , STATUS_COLLISION , STATUS_TIMEOUT ,
  STATUS_NO_ROOM , STATUS_INTERNAL_ERROR , STATUS_INVALID , STATUS_CRC_WRONG ,
  STATUS_MIFARE_NACK = 0xff
}
 

Public Member Functions

 MFRC522Extended ()
 
 MFRC522Extended (uint8_t rst)
 
 MFRC522Extended (uint8_t ss, uint8_t rst)
 
StatusCode PICC_Select (Uid *uid, byte validBits=0) override
 
StatusCode PICC_RequestATS (Ats *ats)
 
StatusCode PICC_PPS ()
 
StatusCode PICC_PPS (TagBitRates sendBitRate, TagBitRates receiveBitRate)
 
StatusCode TCL_Transceive (PcbBlock *send, PcbBlock *back)
 
StatusCode TCL_Transceive (TagInfo *tag, byte *sendData, byte sendLen, byte *backData=NULL, byte *backLen=NULL)
 
StatusCode TCL_TransceiveRBlock (TagInfo *tag, bool ack, byte *backData=NULL, byte *backLen=NULL)
 
StatusCode TCL_Deselect (TagInfo *tag)
 
void PICC_DumpToSerial (TagInfo *tag)
 
void PICC_DumpDetailsToSerial (TagInfo *tag)
 
void PICC_DumpISO14443_4 (TagInfo *tag)
 
bool PICC_IsNewCardPresent () override
 
bool PICC_ReadCardSerial () override
 
void PICC_DumpToSerial (Uid *uid)
 
void PICC_DumpDetailsToSerial (Uid *uid)
 
- Public Member Functions inherited from MFRC522
 MFRC522 ()
 
 MFRC522 (byte resetPowerDownPin)
 
 MFRC522 (byte chipSelectPin, byte resetPowerDownPin)
 
void PCD_WriteRegister (PCD_Register reg, byte value)
 
void PCD_WriteRegister (PCD_Register reg, byte count, byte *values)
 
byte PCD_ReadRegister (PCD_Register reg)
 
void PCD_ReadRegister (PCD_Register reg, byte count, byte *values, byte rxAlign=0)
 
void PCD_SetRegisterBitMask (PCD_Register reg, byte mask)
 
void PCD_ClearRegisterBitMask (PCD_Register reg, byte mask)
 
StatusCode PCD_CalculateCRC (byte *data, byte length, byte *result)
 
void PCD_Init ()
 
void PCD_Init (byte resetPowerDownPin)
 
void PCD_Init (byte chipSelectPin, byte resetPowerDownPin)
 
void PCD_Reset ()
 
void PCD_AntennaOn ()
 
void PCD_AntennaOff ()
 
byte PCD_GetAntennaGain ()
 
void PCD_SetAntennaGain (byte mask)
 
bool PCD_PerformSelfTest ()
 
void PCD_SoftPowerDown ()
 
void PCD_SoftPowerUp ()
 
StatusCode PCD_TransceiveData (byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits=nullptr, byte rxAlign=0, bool checkCRC=false)
 
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)
 
StatusCode PICC_RequestA (byte *bufferATQA, byte *bufferSize)
 
StatusCode PICC_WakeupA (byte *bufferATQA, byte *bufferSize)
 
StatusCode PICC_REQA_or_WUPA (byte command, byte *bufferATQA, byte *bufferSize)
 
virtual StatusCode PICC_Select (Uid *uid, byte validBits=0)
 
StatusCode PICC_HaltA ()
 
StatusCode PCD_Authenticate (byte command, byte blockAddr, MIFARE_Key *key, Uid *uid)
 
void PCD_StopCrypto1 ()
 
StatusCode MIFARE_Read (byte blockAddr, byte *buffer, byte *bufferSize)
 
StatusCode MIFARE_Write (byte blockAddr, byte *buffer, byte bufferSize)
 
StatusCode MIFARE_Ultralight_Write (byte page, byte *buffer, byte bufferSize)
 
StatusCode MIFARE_Decrement (byte blockAddr, int32_t delta)
 
StatusCode MIFARE_Increment (byte blockAddr, int32_t delta)
 
StatusCode MIFARE_Restore (byte blockAddr)
 
StatusCode MIFARE_Transfer (byte blockAddr)
 
StatusCode MIFARE_GetValue (byte blockAddr, int32_t *value)
 
StatusCode MIFARE_SetValue (byte blockAddr, int32_t value)
 
StatusCode PCD_NTAG216_AUTH (byte *passWord, byte pACK[])
 
StatusCode PCD_MIFARE_Transceive (byte *sendData, byte sendLen, bool acceptTimeout=false)
 
void PCD_DumpVersionToSerial ()
 
void PICC_DumpToSerial (Uid *uid)
 
void PICC_DumpDetailsToSerial (Uid *uid)
 
void PICC_DumpMifareClassicToSerial (Uid *uid, PICC_Type piccType, MIFARE_Key *key)
 
void PICC_DumpMifareClassicSectorToSerial (Uid *uid, MIFARE_Key *key, byte sector)
 
void PICC_DumpMifareUltralightToSerial ()
 
void MIFARE_SetAccessBits (byte *accessBitBuffer, byte g0, byte g1, byte g2, byte g3)
 
bool MIFARE_OpenUidBackdoor (bool logErrors)
 
bool MIFARE_SetUid (byte *newUid, byte uidSize, bool logErrors)
 
bool MIFARE_UnbrickUidSector (bool logErrors)
 
virtual bool PICC_IsNewCardPresent ()
 
virtual bool PICC_ReadCardSerial ()
 

Static Public Member Functions

static PICC_Type PICC_GetType (TagInfo *tag)
 
static PICC_Type PICC_GetType (byte sak)
 
- Static Public Member Functions inherited from MFRC522
static const __FlashStringHelper * GetStatusCodeName (StatusCode code)
 
static PICC_Type PICC_GetType (byte sak)
 
static const __FlashStringHelper * PICC_GetTypeName (PICC_Type type)
 

Public Attributes

TagInfo tag
 
- Public Attributes inherited from MFRC522
Uid uid
 

Additional Inherited Members

- Static Public Attributes inherited from MFRC522
static constexpr byte FIFO_SIZE = 64
 
static constexpr uint8_t UNUSED_PIN = UINT8_MAX
 
- Protected Member Functions inherited from MFRC522
StatusCode MIFARE_TwoStepHelper (byte command, byte blockAddr, int32_t data)
 
- Protected Attributes inherited from MFRC522
byte _chipSelectPin
 
byte _resetPowerDownPin
 

Member Enumeration Documentation

◆ TagBitRates

Enumerator
BITRATE_106KBITS 
BITRATE_212KBITS 
BITRATE_424KBITS 
BITRATE_848KBITS 

Constructor & Destructor Documentation

◆ MFRC522Extended() [1/3]

MFRC522Extended::MFRC522Extended ( )
inline

◆ MFRC522Extended() [2/3]

MFRC522Extended::MFRC522Extended ( uint8_t  rst)
inline

◆ MFRC522Extended() [3/3]

MFRC522Extended::MFRC522Extended ( uint8_t  ss,
uint8_t  rst 
)
inline

Member Function Documentation

◆ PICC_DumpDetailsToSerial() [1/2]

void MFRC522Extended::PICC_DumpDetailsToSerial ( TagInfo tag)

Dumps card info (UID,SAK,Type) about the selected PICC to Serial.

Parameters
tagPointer to TagInfo struct returned from a successful PICC_Select().

◆ PICC_DumpDetailsToSerial() [2/2]

void MFRC522::PICC_DumpDetailsToSerial ( Uid uid)

Dumps card info (UID,SAK,Type) about the selected PICC to Serial.

Parameters
uidPointer to Uid struct returned from a successful PICC_Select().

◆ PICC_DumpISO14443_4()

void MFRC522Extended::PICC_DumpISO14443_4 ( TagInfo tag)

Dumps memory contents of a ISO-14443-4 PICC.

◆ PICC_DumpToSerial() [1/2]

void MFRC522Extended::PICC_DumpToSerial ( TagInfo tag)

Dumps debug info about the selected PICC to Serial. On success the PICC is halted after dumping the data. For MIFARE Classic the factory default key of 0xFFFFFFFFFFFF is tried.

◆ PICC_DumpToSerial() [2/2]

void MFRC522::PICC_DumpToSerial ( Uid uid)

Dumps debug info about the selected PICC to Serial. On success the PICC is halted after dumping the data. For MIFARE Classic the factory default key of 0xFFFFFFFFFFFF is tried.

Parameters
uidPointer to Uid struct returned from a successful PICC_Select().

◆ PICC_GetType() [1/2]

MFRC522::PICC_Type MFRC522::PICC_GetType ( byte  sak)
static

Translates the SAK (Select Acknowledge) to a PICC type.

Returns
PICC_Type
Parameters
sakThe SAK byte returned from PICC_Select().

◆ PICC_GetType() [2/2]

MFRC522::PICC_Type MFRC522Extended::PICC_GetType ( TagInfo tag)
static

Get the PICC type.

Returns
PICC_Type
Parameters
tagThe TagInfo returned from PICC_Select().

◆ PICC_IsNewCardPresent()

bool MFRC522Extended::PICC_IsNewCardPresent ( )
overridevirtual

Returns true if a PICC responds to PICC_CMD_REQA. Only "new" cards in state IDLE are invited. Sleeping cards in state HALT are ignored.

Returns
bool

Reimplemented from MFRC522.

◆ PICC_PPS() [1/2]

MFRC522::StatusCode MFRC522Extended::PICC_PPS ( )

Transmits Protocol and Parameter Selection Request (PPS) without parameter 1

Returns
STATUS_OK on success, STATUS_??? otherwise.

◆ PICC_PPS() [2/2]

MFRC522::StatusCode MFRC522Extended::PICC_PPS ( TagBitRates  sendBitRate,
TagBitRates  receiveBitRate 
)

Transmits Protocol and Parameter Selection Request (PPS)

Returns
STATUS_OK on success, STATUS_??? otherwise.
Parameters
sendBitRateDS
receiveBitRateDR

◆ PICC_ReadCardSerial()

bool MFRC522Extended::PICC_ReadCardSerial ( )
overridevirtual

Simple wrapper around PICC_Select. Returns true if a UID could be read. Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first. The read UID is available in the class variable uid.

Returns
bool

Reimplemented from MFRC522.

◆ PICC_RequestATS()

MFRC522::StatusCode MFRC522Extended::PICC_RequestATS ( Ats ats)

Transmits a Request command for Answer To Select (ATS).

Returns
STATUS_OK on success, STATUS_??? otherwise.

◆ PICC_Select()

MFRC522::StatusCode MFRC522Extended::PICC_Select ( Uid uid,
byte  validBits = 0 
)
overridevirtual

Transmits SELECT/ANTICOLLISION commands to select a single PICC. Before calling this function the PICCs must be placed in the READY(*) state by calling PICC_RequestA() or PICC_WakeupA(). On success:

  • The chosen PICC is in state ACTIVE(*) and all other PICCs have returned to state IDLE/HALT. (Figure 7 of the ISO/IEC 14443-3 draft.)
  • The UID size and value of the chosen PICC is returned in *uid along with the SAK.

A PICC UID consists of 4, 7 or 10 bytes. Only 4 bytes can be specified in a SELECT command, so for the longer UIDs two or three iterations are used: UID size Number of UID bytes Cascade levels Example of PICC ======== =================== ============== =============== single 4 1 MIFARE Classic double 7 2 MIFARE Ultralight triple 10 3 Not currently in use?

Returns
STATUS_OK on success, STATUS_??? otherwise.
Parameters
uidPointer to Uid struct. Normally output, but can also be used to supply a known UID.
validBitsThe number of known UID bits supplied in *uid. Normally 0. If set you must also supply uid->size.

Reimplemented from MFRC522.

◆ TCL_Deselect()

MFRC522::StatusCode MFRC522Extended::TCL_Deselect ( TagInfo tag)

Send an S-Block to deselect the card.

◆ TCL_Transceive() [1/2]

MFRC522::StatusCode MFRC522Extended::TCL_Transceive ( PcbBlock send,
PcbBlock back 
)

◆ TCL_Transceive() [2/2]

MFRC522::StatusCode MFRC522Extended::TCL_Transceive ( TagInfo tag,
byte *  sendData,
byte  sendLen,
byte *  backData = NULL,
byte *  backLen = NULL 
)

Send an I-Block (Application)

◆ TCL_TransceiveRBlock()

MFRC522::StatusCode MFRC522Extended::TCL_TransceiveRBlock ( TagInfo tag,
bool  ack,
byte *  backData = NULL,
byte *  backLen = NULL 
)

Send R-Block to the PICC.

Member Data Documentation

◆ tag

TagInfo MFRC522Extended::tag

The documentation for this class was generated from the following files: