Crate mfrc522

Source
Expand description

Driver library for interfacing with the MFRC522 contacless communication IC, based on the embedded-hal traits.

The MFRC522 is a Proximity Coupling Device (PCD) and communicates with a Proximity Integrated Circuit Card (PICC). The main purpose of the MFRC522 is to give the connected device (where we’re running this driver) the ability to read and write data from/to the card.

The MFRC522 supports 3 communication interfaces:

  • SPI
  • I2C
  • UART

However, currently only SPI communication is implemented in this crate.

§Quickstart

use mfrc522::comm::blocking::spi::SpiInterface;
use mfrc522::Mfrc522;

// Use your HAL to create an SPI device that implements the embedded-hal `SpiDevice` trait.
// This device manages the SPI bus and CS pin.
let spi = spi::Spi;

let itf = SpiInterface::new(spi);
let mut mfrc522 = Mfrc522::new(itf).init().unwrap();

// The reported version is expected to be 0x91 or 0x92
let mfrc522_version = mfrc522.version().unwrap();

Take a look at SpiInterface for options when creating the communication interface, and Mfrc522 for information on the functions that are available after initialization.

§Example applications

Modules§

comm
Contains implementations for the different communication interfaces that are available for the MFRC522.

Structs§

AtqA
Answer To reQuest type A
FifoData
Data read from the internal FIFO buffer
GenericUid
An identifier that is generic over the size.
Mfrc522
MFRC522 driver

Enums§

Error
Error type used in this crate
Initialized
The MFRC522 driver is ready for use.
RxGain
The receiver’s signal voltage gain factor
Type
PICC Type
Uid
The unique identifier returned by a PICC
Uninitialized
The MFRC522 driver starts in this state and needs to be initialized before it can be used.

Traits§

State
Implemented by the different states of the MFRC522 driver.

Type Aliases§

MifareKey
Key used for MIFARE authentication