172#define MFRC522_FIFO_BUF_SIZE 64
177# define MFRC522_PICC_CASCADE_TAG 0x88
182#define MFRC522_BIT_COMMAND_RCV_OFF BIT5
192#define MFRC522_BIT_COMMAND_POWER_DOWN BIT4
201#define MFRC522_BITMASK_COMMAND_POWER_DOWN 0x0F
213#define MFRC522_BIT_COML_EN_IRQ_INV BIT7
219#define MFRC522_BIT_COML_EN_TX_I_EN BIT6
225#define MFRC522_BIT_COML_EN_RX_I_EN BIT5
231#define MFRC522_BIT_COML_EN_IDLE_I_EN BIT4
237#define MFRC522_BIT_COML_EN_HI_ALERT_I_EN BIT3
243#define MFRC522_BIT_COML_EN_LO_ALERT_I_EN BIT2
249#define MFRC522_BIT_COML_EN_ERR_I_EN BIT1
255#define MFRC522_BIT_COML_EN_TIMER_I_EN BIT0
263#define MFRC522_BIT_DIVL_EN_IRQ_PUSH_PULL BIT7
268#define MFRC522_BIT_DIVL_EN_MFIN_ACT_I_EN BIT4
274#define MFRC522_BIT_DIVL_EN_CRC_I_EN BIT2
283#define MFRC522_BIT_COM_IRQ_SET_1 BIT7
289#define MFRC522_BIT_COM_IRQ_TX_IRQ BIT6
296#define MFRC522_BIT_COM_IRQ_RX_IRQ BIT5
306#define MFRC522_BIT_COM_IRQ_IDLE_IRQ BIT4
313#define MFRC522_BIT_COM_IRQ_HI_ALERT_IRQ BIT3
320#define MFRC522_BIT_COM_IRQ_LO_ALERT_IRQ BIT2
325#define MFRC522_BIT_COM_IRQ_ERR_IRQ BIT1
330#define MFRC522_BIT_COM_IRQ_TIMER_IRQ BIT0
338#define MFRC522_BIT_DIV_IRQ_SET_2 BIT7
344#define MFRC522_BIT_DIV_IRQ_MFIN_ACT_IRQ BIT4
349#define MFRC522_BIT_DIV_IRQ_CRC_IRQ BIT2
359#define MFRC522_BIT_ERROR_WR_ERR BIT7
365#define MFRC522_BIT_ERROR_TEMP_ERR BIT6
371#define MFRC522_BIT_ERROR_BUFFER_OVFL BIT4
379#define MFRC522_BIT_ERROR_COLL_ERR BIT3
386#define MFRC522_BIT_ERROR_CRC_ERR BIT2
393#define MFRC522_BIT_ERROR_PARITY_ERR BIT1
402#define MFRC522_BIT_ERROR_PROTOCOL_ERR BIT0
413#define MFRC522_BIT_STATUS_1_CRC_OK BIT6
419#define MFRC522_BIT_STATUS_1_CRC_READY BIT5
426#define MFRC522_BIT_STATUS_1_IRQ BIT4
435#define MFRC522_BIT_STATUS_1_T_RUNNING BIT3
444#define MFRC522_BIT_STATUS_1_HI_ALERT BIT1
453#define MFRC522_BIT_STATUS_1_LO_ALERT BIT0
461#define MFRC522_BIT_STATUS_2_TEMP_SENS_CLEAR BIT7
469#define MFRC522_BIT_STATUS_2_I2C_FORCE_HS BIT6
478#define MFRC522_BIT_STATUS_2_MF_CRYPTO_1_ON BIT3
497#define MFRC522_BITMASK_STATUS_2_MODEM_STATE_2 0x07
508#define MFRC522_BITMASK_FIFO_DATA 0xFF
517#define MFRC522_BIT_FIFO_LEVEL_FLUSH_BUFFER BIT7
526#define MFRC522_BITMASK_FIFO_LEVEL_FIFO_LEVEL 0x7F
542#define MFRC522_BITMASK_WATER_LEVEL_WATER_LEVEL 0x3F
550#define MFRC522_BIT_CONTROL_T_STOP_NOW BIT7
556#define MFRC522_BIT_CONTROL_T_START_NOW BIT6
564#define MFRC522_BITMASK_CONTROL_RX_LAST_BITS 0x07
572#define MFRC522_BIT_BIT_FRAMING_START_SEND BIT7
590#define MFRC522_BITMASK_BIT_FRAMING_RX_ALIGN 0x70
599#define MFRC522_BIT_BIT_FRAMING_TX_LAST_BITS 0x07
607#define MFRC522_BIT_COLL_VALUES_AFTER_COLL BIT7
613#define MFRC522_BIT_COLL_COLL_POS_NOT_VALID BIT5
627#define MFRC522_BITMASK_COLL_COLL_POS 0x1F
637#define MFRC522_BIT_MODE_MSB_FIRST BIT7
642#define MFRC522_BIT_MODE_TX_WAIT_RF BIT5
651#define MFRC522_BIT_MODE_POL_MFIN BIT3
666#define MFRC522_BITMASK_MODE_CRC_PRESET 0x03
674#define MFRC522_BIT_TX_MODE_TX_CRC_EN BIT7
687#define MFRC522_BITMASK_TX_MODE_TX_SPEED 0x70
692#define MFRC522_BIT_TX_MODE_INV_MOD BIT3
700#define MFRC522_BIT_RX_MODE_RX_CRC_EN BIT7
713#define MFRC522_BITMASK_RX_MODE_RX_SPEED 0x70
719#define MFRC522_BIT_RX_MODE_RX_NO_ERR BIT3
736#define MFRC522_BIT_RX_MODE_RX_MULTIPLE BIT2
743#define MFRC522_BIT_TX_CONTROL_INV_TX2_RF_ON BIT7
748#define MFRC522_BIT_TX_CONTROL_INV_TX1_RF_ON BIT6
753#define MFRC522_BIT_TX_CONTROL_INV_TX2_RF_OFF BIT5
758#define MFRC522_BIT_TX_CONTROL_INV_TX1_RF_OFF BIT4
765#define MFRC522_BIT_TX_CONTROL_TX2_CW BIT3
771#define MFRC522_BIT_TX_CONTROL_TX2_RF_EN BIT1
777#define MFRC522_BIT_TX_CONTROL_TX1_RF_EN BIT0
785#define MFRC522_BIT_TX_ASK_FORCE_100_ASK BIT6
802#define MFRC522_BITMASK_TX_SEL_DRIVER_SEL 0x30
821#define MFRC522_BITMASK_TX_SEL_MF_OUT_SEL 0x0F
836#define MFRC522_BITMASK_RX_SEL_UART_SEL 0xC0
847#define MFRC522_BITMASK_RX_SEL_RX_WAIT 0x3F
858#define MFRC522_BITMASK_RX_THRESHHOLD_MIN_LEVEL 0xF0
868#define MFRC522_BITMASK_RX_THRESHHOLD_COLL_LEVEL 0x07
882#define MFRC522_BITMASK_DEMOD_ADD_IQ 0xC0
888#define MFRC522_BIT_DEMOD_FIX_IQ BIT5
903#define MFRC522_BIT_DEMOD_T_PRESCAL_EVEN BIT4
911#define MFRC522_BITMASK_DEMOD_TAU_RCV 0x0C
918#define MFRC522_BITMASK_DEMOD_TAU_SYNC 0x03
928#define MFRC522_BITMASK_MF_TX_TX_WAIT 0x03
937#define MFRC522_BIT_MF_RX_PARITY_DISABLE BIT4
947#define MFRC522_BITMASK_SERIAL_SPEED_BR_T0 0xE0
955#define MFRC522_BITMASK_SERIAL_SPEED_BR_T1 0x1F
965#define MFRC522_BITMASK_CRC_RESULT_MSB_CRC_RESULT_MSB 0xFF
974#define MFRC522_BITMASK_CRC_RESULT_LSB_CRC_RESULT_LSB 0xFF
985#define MFRC522_BITMASK_MOD_WIDTH 0xFF
1005#define MFRC522_BITMASK_RF_CFG_RX_GAIN 0x70
1018#define MFRC522_BITMASK_GS_N_CW_GS_N 0xF0
1029#define MFRC522_BITMASK_GS_N_MOD_GS_N 0x0F
1041#define MFRC522_BITMASK_CW_GS_P_CW_GS_P 0x3F
1054#define MFRC522_BITMASK_MOD_GS_P_MOD_GS_P 0x3F
1068#define MFRC522_BIT_T_MODE_T_AUTO BIT7
1082#define MFRC522_BITMASK_T_MODE_T_GATED 0x60
1090#define MFRC522_BIT_T_MODE_T_AUTO_RESTART BIT4
1108#define MFRC522_BITMASK_T_MODE_T_PRESCALER_HI 0x0F
1125#define MFRC522_BITMASK_T_PRESCALER_T_PRESCALER_LO 0xFF
1136#define MFRC522_BITMASK_T_RELOAD_MSB_T_RELOAD_VAL_HI 0xFF
1145#define MFRC522_BITMASK_T_RELOAD_LSB_T_RELOAD_VAL_LO 0xFF
1154#define MFRC522_BITMASK_T_COUNTER_VAL_MSB_T_COUNTER_VAL_HI 0xFF
1161#define MFRC522_BITMASK_T_COUNTER_VAL_LSB_T_COUNTER_VAL_LO 0xFF
Helper functions for bit arithmetic.
mfrc522_pcd_command_t
Command definitions.
@ MFRC522_CMD_MEM
Stores 25 bytes into the internal buffer.
@ MFRC522_CMD_NO_CMD_CHANGE
No command change, can be used to modify the CommandReg register bits without affecting the command,...
@ MFRC522_CMD_MF_AUTHENT
Performs the MIFARE standard authentication as a reader.
@ MFRC522_CMD_TRANSMIT
Transmits data from the FIFO buffer.
@ MFRC522_CMD_CALC_CRC
Activates the CRC coprocessor or performs a self test.
@ MFRC522_CMD_RECEIVE
Activates the receiver circuits.
@ MFRC522_CMD_SOFT_RESET
Resets the MFRC522.
@ MFRC522_CMD_TRANSCEIVE
Transmits data from FIFO buffer to antenna and automatically activates the receiver after transmissio...
@ MFRC522_CMD_GENERATE_RANDOM_ID
Generates a 10-byte random ID number.
@ MFRC522_CMD_IDLE
No action, cancels current command execution.
mfrc522_picc_command_t
PICC command definitions.
@ MFRC522_PICC_CMD_MF_PERS_UID_USAGE
Set anti-collision, selection and authentication behaviour.
@ MFRC522_PICC_CMD_MF_AUTH_KEY_B
Authentication with Key B.
@ MFRC522_PICC_CMD_ISO_14443_SEL_CL1
Anti collision/Select, Cascade Level 1.
@ MFRC522_PICC_CMD_MF_UL_READ
Read one block of 16 bytes.
@ MFRC522_PICC_CMD_MF_UL_WRITE
Transfers 16 bytes, but only writes least significant 4 bytes.
@ MFRC522_PICC_CMD_MF_SET_MOD_TYPE
Set load modulation strength.
@ MFRC522_PICC_CMD_ISO_14443_HLTA
HLTA command, Type A.
@ MFRC522_PICC_CMD_ISO_14443_WUPA
Wake-UP command, Type A.
@ MFRC522_PICC_CMD_ISO_14443_REQA
REQuest command, Type A.
@ MFRC522_PICC_CMD_MF_TRANSFER
Write the value from the Transfer Buffer into destination block.
@ MFRC522_PICC_CMD_MF_WRITE
Write one block of 16 bytes.
@ MFRC522_PICC_CMD_ISO_14443_SEL_CL3
Anti collision/Select, Cascade Level 3.
@ MFRC522_PICC_CMD_MF_READ
Read one block of 16 bytes.
@ MFRC522_PICC_CMD_ISO_14443_RATS
Request command for Answer To Reset.
@ MFRC522_PICC_CMD_ISO_14443_SEL_CL2
Anti collision/Select, Cascade Level 2.
@ MFRC522_PICC_CMD_MF_INCREMENT
Increment: Adds the operand to the value of the addressed block, and stores the result in the Transfe...
@ MFRC522_PICC_CMD_MF_UL_COMPAT_WRITE
Write one block of 16 bytes.
@ MFRC522_PICC_CMD_MF_DECREMENT
Decrement: Subtracts the operand from the value of the addressed block, and stores the result in the ...
@ MFRC522_PICC_CMD_MF_AUTH_KEY_A
Authentication with Key A.
@ MFRC522_PICC_CMD_MF_RESTORE
Restore: Copies the value of the addressed block into the Transfer Buffer.
mfrc522_pcd_register_t
Register definitions.
@ MFRC522_REG_RF_CFG
Configures the receiver gain.
@ MFRC522_REG_DIV_IRQ
Interrupt request bits.
@ MFRC522_REG_CRC_RESULT_LSB
Shows the lower 8 bits of the CRC calculation.
@ MFRC522_REG_T_MODE
Defines settings for the internal timer.
@ MFRC522_REG_TEST_PIN_EN
Enables pin output driver on pins D1 to D7.
@ MFRC522_REG_TEST_PIN_VALUE
Defines the values for D1 to D7 when it is used as an I/O bus.
@ MFRC522_REG_DEMOD
Defines demodulator settings.
@ MFRC522_REG_T_RELOAD_MSB
Defines the higher 8 bits of 16-bit timer reload value.
@ MFRC522_REG_TX_ASK
Controls the setting of the transmission modulation.
@ MFRC522_REG_ERROR
Error bits showing the error status of the last command executed.
@ MFRC522_REG_T_COUNTER_VAL_MSB
Shows the higher 8 bits of 16-bit timer value.
@ MFRC522_REG_COMMAND
Starts and stops command execution.
@ MFRC522_REG_ANALOG_TEST
Controls the pins AUX1 and AUX2.
@ MFRC522_REG_COM_IRQ
Interrupt request bits.
@ MFRC522_REG_RX_THRESHHOLD
Selects thresholds for the bit decoder.
@ MFRC522_REG_BIT_FRAMING
Adjustments for bit-oriented frames.
@ MFRC522_REG_TEST_BUS
Shows the status of the internal test bus.
@ MFRC522_REG_TX_SEL
Selects the internal sources for the antenna driver.
@ MFRC522_REG_STATUS_2
Receiver and transmitter status bits.
@ MFRC522_REG_MF_TX
Controls some MIFARE communication transmit parameters.
@ MFRC522_REG_SERIAL_SPEED
Selects the speed of the serial UART interface.
@ MFRC522_REG_T_PRESCALER
Defines settings for the internal timer.
@ MFRC522_REG_CRC_RESULT_MSB
Shows the higher 8 bits of the CRC calculation.
@ MFRC522_REG_TEST_SEL_1
General test signal configuration.
@ MFRC522_REG_RX_MODE
Defines reception data rate and framing.
@ MFRC522_REG_RX_SEL
Selects internal receiver settings.
@ MFRC522_REG_TX_MODE
Defines transmission data rate and framing.
@ MFRC522_REG_GS_N
Selects the conductance of the antenna driver pins TX1 and TX2 for modulation.
@ MFRC522_REG_VERSION
Shows the software version.
@ MFRC522_REG_STATUS_1
Communication status bits.
@ MFRC522_REG_TEST_DAC2
Defines the test value for TestDAC2.
@ MFRC522_REG_T_COUNTER_VAL_LSB
Shows the lower 8 bits of 16-bit timer value.
@ MFRC522_REG_CONTROL
Miscellaneous control registers.
@ MFRC522_REG_TEST_ADC
Shows the value of ADC I and Q channels.
@ MFRC522_REG_CW_GS_P
Defines the conductance of the p-driver output during periods of no modulation.
@ MFRC522_REG_FIFO_DATA
Input and output of 64 byte FIFO buffer.
@ MFRC522_REG_TEST_DAC_1
Defines the test value for TestDAC1.
@ MFRC522_REG_TX_CONTROL
Controls the logical behavior of the antenna driver pins TX1 and TX2.
@ MFRC522_REG_WATER_LEVEL
Level for FIFO underflow and overflow warning.
@ MFRC522_REG_MODE
Defines general modes for transmitting and receiving.
@ MFRC522_REG_AUTO_TEST
Controls the digital self test.
@ MFRC522_REG_T_RELOAD_LSB
Defines the lower 8 bits of 16-bit timer reload value.
@ MFRC522_REG_MOD_WIDTH
Controls the ModWidth setting.
@ MFRC522_REG_COLL
Bit position of the first bit-collision detected on the RF interface.
@ MFRC522_REG_MF_RX
Controls some MIFARE communication receive parameters.
@ MFRC522_REG_MOD_GS_P
Defines the conductance of the p-driver output during periods of modulation.
@ MFRC522_REG_FIFO_LEVEL
Number of bytes stored in the FIFO buffer.
@ MFRC522_REG_DIVL_EN
Enable and disable interrupt request control bits.
@ MFRC522_REG_COML_EN
Enable and disable interrupt request control bits.
@ MFRC522_REG_TEST_SEL_2
General test signal configuration and PRBS control.
mfrc522_pcd_rx_gain_t
Receiver gain definitions.
@ MFRC522_RXGAIN_MIN
18 dB, minimum, convenience for MFRC522_RXGAIN_18_DB
@ MFRC522_RXGAIN_AVG
33 dB, average, convenience for MFRC522_RXGAIN_33_DB
@ MFRC522_RXGAIN_33_DB
33 dB, average, and typical default
@ MFRC522_RXGAIN_48_DB
48 dB, maximum
@ MFRC522_RXGAIN_43_DB
43 dB
@ MFRC522_RXGAIN_38_DB
38 dB
@ MFRC522_RXGAIN_23_DB
23 dB
@ MFRC522_RXGAIN_23_DB_2
23 dB, duplicate for MFRC522_RXGAIN_23_DB
@ MFRC522_RXGAIN_18_DB
18 dB, minimum
@ MFRC522_RXGAIN_MAX
48 dB, maximum, convenience for MFRC522_RXGAIN_48_DB
@ MFRC522_RXGAIN_18_DB_2
18 dB, duplicate for MFRC522_RXGAIN_18_DB