55#define MFRC522_UID_MAX_SIZE 10
60#define MFRC522_MF_ACK 0xA
65#define MFRC522_MF_KEY_SIZE 6
252 const uint8_t *send_data, uint8_t send_len,
253 uint8_t *back_data, uint8_t *back_len,
254 uint8_t *valid_bits, uint8_t rx_align,
bool check_crc);
287 const uint8_t *send_data, uint8_t send_len,
288 uint8_t *back_data, uint8_t *back_len,
289 uint8_t *valid_bits, uint8_t rx_align,
bool check_crc);
355 uint8_t *buffer_atqa, uint8_t *buffer_size);
502 const uint8_t *buffer, uint8_t buffer_size);
671 const uint8_t *send_data, uint8_t send_len,
672 bool accept_timeout);
708 uint8_t g0, uint8_t g1, uint8_t g2, uint8_t g3);
754 const uint8_t *new_uid, uint8_t new_uid_size);
#define MFRC522_UID_MAX_SIZE
Maximum size for uid byte array.
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.
void mfrc522_pcd_antenna_off(mfrc522_t *dev)
Turns the antenna off by disabling pins TX1 and TX2.
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_mifare_open_uid_backdoor(mfrc522_t *dev)
Performs the "magic sequence" needed to get Chinese UID changeable Mifare cards to allow writing to s...
int mfrc522_pcd_init(mfrc522_t *dev, const mfrc522_params_t *params)
Initialization.
void mfrc522_pcd_soft_power_up(mfrc522_t *dev)
Set the MFRC522 to leave soft power-down mode.
mfrc522_picc_type_t
PICC types.
int mfrc522_mifare_transfer(mfrc522_t *dev, uint8_t block_addr)
Write the value from the Transfer Buffer into destination block.
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.
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.
mfrc522_pcd_rx_gain_t mfrc522_pcd_get_antenna_gain(mfrc522_t *dev)
Get the current MFRC522 receiver gain.
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_mifare_unbrick_uid_sector(mfrc522_t *dev)
Reset entire sector 0 to zeroes, so the card can be read again by readers.
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 fr...
const char * mfrc522_picc_get_type_string(mfrc522_picc_type_t picc_type)
Returns the name for the PICC type.
int mfrc522_picc_read_card_serial(mfrc522_t *dev, mfrc522_uid_t *uid)
Simple wrapper around mfrc522_picc_select()
void mfrc522_pcd_reset(mfrc522_t *dev)
Performs a soft reset on the MFRC522 chip and waits for it to be ready again.
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_picc_wakeup_a(mfrc522_t *dev, uint8_t *buffer_atqa, uint8_t *buffer_size)
Transmits WUPA, Type A.
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.
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.
#define MFRC522_MF_KEY_SIZE
A Mifare Crypto1 key is 6 bytes.
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.
void mfrc522_pcd_soft_power_down(mfrc522_t *dev)
Set the MFRC522 to soft power-down mode.
int mfrc522_mifare_restore(mfrc522_t *dev, uint8_t block_addr)
Copies the value of the addressed block into the Transfer Buffer.
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_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 Buff...
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.
void mfrc522_picc_dump_to_serial(mfrc522_t *dev, mfrc522_uid_t *uid)
Dump debug info about the selected PICC to stdout.
int mfrc522_picc_halt_a(mfrc522_t *dev)
Instructs a PICC in state ACTIVE(*) to go to state HALT.
void mfrc522_picc_dump_mifare_ultralight_to_serial(mfrc522_t *dev)
Dump memory contents of a MIFARE Ultralight PICC to stdout.
void mfrc522_pcd_dump_version_to_serial(mfrc522_t *dev)
Dump debug info about the connected PCD to stdout.
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,...
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.
bool mfrc522_pcd_perform_self_test(mfrc522_t *dev)
Perform a self-test of the MFRC522.
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.
mfrc522_picc_type_t mfrc522_picc_get_type(uint8_t sak)
Translates the SAK (Select Acknowledge) to a PICC type.
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.
bool mfrc522_picc_is_new_card_present(mfrc522_t *dev)
Checks whether a new card could be detected.
void mfrc522_pcd_antenna_on(mfrc522_t *dev)
Turns the antenna on by enabling pins TX1 and TX2.
int mfrc522_pcd_ntag216_auth(mfrc522_t *dev, const uint8_t *password, uint8_t p_ack[])
Authenticate with a NTAG216.
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_pcd_set_antenna_gain(mfrc522_t *dev, mfrc522_pcd_rx_gain_t rx_gain)
Set the MFRC522 receiver gain.
int mfrc522_picc_request_a(mfrc522_t *dev, uint8_t *buffer_atqa, uint8_t *buffer_size)
Transmits REQA, Type A.
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.
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_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.
@ MFRC522_PICC_TYPE_ISO_14443_4
PICC compliant with ISO/IEC 14443-4.
@ MFRC522_PICC_TYPE_MIFARE_UL
MIFARE Ultralight or Ultralight C.
@ MFRC522_PICC_TYPE_MIFARE_4K
MIFARE Classic protocol, 4KB.
@ MFRC522_PICC_TYPE_MIFARE_PLUS
MIFARE Plus.
@ MFRC522_PICC_TYPE_MIFARE_DESFIRE
MIFARE DESFire.
@ MFRC522_PICC_TYPE_MIFARE_MINI
MIFARE Classic protocol, 320 bytes.
@ MFRC522_PICC_TYPE_TNP3XXX
Only mentioned in NXP AN 10833 MIFARE Type Identification Procedure.
@ MFRC522_PICC_TYPE_UNKNOWN
unknown type
@ MFRC522_PICC_TYPE_MIFARE_1K
MIFARE Classic protocol, 1KB.
@ MFRC522_PICC_TYPE_ISO_18092
PICC compliant with ISO/IEC 18092 (NFC)
@ MFRC522_PICC_TYPE_NOT_COMPLETE
SAK indicates UID is not complete.
Register definitions for the MFRC522 controller.
mfrc522_pcd_command_t
Command definitions.
mfrc522_picc_command_t
PICC command definitions.
mfrc522_pcd_register_t
Register definitions.
mfrc522_pcd_rx_gain_t
Receiver gain definitions.
Low-level SPI peripheral driver interface definition.
A struct used for passing a MIFARE Crypto1 key.
MFRC522 device initialization parameters.
spi_t spi_dev
SPI bus the controller is connected to.
spi_clk_t spi_clk
SPI clock speed.
gpio_t cs_pin
Slave select pin.
MFRC522 device data structure type.
mfrc522_params_t params
Device initialization parameters.
A struct used for passing the UID of a PICC.
uint8_t sak
The SAK (Select acknowledge) byte returned from the PICC after successful selection.
uint8_t size
Number of bytes in the UID.