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

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

Structs

Enums

  • The MFRC522 driver is ready for use.
  • The MFRC522 driver starts in this state and needs to be initialized before it can be used.

Traits

  • Implemented by the different states of the MFRC522 driver.

Type Aliases