|
28 | 28 | import board
|
29 | 29 | import busio
|
30 | 30 | from digitalio import DigitalInOut
|
31 |
| -import adafruit_pn532 |
| 31 | +# |
| 32 | +# NOTE: pick the import that matches the interface being used |
| 33 | +# |
| 34 | +#from adafruit_pn532.i2c import PN532_I2C |
| 35 | +from adafruit_pn532.spi import PN532_SPI |
| 36 | +#from adafruit_pn532.uart import PN532_UART |
32 | 37 |
|
33 | 38 | # I2C connection:
|
34 | 39 | #i2c = busio.I2C(board.SCL, board.SDA)
|
35 | 40 |
|
36 | 41 | # Non-hardware reset/request with I2C
|
37 |
| -#pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False) |
| 42 | +#pn532 = PN532_I2C(i2c, debug=False) |
38 | 43 |
|
39 | 44 | # With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
40 | 45 | # harware reset
|
41 | 46 | #reset_pin = DigitalInOut(board.D6)
|
42 | 47 | # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
43 | 48 | # wakeup! this means we don't need to do the I2C clock-stretch thing
|
44 | 49 | #req_pin = DigitalInOut(board.D12)
|
45 |
| -#pn532 = adafruit_pn532.PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) |
| 50 | +#pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) |
46 | 51 |
|
47 | 52 | # SPI connection:
|
48 | 53 | spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
49 | 54 | cs_pin = DigitalInOut(board.D5)
|
50 |
| -pn532 = adafruit_pn532.PN532_SPI(spi, cs_pin, debug=False) |
| 55 | +pn532 = PN532_SPI(spi, cs_pin, debug=False) |
51 | 56 |
|
52 | 57 | # UART connection
|
53 | 58 | #uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
54 |
| -#pn532 = adafruit_pn532.PN532_UART(uart, debug=False) |
| 59 | +#pn532 = PN532_UART(uart, debug=False) |
55 | 60 |
|
56 | 61 | ic, ver, rev, support = pn532.get_firmware_version()
|
57 | 62 | print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
|
|
0 commit comments