#![no_std] #![forbid(unsafe_code)] //! A `no_std` [`embedded-hal`] driver for the NXP PN532 NFC controller over I2C. //! //! This crate is a Rust port of the well-known //! [Adafruit/Seeed PN532 Arduino library](https://github.com/elechouse/PN532), //! targeting the I2C interface (the most common breakout-board wiring). //! //! The driver is transport-agnostic via the [`Interface`] trait; [`I2cInterface`] //! provides the I2C implementation on top of a blocking `embedded_hal::i2c::I2c` //! bus plus a `embedded_hal::delay::DelayNs` delay source. //! //! # Example //! //! ```ignore //! use embedded_hal::delay::DelayNs; //! use pn532::{BaudRate, I2cInterface, Pn532}; //! //! # struct Delay; //! # impl DelayNs for Delay { fn delay_ns(&mut self, _: u32) {} } //! # //! # fn demo(i2c: I2C, delay: Delay) //! # where I2C: embedded_hal::i2c::I2c //! # { //! let mut nfc = Pn532::new(I2cInterface::new(i2c, delay)); //! nfc.begin().unwrap(); //! nfc.sam_config().unwrap(); //! //! let uid = nfc //! .read_passive_target_id(BaudRate::ISO14443A106kbps, 1000) //! .unwrap(); //! if let Some(uid) = uid { //! // uid.bytes[..uid.len as usize] contains the card UID //! } //! # } //! ``` //! //! # Limitations //! //! * Responses are limited to 64 bytes, matching the PN532's internal packet //! buffer (this also constrains multi-block FeliCa reads). //! * The I2C interface is blocking and uses busy-wait polling for the PN532's //! "ready" flag, mirroring the original Arduino implementation. extern crate alloc; pub mod commands; pub mod error; #[cfg(feature = "felica")] pub mod felica; pub mod interface; pub(crate) mod driver; pub mod tg; #[cfg(feature = "mifare-classic")] pub mod mifare; #[cfg(feature = "iso14443a")] pub mod iso14443a; pub use commands::*; pub use driver::*; pub use error::*; pub use interface::*; #[cfg(feature = "defmt")] #[allow(unused_imports)] use defmt::{error, warn, info, debug, trace}; #[cfg(not(feature = "defmt"))] #[macro_export] macro_rules! error { ($($arg:tt)+) => {}; } #[cfg(not(feature = "defmt"))] #[macro_export] macro_rules! warn { ($($arg:tt)+) => {}; } #[cfg(not(feature = "defmt"))] #[macro_export] macro_rules! info { ($($arg:tt)+) => {}; } #[cfg(not(feature = "defmt"))] #[macro_export] macro_rules! debug { ($($arg:tt)+) => {}; } #[cfg(not(feature = "defmt"))] #[macro_export] macro_rules! trace { ($($arg:tt)+) => {}; }