Skip to content

Commit 8aa8ac3

Browse files
Merge pull request #65 from tcfranks/main
add addtional RTD info
2 parents 0061f33 + 7edf5cf commit 8aa8ac3

File tree

5 files changed

+111
-3
lines changed

5 files changed

+111
-3
lines changed

adafruit_pn532/adafruit_pn532.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import time
3030
from digitalio import Direction
31-
3231
from micropython import const
3332

3433
try:
@@ -164,7 +163,7 @@ def __init__(
164163
*,
165164
debug: bool = False,
166165
irq: Optional[DigitalInOut] = None,
167-
reset: Optional[DigitalInOut] = None
166+
reset: Optional[DigitalInOut] = None,
168167
) -> None:
169168
"""Create an instance of the PN532 class"""
170169
self.low_power = True

adafruit_pn532/i2c.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,46 @@ 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 digitalio.DigitalInOut irq: board pin the PN532 IRQ is connected to
56+
:param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to
57+
:param digitalio.DigitalInOut req: board pin the PN532 P32 is connected to
58+
:param bool debug: if True print additional debug statements. Defaults to False
59+
60+
**Quickstart: Importing and using the device**
61+
62+
Here is an example of using the :class:`PN532_I2C` class.
63+
First you will need to import the libraries to use the sensor
64+
65+
.. code-block:: python
66+
67+
import board
68+
import busio
69+
from digitalio import DigitalInOut
70+
from adafruit_pn532.i2c import PN532_I2C
71+
72+
Once this is done you can define your `board.I2C` object and define your object
73+
74+
.. code-block:: python
75+
76+
i2c = busio.I2C(board.SCL, board.SDA)
77+
reset_pin = DigitalInOut(board.D6)
78+
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
79+
# wakeup! this means we don't need to do the I2C clock-stretch thing
80+
req_pin = DigitalInOut(board.D12)
81+
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
82+
# Configure PN532 to communicate with MiFare cards
83+
pn532.SAM_configuration()
84+
85+
Now you have access to the attributes and functions of the PN532 RFID/NFC
86+
shield or breakout
87+
88+
.. code-block:: python
89+
90+
uid = pn532.read_passive_target(timeout=0.5)
91+
5292
"""
5393
self.debug = debug
5494
self._req = req

adafruit_pn532/spi.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,43 @@ 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 digitalio.DigitalInOut cs: board pin the PN532 chip select line is connected to
69+
:param digitalio.DigitalInOut irq: board pin the PN532 P32 is connected to
70+
:param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to
71+
:param bool debug: if True print additional debug statements. Defaults to False
72+
73+
74+
**Quickstart: Importing and using the device**
75+
Here is an example of using the :class:`PN532_SPI` class.
76+
First you will need to import the libraries to use the sensor
77+
78+
.. code-block:: python
79+
80+
import board
81+
import busio
82+
from digitalio import DigitalInOut
83+
from adafruit_pn532.spi import PN532_SPI
84+
85+
Once this is done you can define your `busio.SPI` object and define your PN532 object
86+
87+
.. code-block:: python
88+
89+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
90+
cs_pin = DigitalInOut(board.D5)
91+
pn532 = PN532_SPI(spi, cs_pin, debug=False)
92+
93+
Now you have access to the attributes and functions of the PN532 RFID/NFC
94+
shield or breakout
95+
96+
.. code-block:: python
97+
98+
uid = pn532.read_passive_target(timeout=0.5)
99+
100+
"""
65101
self.debug = debug
66102
self._spi = spi_device.SPIDevice(spi, cs_pin)
67103
super().__init__(debug=debug, irq=irq, reset=reset)

adafruit_pn532/uart.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ 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 uart: The uart object the PN532 is connected to.
42+
:param digitalio.DigitalInOut reset: board pin the PN532 RSTOUT_N is connected to
43+
:param bool debug: if True print additional debug statements. Defaults to False
44+
45+
**Quickstart: Importing and using the device**
46+
47+
Here is an example of using the :class:`PN532_I2C` class.
48+
First you will need to import the libraries to use the sensor
49+
50+
.. code-block:: python
51+
52+
import board
53+
import busio
54+
from digitalio import DigitalInOut
55+
from adafruit_pn532.uart import PN532_UART
56+
57+
Once this is done you can define your `busio.UART` object and define your PN532 object
58+
59+
.. code-block:: python
60+
61+
uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
62+
pn532 = PN532_UART(uart, debug=False)
63+
64+
Now you have access to the attributes and functions of the PN532 RFID/NFC
65+
shield or breakout
66+
67+
.. code-block:: python
68+
69+
uid = pn532.read_passive_target(timeout=0.5)
70+
4071
"""
4172
self.debug = debug
4273
self._uart = uart

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
4040
}
4141

42+
autoclass_content = "both"
43+
4244
# Add any paths that contain templates here, relative to this directory.
4345
templates_path = ["_templates"]
4446

0 commit comments

Comments
 (0)