pn532
no_std implementation of the Pn532 protocol using embedded_hal traits.
Since communication with the Pn532 can be rather slow at times, communication can be split into multiple parts, a timeout can be provided or an async runtime can be used.
The Pn532 supports different serial links. The Interface trait abstracts
over these different links.
Interface can be manually implemented or one the four provided interface structs can be used:
spi::SPIInterfacespi::SPIInterfaceWithIrqi2c::I2CInterfacei2c::I2CInterfaceWithIrq
Troubleshooting
General
- check you're using
Request::sam_configurationto initialize the PN532
I2C
- check wiring
- check you're using external pull-up resistors
SPI
- check wiring
- check you set the SPI mode to
Mode0(CPOL = 0, CPHA = 0) - check you set the SPI to LSB mode (oftentimes this is not the default) or enable the
msb-spifeature
SPI example
use ;
use IntoDuration; // trait for `ms()`, your HAL might have its own
// spi is a struct implementing embedded_hal::spi::SpiDevice
// timer is a struct implementing pn532::CountDown
let mut pn532: = new;
if let Err = pn532.process
if let Ok = pn532.process
msb-spi feature
If you want to use either spi::SPIInterface or spi::SPIInterfaceWithIrq and
your peripheral cannot be set to lsb mode you need to enable the msb-spi feature of this crate.
std feature
Enable the std feature to use serialport::SerialPortInterface.
Only works for targets supported by the serialport crate.