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
Public Types Documentation
Public Attributes Documentation
Public Static Attributes Documentation
Public Functions Documentation
Parameters:
sda I2C sda pin
scl I2C scl pin
Constructor. Prepares the output pins.
Parameters:
sda I2C sda pin
scl I2C scl pin
reset Reset pin
Constructor. Prepares the output pins.
Turns the antenna on by enabling pins TX1 and TX2. After a reset these pins disabled.
Parameters:
reg The register to write to. One of the PCD_Register enums.
value The value to write.
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.
Parameters:
reg The register to read from. One of the PCD_Register enums.
Returns:
Register value
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:
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.
Instructs a PICC in state ACTIVE(*) to go to state HALT.
Returns:
STATUS_OK on success, STATUS_??? otherwise.
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)
Returns:
STATUS_OK on success, STATUS_??? otherwise. Probably STATUS_TIMEOUT if you supply the wrong key.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Translates the SAK (Select Acknowledge) to a PICC type.
Parameters:
Returns:
PICC_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.
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.
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)
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
Returns:
bool
The documentation for this class was generated from the following file: D:/w/hw-libs/\_libs\_/libraries/MFRC522.h
Last updated