Loading...
Searching...
No Matches
#include "stdbool.h"
#include "periph/spi.h"
#include "mfrc522_regs.h"
+ Include dependency graph for mfrc522.h:

Go to the source code of this file.

Data Structures

struct  mfrc522_params_t
 MFRC522 device initialization parameters. More...
 
struct  mfrc522_t
 MFRC522 device data structure type. More...
 
struct  mfrc522_uid_t
 A struct used for passing the UID of a PICC. More...
 
struct  mfrc522_mifare_key_t
 A struct used for passing a MIFARE Crypto1 key. More...
 

Macros

#define MFRC522_UID_MAX_SIZE   10
 Maximum size for uid byte array.
 
#define MFRC522_MF_ACK   0xA
 The MIFARE Classic uses a 4 bit ACK/NAK.
 
#define MFRC522_MF_KEY_SIZE   6
 A Mifare Crypto1 key is 6 bytes.
 

Enumerations

enum  mfrc522_picc_type_t {
  MFRC522_PICC_TYPE_ISO_14443_4 , MFRC522_PICC_TYPE_ISO_18092 , MFRC522_PICC_TYPE_MIFARE_MINI , MFRC522_PICC_TYPE_MIFARE_1K ,
  MFRC522_PICC_TYPE_MIFARE_4K , MFRC522_PICC_TYPE_MIFARE_UL , MFRC522_PICC_TYPE_MIFARE_PLUS , MFRC522_PICC_TYPE_MIFARE_DESFIRE ,
  MFRC522_PICC_TYPE_TNP3XXX , MFRC522_PICC_TYPE_NOT_COMPLETE , MFRC522_PICC_TYPE_UNKNOWN
}
 PICC types. More...
 

Functions

void mfrc522_pcd_set_register_bitmask (mfrc522_t *dev, mfrc522_pcd_register_t reg, uint8_t mask)
 Sets the bits given in mask in register reg.
 
void mfrc522_pcd_clear_register_bitmask (mfrc522_t *dev, mfrc522_pcd_register_t reg, uint8_t mask)
 Clears the bits given in mask from register reg.
 
int mfrc522_pcd_calculate_crc (mfrc522_t *dev, const uint8_t *data, uint8_t length, uint8_t *result)
 Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.
 
int mfrc522_pcd_init (mfrc522_t *dev, const mfrc522_params_t *params)
 Initialization.
 
void mfrc522_pcd_reset (mfrc522_t *dev)
 Performs a soft reset on the MFRC522 chip and waits for it to be ready again.
 
void mfrc522_pcd_antenna_on (mfrc522_t *dev)
 Turns the antenna on by enabling pins TX1 and TX2.
 
void mfrc522_pcd_antenna_off (mfrc522_t *dev)
 Turns the antenna off by disabling pins TX1 and TX2.
 
mfrc522_pcd_rx_gain_t mfrc522_pcd_get_antenna_gain (mfrc522_t *dev)
 Get the current MFRC522 receiver gain.
 
void mfrc522_pcd_set_antenna_gain (mfrc522_t *dev, mfrc522_pcd_rx_gain_t rx_gain)
 Set the MFRC522 receiver gain.
 
void mfrc522_pcd_soft_power_down (mfrc522_t *dev)
 Set the MFRC522 to soft power-down mode.
 
void mfrc522_pcd_soft_power_up (mfrc522_t *dev)
 Set the MFRC522 to leave soft power-down mode.
 
int mfrc522_pcd_transceive_data (mfrc522_t *dev, const uint8_t *send_data, uint8_t send_len, uint8_t *back_data, uint8_t *back_len, uint8_t *valid_bits, uint8_t rx_align, bool check_crc)
 Executes MFRC522_CMD_TRANSCEIVE.
 
int mfrc522_pcd_communicate_with_picc (mfrc522_t *dev, mfrc522_pcd_command_t command, uint8_t wait_irq, const uint8_t *send_data, uint8_t send_len, uint8_t *back_data, uint8_t *back_len, uint8_t *valid_bits, uint8_t rx_align, bool check_crc)
 Transfers data to MFRC522's FIFO, executes a command, waits for completion and transfers data back from the FIFO.
 
int mfrc522_picc_request_a (mfrc522_t *dev, uint8_t *buffer_atqa, uint8_t *buffer_size)
 Transmits REQA, Type A.
 
int mfrc522_picc_wakeup_a (mfrc522_t *dev, uint8_t *buffer_atqa, uint8_t *buffer_size)
 Transmits WUPA, Type A.
 
int mfrc522_picc_reqa_or_wupa (mfrc522_t *dev, mfrc522_picc_command_t command, uint8_t *buffer_atqa, uint8_t *buffer_size)
 Transmits REQA (Type A) or WUPA (Type A) commands.
 
int mfrc522_picc_select (mfrc522_t *dev, mfrc522_uid_t *uid, uint8_t valid_bits)
 Transmits SELECT/ANTICOLLISION commands to select a single PICC.
 
int mfrc522_picc_halt_a (mfrc522_t *dev)
 Instructs a PICC in state ACTIVE(*) to go to state HALT.
 
int mfrc522_pcd_authenticate (mfrc522_t *dev, mfrc522_picc_command_t command, uint8_t block_addr, const mfrc522_mifare_key_t *key, const mfrc522_uid_t *uid)
 Executes the MFRC522 MFAuthent command.
 
void mfrc522_pcd_stop_crypto1 (mfrc522_t *dev)
 Used to exit the PCD from its authenticated state.
 
int mfrc522_mifare_read (mfrc522_t *dev, uint8_t block_addr, uint8_t *buffer, uint8_t *buffer_size)
 Read 16 bytes (+ 2 bytes CRC_A) from the active PICC.
 
int mfrc522_mifare_write (mfrc522_t *dev, uint8_t block_addr, const uint8_t *buffer, uint8_t buffer_size)
 Write 16 bytes to the active PICC.
 
int mfrc522_mifare_ultralight_write (mfrc522_t *dev, uint8_t page, const uint8_t *buffer)
 Write a 4 byte page to the active MIFARE Ultralight PICC.
 
int mfrc522_mifare_decrement (mfrc522_t *dev, uint8_t block_addr, int32_t delta)
 Subtract the operand from the value of the addressed block, and store the result in the Transfer Buffer.
 
int mfrc522_mifare_increment (mfrc522_t *dev, uint8_t block_addr, int32_t delta)
 Add the operand to the value of the addressed block, and store the result in the Transfer Buffer.
 
int mfrc522_mifare_restore (mfrc522_t *dev, uint8_t block_addr)
 Copies the value of the addressed block into the Transfer Buffer.
 
int mfrc522_mifare_transfer (mfrc522_t *dev, uint8_t block_addr)
 Write the value from the Transfer Buffer into destination block.
 
int mfrc522_mifare_get_value (mfrc522_t *dev, uint8_t block_addr, int32_t *value)
 Helper routine to read the current value from a Value Block.
 
int mfrc522_mifare_set_value (mfrc522_t *dev, uint8_t block_addr, int32_t value)
 Helper routine to write a specific value into a Value Block.
 
int mfrc522_pcd_ntag216_auth (mfrc522_t *dev, const uint8_t *password, uint8_t p_ack[])
 Authenticate with a NTAG216.
 
int mfrc522_pcd_mifare_transceive (mfrc522_t *dev, const uint8_t *send_data, uint8_t send_len, bool accept_timeout)
 Wrapper for MIFARE protocol communication.
 
mfrc522_picc_type_t mfrc522_picc_get_type (uint8_t sak)
 Translates the SAK (Select Acknowledge) to a PICC type.
 
const char * mfrc522_picc_get_type_string (mfrc522_picc_type_t picc_type)
 Returns the name for the PICC type.
 
void mfrc522_mifare_set_access_bits (uint8_t *access_bit_buffer, uint8_t g0, uint8_t g1, uint8_t g2, uint8_t g3)
 Calculates the bit pattern needed for the specified access bits.
 
int mfrc522_mifare_open_uid_backdoor (mfrc522_t *dev)
 Performs the "magic sequence" needed to get Chinese UID changeable Mifare cards to allow writing to sector 0, where the card UID is stored.
 
int mfrc522_mifare_set_uid (mfrc522_t *dev, mfrc522_uid_t *uid, const uint8_t *new_uid, uint8_t new_uid_size)
 Read entire block 0, including all manufacturer data, and overwrites that block with the new UID, a freshly calculated BCC, and the original manufacturer data.
 
int mfrc522_mifare_unbrick_uid_sector (mfrc522_t *dev)
 Reset entire sector 0 to zeroes, so the card can be read again by readers.
 
bool mfrc522_picc_is_new_card_present (mfrc522_t *dev)
 Checks whether a new card could be detected.
 
int mfrc522_picc_read_card_serial (mfrc522_t *dev, mfrc522_uid_t *uid)
 Simple wrapper around mfrc522_picc_select()
 
void mfrc522_pcd_dump_version_to_serial (mfrc522_t *dev)
 Dump debug info about the connected PCD to stdout.
 
void mfrc522_picc_dump_to_serial (mfrc522_t *dev, mfrc522_uid_t *uid)
 Dump debug info about the selected PICC to stdout.
 
void mfrc522_picc_dump_details_to_serial (mfrc522_uid_t *uid)
 Dump card info (UID, SAK, Type) about the selected PICC to stdout.
 
void mfrc522_picc_dump_mifare_classic_to_serial (mfrc522_t *dev, mfrc522_uid_t *uid, mfrc522_picc_type_t picc_type, mfrc522_mifare_key_t *key)
 Dump memory contents of a MIFARE Classic PICC to stdout.
 
void mfrc522_picc_dump_mifare_classic_sector_to_serial (mfrc522_t *dev, mfrc522_uid_t *uid, mfrc522_mifare_key_t *key, uint8_t sector)
 Dump memory contents of a sector of a MIFARE Classic PICC to stdout.
 
void mfrc522_picc_dump_mifare_ultralight_to_serial (mfrc522_t *dev)
 Dump memory contents of a MIFARE Ultralight PICC to stdout.
 
bool mfrc522_pcd_perform_self_test (mfrc522_t *dev)
 Perform a self-test of the MFRC522.