MFRC522

Classes

Type

Name

struct

struct

Public Types

Type

Name

enum

enum

enum

enum

enum

enum

enum

Public Attributes

Type

Name

Public Static Attributes

Type

Name

static const uint8_t

Public Functions

Type

Name

int

int

int

int

int

uint8_t

void

void

void

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

void

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

uint8_t

char *

char *

void

bool

bool

Detailed Description

MFRC522 example

#include "mbed.h"
#include "MFRC522.h"

//KL25Z Pins for MFRC522 SPI interface
#define SPI_MOSI    PTC6
#define SPI_MISO    PTC7
#define SPI_SCLK    PTC5
#define SPI_CS      PTC4
// KL25Z Pin for MFRC522 reset
#define MF_RESET    PTC3
// KL25Z Pins for Debug UART port
#define UART_RX     PTA1
#define UART_TX     PTA2

DigitalOut LedRed   (LED_RED);
DigitalOut LedGreen (LED_GREEN);

Serial     DebugUART(UART_TX, UART_RX);
MFRC522    RfChip   (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET);

int main(void) {
  // Set debug UART speed
  DebugUART.baud(115200);

  // Init. RC522 Chip
  RfChip.PCD_Init();

  while (true) {
    LedRed   = 1;
    LedGreen = 1;

    // Look for new cards
    if ( ! RfChip.PICC_IsNewCardPresent())
    {
      wait_ms(500);
      continue;
    }

    LedRed   = 0;

    // Select one of the cards
    if ( ! RfChip.PICC_ReadCardSerial())
    {
      wait_ms(500);
      continue;
    }

    LedRed   = 1;
    LedGreen = 0;

    // Print Card UID
    printf("Card UID: ");
    for (uint8_t i = 0; i < RfChip.uid.size; i++)
    {
      printf(" %X02", RfChip.uid.uidByte[i]);
    }
    printf("\n\r");

    // Print Card type
    uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
    printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
    wait_ms(1000);
  }
}

Public Types Documentation

enum MFRC522::PCD_Register {
    CommandReg = 0x01,
    ComIEnReg = 0x02,
    DivIEnReg = 0x03,
    ComIrqReg = 0x04,
    DivIrqReg = 0x05,
    ErrorReg = 0x06,
    Status1Reg = 0x07,
    Status2Reg = 0x08,
    FIFODataReg = 0x09,
    FIFOLevelReg = 0x0A,
    WaterLevelReg = 0x0B,
    ControlReg = 0x0C,
    BitFramingReg = 0x0D,
    CollReg = 0x0E,
    ModeReg = 0x11,
    TxModeReg = 0x12,
    RxModeReg = 0x13,
    TxControlReg = 0x14,
    TxASKReg = 0x15,
    TxSelReg = 0x16,
    RxSelReg = 0x17,
    RxThresholdReg = 0x18,
    DemodReg = 0x19,
    MfTxReg = 0x1C,
    MfRxReg = 0x1D,
    SerialSpeedReg = 0x1F,
    CRCResultRegH = 0x21,
    CRCResultRegL = 0x22,
    ModWidthReg = 0x24,
    RFCfgReg = 0x26,
    GsNReg = 0x27,
    CWGsPReg = 0x28,
    ModGsPReg = 0x29,
    TModeReg = 0x2A,
    TPrescalerReg = 0x2B,
    TReloadRegH = 0x2C,
    TReloadRegL = 0x2D,
    TCntValueRegH = 0x2E,
    TCntValueRegL = 0x2F,
    TestSel1Reg = 0x31,
    TestSel2Reg = 0x32,
    TestPinEnReg = 0x33,
    TestPinValueReg = 0x34,
    TestBusReg = 0x35,
    AutoTestReg = 0x36,
    VersionReg = 0x37,
    AnalogTestReg = 0x38,
    TestDAC1Reg = 0x39,
    TestDAC2Reg = 0x3A,
    TestADCReg = 0x3B,
};

MFRC522 registers (described in chapter 9 of the datasheet). When using SPI all addresses areed one bit left in the "SPI address byte" (section 8.1.2.3)

enum MFRC522::PCD_Command {
    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 MFRC522::PCD_RxGain {
    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 MFRC522::PICC_Command {
    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_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 MFRC522::MIFARE_Misc {
    MF_ACK = 0xA,
    MF_KEY_SIZE = 6,
};

enum MFRC522::PICC_Type {
    PICC_TYPE_UNKNOWN = 0,
    PICC_TYPE_ISO_14443_4 = 1,
    PICC_TYPE_ISO_18092 = 2,
    PICC_TYPE_MIFARE_MINI = 3,
    PICC_TYPE_MIFARE_1K = 4,
    PICC_TYPE_MIFARE_4K = 5,
    PICC_TYPE_MIFARE_UL = 6,
    PICC_TYPE_MIFARE_PLUS = 7,
    PICC_TYPE_TNP3XXX = 8,
    PICC_TYPE_NOT_COMPLETE = 255,
};

enum MFRC522::StatusCode {
    STATUS_OK = 1,
    STATUS_ERROR = 2,
    STATUS_COLLISION = 3,
    STATUS_TIMEOUT = 4,
    STATUS_NO_ROOM = 5,
    STATUS_INTERNAL_ERROR = 6,
    STATUS_INVALID = 7,
    STATUS_CRC_WRONG = 8,
    STATUS_MIFARE_NACK = 9,
};

Public Attributes Documentation

variable uid

Uid MFRC522::uid;

Public Static Attributes Documentation

variable FIFO_SIZE

const uint8_t MFRC522::FIFO_SIZE;

Public Functions Documentation

function MFRC522

MFRC522::MFRC522 (
    PinName sda,
    PinName scl,
    uint32_t frequency = 400000
)

MFRC522 constructor

Parameters:

  • sda I2C sda pin

  • scl I2C scl pin

Constructor. Prepares the output pins.

function MFRC522

MFRC522::MFRC522 (
    PinName sda,
    PinName scl,
    PinName reset
)

MFRC522 constructor

Parameters:

  • sda I2C sda pin

  • scl I2C scl pin

  • reset Reset pin

Constructor. Prepares the output pins.

function ~MFRC522

MFRC522::~MFRC522 ()

MFRC522 destructor Destructor.

function PCD_Init

int MFRC522::PCD_Init (
    void 
)

Initializes the MFRC522 chip.

function PCD_Reset

int MFRC522::PCD_Reset (
    void 
)

Performs a soft reset on the MFRC522 chip and waits for it to be ready again.

function PCD_AntennaOn

int MFRC522::PCD_AntennaOn (
    void 
)

Turns the antenna on by enabling pins TX1 and TX2. After a reset these pins disabled.

int MFRC522::PCD_WriteRegister (
    uint8_t reg,
    uint8_t value
)

Writes a byte to the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

Parameters:

  • reg The register to write to. One of the PCD_Register enums.

  • value The value to write.

Writes a byte to the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

int MFRC522::PCD_WriteRegister (
    uint8_t reg,
    uint8_t count,
    uint8_t * values
)

Writes a number of bytes to the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

Parameters:

  • reg The register to write to. One of the PCD_Register enums.

  • count The number of bytes to write to the register

  • values The values to write. Byte array.

Writes a number of bytes to the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

uint8_t MFRC522::PCD_ReadRegister (
    uint8_t reg
)

Reads a byte from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

Parameters:

  • reg The register to read from. One of the PCD_Register enums.

Returns:

Register value

Reads a byte from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

void MFRC522::PCD_ReadRegister (
    uint8_t reg,
    uint8_t count,
    uint8_t * values,
    uint8_t rxAlign = 0
)

Reads a number of bytes from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

Parameters:

  • reg The register to read from. One of the PCD_Register enums.

  • count The number of bytes to read.

  • values Byte array to store the values in.

  • rxAlign Only bit positions rxAlign..7 in values[0] are updated.

Reads a number of bytes from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.

void MFRC522::PCD_SetRegisterBits (
    uint8_t reg,
    uint8_t mask
)

Sets the bits given in mask in register reg.

Parameters:

  • reg The register to update. One of the PCD_Register enums.

  • mask The bits to set.

Sets the bits given in mask in register reg.

void MFRC522::PCD_ClrRegisterBits (
    uint8_t reg,
    uint8_t mask
)

Clears the bits given in mask from register reg.

Parameters:

  • reg The register to update. One of the PCD_Register enums.

  • mask The bits to clear.

Clears the bits given in mask from register reg.

uint8_t MFRC522::PCD_CalculateCRC (
    uint8_t * data,
    uint8_t length,
    uint8_t * result
)

Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.

Parameters:

  • data Pointer to the data to transfer to the FIFO for CRC calculation.

  • length The number of bytes to transfer.

  • result Pointer to result buffer. Result is written to result[0..1], low byte first.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.

uint8_t MFRC522::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
)

Executes the Transceive command. CRC validation can only be done if backData and backLen are specified.

Parameters:

  • sendData Pointer to the data to transfer to the FIFO.

  • sendLen Number of bytes to transfer to the FIFO.

  • backData NULL or pointer to buffer if data should be read back after executing the command.

  • backLen Max number of bytes to write to *backData. Out: The number of bytes returned.

  • validBits The number of valid bits in the last byte. 0 for 8 valid bits. Default NULL.

  • rxAlign Defines the bit position in backData[0] for the first bit received. Default 0.

  • checkCRC True => The last two bytes of the response is assumed to be a CRC_A that must be validated.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

Executes the Transceive command. CRC validation can only be done if backData and backLen are specified.

uint8_t MFRC522::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
)

Transfers data to the MFRC522 FIFO, executes a commend, waits for completion and transfers data back from the FIFO. CRC validation can only be done if backData and backLen are specified.

Parameters:

  • command The command to execute. One of the PCD_Command enums.

  • waitIRq The bits in the ComIrqReg register that signals successful completion of the command.

  • sendData Pointer to the data to transfer to the FIFO.

  • sendLen Number of bytes to transfer to the FIFO.

  • backData NULL or pointer to buffer if data should be read back after executing the command.

  • backLen In: Max number of bytes to write to *backData. Out: The number of bytes returned.

  • validBits In/Out: The number of valid bits in the last byte. 0 for 8 valid bits.

  • rxAlign In: Defines the bit position in backData[0] for the first bit received. Default 0.

  • checkCRC In: True => The last two bytes of the response is assumed to be a CRC_A that must be validated.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

Transfers data to the MFRC522 FIFO, executes a commend, waits for completion and transfers data back from the FIFO. CRC validation can only be done if backData and backLen are specified.

function PICC_RequestA

uint8_t MFRC522::PICC_RequestA (
    uint8_t * bufferATQA,
    uint8_t * bufferSize
)

Transmits a REQuest command, Type A. Invites PICCs in state IDLE to go to READY and prepare for anticollision or selection. 7 bit frame. Beware: When two PICCs are in the field at the same time I often get STATUS_TIMEOUT - probably due do bad antenna design.

Parameters:

  • bufferATQA The buffer to store the ATQA (Answer to request) in

  • bufferSize Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

function PICC_WakeupA

uint8_t MFRC522::PICC_WakeupA (
    uint8_t * bufferATQA,
    uint8_t * bufferSize
)

Transmits a 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. Beware: When two PICCs are in the field at the same time I often get STATUS_TIMEOUT - probably due do bad antenna design.

Parameters:

  • bufferATQA The buffer to store the ATQA (Answer to request) in

  • bufferSize Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

Transmits a 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. Beware: When two PICCs are in the field at the same time I often get STATUS_TIMEOUT - probably due do bad antenna design.

uint8_t MFRC522::PICC_REQA_or_WUPA (
    uint8_t command,
    uint8_t * bufferATQA,
    uint8_t * bufferSize
)

Transmits REQA or WUPA commands. Beware: When two PICCs are in the field at the same time I often get STATUS_TIMEOUT - probably due do bad antenna design.

Parameters:

  • command The command to send - PICC_CMD_REQA or PICC_CMD_WUPA

  • bufferATQA The buffer to store the ATQA (Answer to request) in

  • bufferSize Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

function PICC_Select

uint8_t MFRC522::PICC_Select (
    Uid * uid,
    uint8_t validBits = 0
)

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?

Parameters:

  • uid Pointer to Uid struct. Normally output, but can also be used to supply a known UID.

  • validBits The number of known UID bits supplied in *uid. Normally 0. If set you must also supply uid->size.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

function PICC_HaltA

uint8_t MFRC522::PICC_HaltA (
    void 
)

Instructs a PICC in state ACTIVE(*) to go to state HALT.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::PCD_Authenticate (
    uint8_t command,
    uint8_t blockAddr,
    MIFARE_Key * key,
    Uid * uid
)

Executes the MFRC522 MFAuthent command. This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card. The authentication is described in the MFRC522 datasheet section 10.3.1.9 and http://www.nxp.com/documents/data_sheet/MF1S503x.pdf section 10.1. For use with MIFARE Classic PICCs. The PICC must be selected - ie in state ACTIVE(*) - before calling this function. Remember to call PCD_StopCrypto1() after communicating with the authenticated PICC - otherwise no new communications can start. All keys are set to FFFFFFFFFFFFh at chip delivery.

Parameters:

  • command PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B

  • blockAddr The block number. See numbering in the comments in the .h file.

  • key Pointer to the Crypteo1 key to use (6 bytes)

  • uid Pointer to Uid struct. The first 4 bytes of the UID is used.

Returns:

STATUS_OK on success, STATUS_??? otherwise. Probably STATUS_TIMEOUT if you supply the wrong key.

void MFRC522::PCD_StopCrypto1 (
    void 
)

Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start.

function MIFARE_Read

uint8_t MFRC522::MIFARE_Read (
    uint8_t blockAddr,
    uint8_t * buffer,
    uint8_t * bufferSize
)

Reads 16 bytes (+ 2 bytes CRC_A) from the active PICC. For MIFARE Classic the sector containing the block must be authenticated before calling this function. For MIFARE Ultralight only addresses 00h to 0Fh are decoded. The MF0ICU1 returns a NAK for higher addresses. The MF0ICU1 responds to the READ command by sending 16 bytes starting from the page address defined by the command argument. For example; if blockAddr is 03h then pages 03h, 04h, 05h, 06h are returned. A roll-back is implemented: If blockAddr is 0Eh, then the contents of pages 0Eh, 0Fh, 00h and 01h are returned. The buffer must be at least 18 bytes because a CRC_A is also returned. Checks the CRC_A before returning STATUS_OK.

Parameters:

  • blockAddr MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The first page to return data from.

  • buffer The buffer to store the data in

  • bufferSize Buffer size, at least 18 bytes. Also number of bytes returned if STATUS_OK.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

function MIFARE_Write

uint8_t MFRC522::MIFARE_Write (
    uint8_t blockAddr,
    uint8_t * buffer,
    uint8_t bufferSize
)

Writes 16 bytes to the active PICC. For MIFARE Classic the sector containing the block must be authenticated before calling this function. For MIFARE Ultralight the opretaion is called "COMPATIBILITY WRITE". Even though 16 bytes are transferred to the Ultralight PICC, only the least significant 4 bytes (bytes 0 to 3) are written to the specified address. It is recommended to set the remaining bytes 04h to 0Fh to all logic 0.

Parameters:

  • blockAddr MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The page (2-15) to write to.

  • buffer The 16 bytes to write to the PICC

  • bufferSize Buffer size, must be at least 16 bytes. Exactly 16 bytes are written.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::MIFARE_UltralightWrite (
    uint8_t page,
    uint8_t * buffer,
    uint8_t bufferSize
)

Writes a 4 byte page to the active MIFARE Ultralight PICC.

Parameters:

  • page The page (2-15) to write to.

  • buffer The 4 bytes to write to the PICC

  • bufferSize Buffer size, must be at least 4 bytes. Exactly 4 bytes are written.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::MIFARE_Decrement (
    uint8_t blockAddr,
    uint32_t delta
)

MIFARE Decrement subtracts the delta from the value of the addressed block, and stores the result in a volatile memory. For MIFARE Classic only. The sector containing the block must be authenticated before calling this function. Only for blocks in "value block" mode, ie with access bits [C1 C2 C3] = [110] or [001]. Use MIFARE_Transfer() to store the result in a block.

Parameters:

  • blockAddr The block (0-0xff) number.

  • delta This number is subtracted from the value of block blockAddr.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::MIFARE_Increment (
    uint8_t blockAddr,
    uint32_t delta
)

MIFARE Increment adds the delta to the value of the addressed block, and stores the result in a volatile memory. For MIFARE Classic only. The sector containing the block must be authenticated before calling this function. Only for blocks in "value block" mode, ie with access bits [C1 C2 C3] = [110] or [001]. Use MIFARE_Transfer() to store the result in a block.

Parameters:

  • blockAddr The block (0-0xff) number.

  • delta This number is added to the value of block blockAddr.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::MIFARE_Restore (
    uint8_t blockAddr
)

MIFARE Restore copies the value of the addressed block into a volatile memory. For MIFARE Classic only. The sector containing the block must be authenticated before calling this function. Only for blocks in "value block" mode, ie with access bits [C1 C2 C3] = [110] or [001]. Use MIFARE_Transfer() to store the result in a block.

Parameters:

  • blockAddr The block (0-0xff) number.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

MIFARE Restore copies the value of the addressed block into a volatile memory.

uint8_t MFRC522::MIFARE_Transfer (
    uint8_t blockAddr
)

MIFARE Transfer writes the value stored in the volatile memory into one MIFARE Classic block. For MIFARE Classic only. The sector containing the block must be authenticated before calling this function. Only for blocks in "value block" mode, ie with access bits [C1 C2 C3] = [110] or [001].

Parameters:

  • blockAddr The block (0-0xff) number.

Returns:

STATUS_OK on success, STATUS_??? otherwise.

uint8_t MFRC522::PCD_MIFARE_Transceive (
    uint8_t * sendData,
    uint8_t sendLen,
    bool acceptTimeout = false
)

Wrapper for MIFARE protocol communication. Adds CRC_A, executes the Transceive command and checks that the response is MF_ACK or a timeout.

Parameters:

  • sendData Pointer to the data to transfer to the FIFO. Do NOT include the CRC_A.

  • sendLen Number of bytes in sendData.

  • acceptTimeout True => A timeout is also success

Returns:

STATUS_OK on success, STATUS_??? otherwise.

function PICC_GetType

uint8_t MFRC522::PICC_GetType (
    uint8_t sak
)

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

Parameters:

Returns:

PICC_Type

char * MFRC522::PICC_GetTypeName (
    uint8_t type
)

Returns a string pointer to the PICC type name.

Parameters:

  • type One of the PICC_Type enums.

Returns:

A string pointer to the PICC type name.

char * MFRC522::GetStatusCodeName (
    uint8_t code
)

Returns a string pointer to a status code name.

Parameters:

  • code One of the StatusCode enums.

Returns:

A string pointer to a status code name.

void MFRC522::MIFARE_SetAccessBits (
    uint8_t * accessBitBuffer,
    uint8_t g0,
    uint8_t g1,
    uint8_t g2,
    uint8_t g3
)

Calculates the bit pattern needed for the specified access bits. In the [C1 C2 C3] tupples C1 is MSB (=4) and C3 is LSB (=1).

Parameters:

  • accessBitBuffer Pointer to byte 6, 7 and 8 in the sector trailer. Bytes [0..2] will be set.

  • g0 Access bits [C1 C2 C3] for block 0 (for sectors 0-31) or blocks 0-4 (for sectors 32-39)

  • g1 Access bits [C1 C2 C3] for block 1 (for sectors 0-31) or blocks 5-9 (for sectors 32-39)

  • g2 Access bits [C1 C2 C3] for block 2 (for sectors 0-31) or blocks 10-14 (for sectors 32-39)

  • g3 Access bits [C1 C2 C3] for the sector trailer, block 3 (for sectors 0-31) or block 15 (for sectors 32-39)

bool MFRC522::PICC_IsNewCardPresent (
    void 
)

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

bool MFRC522::PICC_ReadCardSerial (
    void 
)

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

The documentation for this class was generated from the following file: D:/w/hw-libs/\_libs\_/libraries/MFRC522.h

Last updated