PN532SpiImpl constructor
The spiBus
and spiChip
corresponds to /dev/spidev[spiBus]
.[spiChip]
.
The connection are the following:
The SCK/SCLK
of PN532 must be connected to SCK/SCLK
of the Pi.
The MOSI
of PN532 must be connected to MOSI
of the Pi.
The MISO
of PN532 must be connected to MISO
of the Pi.
The SS/NSS
of PN532 must be connected to CE0
or the one specifed in chipSelectPin
.
The irqPin
and the resetPin
are both optional!
OPTIONAL: The IRQ
of PN532 should be connected to a GPIO
pin of your choice (default: 16) of the Pi.
OPTIONAL: The RSTPDN
of PN532 should be connected to a GPIO
pin of your choice (default: 12) of the Pi.
For the IRQ
, RSTPDN
and chipSelectPin
pin you can choose any
GPIO pin of the pi just be aware that it seems like that the used dart
package dart_periphery
can't open all GPIOs
(like in my test GPIO09) - then just use a different one.
Also be sure that the irqPin
is properly connected since the interrupt
works the way that the irqPin
uses low to activate - means that if it
isn't properly connect the driver doesn't wait for the PN532 to be ready
for a response and you get kind of cryptic responses like
PN532BadResponseException
just because of the wrongly connected irqPin
.
Also be aware that the RSTPDN
pin is NOT the RSTO
Pin!
Implementation
PN532SpiImpl({
int? resetPin,
int? irqPin,
int? chipSelectPin,
int spiBus = 0,
int spiChip = 0,
}) : chipSelectGpio = chipSelectPin == null
? null
: GPIO(chipSelectPin, GPIOdirection.gpioDirIn),
spi = SPI(spiBus, spiChip, SPImode.mode0, 500000),
super(resetPin: resetPin, irqPin: irqPin) {
reset();
wakeUp();
}