adafruit / Adafruit_CircuitPython_PN532

CircuitPython driver for the PN532 NFC/RFID Breakout and PN532 NFC/RFID Shield
MIT License
91 stars 47 forks source link

Remove delays #40

Closed dunkmann00 closed 3 years ago

dunkmann00 commented 4 years ago

This fixes #39.

I tested this code on an itsybitsy m4 express and everything worked as expected. It was even returning the firmware version on the first attempt.

dunkmann00 commented 4 years ago

In the event that we do have _req connected I think we are supposed to call it first, before any command is sent.

Here is another excerpt from the manual:

Fig 43. Handshake in case of I2C link – case 2

And the relevant text that follows:

  • The PN532 is in Power Down mode (T_PD1), The host controller wants to send a frame to the PN532, and so it asserts the H_REQ line. That makes the PN532 waking up (1) and it acknowledges with P70_IRQ pin (2),
  • Then before sending the command frame (3), the host controller has 2 possibilities:
    • either the host controller waits for a defined delay (twup) which guarantees in that case that the PN532 will be waken up when the I2C frame will be sent,
    • or the host controller monitors the P70_IRQ pin to check when the PN532 is woken up (with a maximum timeout of twup). This option can optimize the overall waiting time if the PN532 was not asleep; there is no need to wait the maximum wakeup time (tready < twup).
dunkmann00 commented 3 years ago

Closing this in favor of #41.