Skip to content

Commit 008565f

Browse files
committed
add addtional RTD info
1 parent 0061f33 commit 008565f

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

adafruit_pn532/i2c.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,42 @@ def __init__(
4949
"""Create an instance of the PN532 class using I2C. Note that PN532
5050
uses clock stretching. Optional IRQ pin (not used),
5151
resetp pin and debugging output.
52+
53+
:param busio.I2C i2c: The I2C bus the PN532 is connected to.
54+
:param int address: The I2C device address. Defaults to :const:`0x24`
55+
:param DigitalInOut reset: board pin the PN532 reset is connected to
56+
:param DigitalInOut req: board pin the PN532 P32 is connected to
57+
:param bool debug: if true print additional debug statements
58+
59+
**Quickstart: Importing and using the device**
60+
Here is an example of using the :class:`PN532_I2C` class.
61+
First you will need to import the libraries to use the sensor
62+
63+
.. code-block:: python
64+
65+
import board
66+
import busio
67+
from digitalio import DigitalInOut
68+
from adafruit_pn532.i2c import PN532_I2C
69+
70+
Once this is done you can define your `board.I2C` object and define your object
71+
.. code-block:: python
72+
73+
i2c = busio.I2C(board.SCL, board.SDA)
74+
reset_pin = DigitalInOut(board.D6)
75+
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
76+
# wakeup! this means we don't need to do the I2C clock-stretch thing
77+
req_pin = DigitalInOut(board.D12)
78+
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
79+
# Configure PN532 to communicate with MiFare cards
80+
pn532.SAM_configuration()
81+
82+
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout
83+
84+
.. code-block:: python
85+
86+
uid = pn532.read_passive_target(timeout=0.5)
87+
5288
"""
5389
self.debug = debug
5490
self._req = req

adafruit_pn532/spi.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,40 @@ def __init__(
6161
reset: Optional[DigitalInOut] = None,
6262
debug: bool = False
6363
) -> None:
64-
"""Create an instance of the PN532 class using SPI"""
64+
"""Create an instance of the PN532 class using SPI
65+
Optional IRQ pin (not used)
66+
67+
:param busio.SPI spi: The spi bus the PN532 is connected to.
68+
:param DigitalInOut cs: board pin the PN532 chip select line is connected to
69+
:param DigitalInOut irq: board pin the PN532 P32 is connected to
70+
:param DigitalInOut reset: board pin the PN532 reset is connected to
71+
:param bool debug: if true print additional debug statements
72+
73+
**Quickstart: Importing and using the device**
74+
Here is an example of using the :class:`PN532_I2C` class.
75+
First you will need to import the libraries to use the sensor
76+
77+
.. code-block:: python
78+
79+
import board
80+
import busio
81+
from digitalio import DigitalInOut
82+
from adafruit_pn532.spi import PN532_SPI
83+
84+
Once this is done you can define your `busio.SPI` object and define your PN532 object
85+
.. code-block:: python
86+
87+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
88+
cs_pin = DigitalInOut(board.D5)
89+
pn532 = PN532_SPI(spi, cs_pin, debug=False)
90+
91+
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout
92+
93+
.. code-block:: python
94+
95+
uid = pn532.read_passive_target(timeout=0.5)
96+
97+
"""
6598
self.debug = debug
6699
self._spi = spi_device.SPIDevice(spi, cs_pin)
67100
super().__init__(debug=debug, irq=irq, reset=reset)

adafruit_pn532/uart.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@ def __init__(
3737
) -> None:
3838
"""Create an instance of the PN532 class using Serial connection.
3939
Optional reset pin and debugging output.
40+
41+
:param busio.UART i2c: The I2C bus the PN532 is connected to.
42+
:param DigitalInOut reset: board pin the PN532 reset is connected to
43+
:param bool debug: if true print additional debug statements
44+
45+
**Quickstart: Importing and using the device**
46+
Here is an example of using the :class:`PN532_I2C` class.
47+
First you will need to import the libraries to use the sensor
48+
49+
.. code-block:: python
50+
51+
import board
52+
import busio
53+
from digitalio import DigitalInOut
54+
from adafruit_pn532.uart import PN532_UART
55+
56+
Once this is done you can define your `busio.UART` object and define your PN532 object
57+
.. code-block:: python
58+
59+
uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
60+
pn532 = PN532_UART(uart, debug=False)
61+
62+
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout
63+
64+
.. code-block:: python
65+
66+
uid = pn532.read_passive_target(timeout=0.5)
67+
4068
"""
4169
self.debug = debug
4270
self._uart = uart

0 commit comments

Comments
 (0)