Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions docs/GPIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ I/O (GPIO).
`Beaglebone pin names table <https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/common.c#L73>`_


.. note::

On-board LEDs (USR0-USR3) are handled by LED class driver rather than the GPIO pin driver.

They have a different path in the /sys/ filesystem.

Setup the pin for output and write GPIO.HIGH or GPIO.LOW

Example::

# Use the config-pin command line tool to set a pin's function to GPIO
Expand All @@ -38,17 +46,36 @@ Example::
GPIO.output("P8_14", GPIO.HIGH) # You can also write '1' instead
GPIO.output("P8_14", GPIO.LOW) # You can also write '0' instead


# Blinking onboard led example
import Adafruit_BBIO.GPIO as GPIO
import time

for i in range(4):
GPIO.setup("USR%d" % i, GPIO.OUT)

while True:
for i in range(4):
GPIO.output("USR%d" % i, GPIO.HIGH)
time.sleep(1)
for i in range(4):
GPIO.output("USR%d" % i, GPIO.LOW)
time.sleep(1)


.. module:: Adafruit_BBIO.GPIO

.. function:: setup(channel, direction[, pull_up_down=PUD_OFF, initial=None, delay=0])
.. function:: setup(channel, direction[, pull_up_down=GPIO.PUD_OFF, initial=None, delay=0])

Set up the given GPIO channel, its direction and (optional) pull/up down control

:param str channel: GPIO channel to set up (e.g. "P8_16").
:param int direction: GPIO channel direction (:data:`IN` or :data:`OUT`).
:param int direction: GPIO channel direction
(:data:`GPIO.IN` or :data:`GPIO.OUT`).
:param int pull_up_down: pull-up/pull-down resistor configuration
(:data:`PUD_OFF`, :data:`PUD_UP` or :data:`PUD_DOWN`).
:param int initial: initial value for an output channel (:data:`LOW`/:data:`HIGH`).
(:data:`GPIO.PUD_OFF`, :data:`GPIO.PUD_UP` or :data:`GPIO.PUD_DOWN`).
:param int initial: initial value for an output channel
(:data:`GPIO.LOW`/:data:`GPIO.HIGH`).
:param int delay: time in milliseconds to wait after exporting the GPIO pin.

.. function:: cleanup()
Expand All @@ -66,7 +93,7 @@ Example::

:param str channel: GPIO channel to output the value to (e.g. "P8_16").
:param value: value to set the output to-- 0/1 or False/True
or :data:`LOW`/:data:`HIGH`.
or :data:`GPIO.LOW`/:data:`GPIO.HIGH`.
:type value: int or bool

.. function:: input(channel)
Expand All @@ -82,8 +109,8 @@ Example::
Enable edge detection events for the given GPIO channel.

:param str channel: GPIO channel to detect events from (e.g. "P8_16").
:param int edge: edge to detect–– :data:`RISING`, :data:`FALLING`
or :data:`BOTH`
:param int edge: edge to detect–– :data:`GPIO.RISING`, :data:`GPIO.FALLING`
or :data:`GPIO.BOTH`
:param func callback: a function to call once the event has been detected.
:param int bouncetime: switch bounce timeout in ms for the callback.

Expand Down Expand Up @@ -118,8 +145,8 @@ Example::
Wait for an edge on the given channel.

:param str channel: GPIO channel to wait on (e.g. "P8_16").
:param int edge: edge to detect–– :data:`RISING`, :data:`FALLING`
or :data:`BOTH`
:param int edge: edge to detect–– :data:`GPIO.RISING`, :data:`GPIO.FALLING`
or :data:`GPIO.BOTH`
:param int timeout: time to wait for an edge, in milliseconds.
-1 will wait forever.

Expand Down
8 changes: 4 additions & 4 deletions docs/SPI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ Example::
# spi = SPI(bus, device) #/dev/spidev<bus>.<device>

# /dev/spidev0.0
spi = SPI(1, 0)
spi = SPI(0, 0)
print(spi.xfer2([32, 11, 110, 22, 220]))
spi.close()

# /dev/spidev0.1
spi = SPI(1, 1)
spi = SPI(0, 1)
print(spi.xfer2([32, 11, 110, 22, 220]))
spi.close()

# /dev/spidev1.0
spi = SPI(2, 0)
spi = SPI(1, 0)
print(spi.xfer2([32, 11, 110, 22, 220]))
spi.close()

# /dev/spidev1.1
spi = SPI(2, 1)
spi = SPI(1, 1)
print(spi.xfer2([32, 11, 110, 22, 220]))
spi.close()

Expand Down