changes per comments

This commit is contained in:
Thomas Franks 2023-03-21 14:49:32 -04:00
parent 008565f650
commit 1859ca77d8
4 changed files with 58 additions and 48 deletions

View file

@ -50,40 +50,43 @@ class PN532_I2C(PN532):
uses clock stretching. Optional IRQ pin (not used), uses clock stretching. Optional IRQ pin (not used),
resetp pin and debugging output. resetp pin and debugging output.
:param busio.I2C i2c: The I2C bus the PN532 is connected to. :param ~busio.I2C i2c: The I2C bus the PN532 is connected to.
:param int address: The I2C device address. Defaults to :const:`0x24` :param int address: The I2C device address. Defaults to :const:`0x24`
:param DigitalInOut reset: board pin the PN532 reset is connected to :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to
:param DigitalInOut req: board pin the PN532 P32 is connected to :param digitalio.DigitalInOut req: board pin the PN532 P32 is connected to
:param bool debug: if true print additional debug statements :param bool debug: if True print additional debug statements. Defaults to False
**Quickstart: Importing and using the device** **Quickstart: Importing and using the device**
Here is an example of using the :class:`PN532_I2C` class.
First you will need to import the libraries to use the sensor
.. code-block:: python Here is an example of using the :class:`PN532_I2C` class.
First you will need to import the libraries to use the sensor
import board .. code-block:: python
import busio
from digitalio import DigitalInOut
from adafruit_pn532.i2c import PN532_I2C
Once this is done you can define your `board.I2C` object and define your object import board
.. code-block:: python import busio
from digitalio import DigitalInOut
from adafruit_pn532.i2c import PN532_I2C
i2c = busio.I2C(board.SCL, board.SDA) Once this is done you can define your `board.I2C` object and define your object
reset_pin = DigitalInOut(board.D6)
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
# wakeup! this means we don't need to do the I2C clock-stretch thing
req_pin = DigitalInOut(board.D12)
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
# Configure PN532 to communicate with MiFare cards
pn532.SAM_configuration()
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout .. code-block:: python
.. code-block:: python i2c = busio.I2C(board.SCL, board.SDA)
reset_pin = DigitalInOut(board.D6)
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
# wakeup! this means we don't need to do the I2C clock-stretch thing
req_pin = DigitalInOut(board.D12)
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
# Configure PN532 to communicate with MiFare cards
pn532.SAM_configuration()
uid = pn532.read_passive_target(timeout=0.5) Now you have access to the attributes and functions of the PN532 RFID/NFC
shield or breakout
.. code-block:: python
uid = pn532.read_passive_target(timeout=0.5)
""" """
self.debug = debug self.debug = debug

View file

@ -64,14 +64,14 @@ class PN532_SPI(PN532):
"""Create an instance of the PN532 class using SPI """Create an instance of the PN532 class using SPI
Optional IRQ pin (not used) Optional IRQ pin (not used)
:param busio.SPI spi: The spi bus the PN532 is connected to. :param ~busio.SPI spi: The spi bus the PN532 is connected to.
:param DigitalInOut cs: board pin the PN532 chip select line is connected to :param digitalio.DigitalInOut cs: board pin the PN532 chip select line is connected to
:param DigitalInOut irq: board pin the PN532 P32 is connected to :param digitalio.DigitalInOut irq: board pin the PN532 P32 is connected to
:param DigitalInOut reset: board pin the PN532 reset is connected to :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to
:param bool debug: if true print additional debug statements :param bool debug: if True print additional debug statements. Defaults to False
**Quickstart: Importing and using the device** **Quickstart: Importing and using the device**
Here is an example of using the :class:`PN532_I2C` class. Here is an example of using the :class:`PN532_SPI` class.
First you will need to import the libraries to use the sensor First you will need to import the libraries to use the sensor
.. code-block:: python .. code-block:: python
@ -82,13 +82,15 @@ class PN532_SPI(PN532):
from adafruit_pn532.spi import PN532_SPI from adafruit_pn532.spi import PN532_SPI
Once this is done you can define your `busio.SPI` object and define your PN532 object Once this is done you can define your `busio.SPI` object and define your PN532 object
.. code-block:: python .. code-block:: python
spi = busio.SPI(board.SCK, board.MOSI, board.MISO) spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs_pin = DigitalInOut(board.D5) cs_pin = DigitalInOut(board.D5)
pn532 = PN532_SPI(spi, cs_pin, debug=False) pn532 = PN532_SPI(spi, cs_pin, debug=False)
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout Now you have access to the attributes and functions of the PN532 RFID/NFC
shield or breakout
.. code-block:: python .. code-block:: python

View file

@ -38,32 +38,35 @@ class PN532_UART(PN532):
"""Create an instance of the PN532 class using Serial connection. """Create an instance of the PN532 class using Serial connection.
Optional reset pin and debugging output. Optional reset pin and debugging output.
:param busio.UART i2c: The I2C bus the PN532 is connected to. :param ~busio.UART uart: The uart object the PN532 is connected to.
:param DigitalInOut reset: board pin the PN532 reset is connected to :param digitalio.DigitalInOut reset: board pin the PN532 reset is connected to
:param bool debug: if true print additional debug statements :param bool debug: if True print additional debug statements. Defaults to False
**Quickstart: Importing and using the device** **Quickstart: Importing and using the device**
Here is an example of using the :class:`PN532_I2C` class.
First you will need to import the libraries to use the sensor
.. code-block:: python Here is an example of using the :class:`PN532_I2C` class.
First you will need to import the libraries to use the sensor
import board .. code-block:: python
import busio
from digitalio import DigitalInOut
from adafruit_pn532.uart import PN532_UART
Once this is done you can define your `busio.UART` object and define your PN532 object import board
.. code-block:: python import busio
from digitalio import DigitalInOut
from adafruit_pn532.uart import PN532_UART
uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) Once this is done you can define your `busio.UART` object and define your PN532 object
pn532 = PN532_UART(uart, debug=False)
Now you have access to the attributes and functions of the PN532 RFID/NFC shield or breakout .. code-block:: python
.. code-block:: python uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
pn532 = PN532_UART(uart, debug=False)
uid = pn532.read_passive_target(timeout=0.5) Now you have access to the attributes and functions of the PN532 RFID/NFC
shield or breakout
.. code-block:: python
uid = pn532.read_passive_target(timeout=0.5)
""" """
self.debug = debug self.debug = debug

View file

@ -39,6 +39,8 @@ intersphinx_mapping = {
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
} }
autoclass_content = "both"
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"] templates_path = ["_templates"]