Skip to content

Commit c84bc31

Browse files
committed
Added SPI pins table and first shot at GPIO module. Functions still need to be documented
1 parent 746c22c commit c84bc31

File tree

1 file changed

+103
-6
lines changed

1 file changed

+103
-6
lines changed

docs/index.rst

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ Example::
102102
the given UART so that it can be accessed by other software that controls
103103
its serial lines.
104104

105-
:param channel: UART channel to set up. One of "UART1", "UART2",
105+
:param str channel: UART channel to set up. One of "UART1", "UART2",
106106
"UART4" or "UART5"
107-
:type channel: str
108107

109108
.. function:: cleanup()
110109

@@ -153,6 +152,16 @@ Because the SPI device interface is opened R/W, users of this module
153152
usually must have root permissions or be members of a group with granted
154153
access rights.
155154

155+
Pins used for SPI0 and SPI1
156+
+++++++++++++++++++++++++++
157+
158+
==== ===== ===== ===== =====
159+
PORT CS0 DO DI SCLK
160+
==== ===== ===== ===== =====
161+
SPI0 P9_17 P9_21 P9_18 P9_22
162+
SPI1 P9_28 P9_29 P9_30 P9_31
163+
==== ===== ===== ===== =====
164+
156165
Example::
157166

158167
import Adafruit_BBIO.SPI as SPI
@@ -166,17 +175,17 @@ Example::
166175
spi.close()
167176

168177
# /dev/spidev0.1
169-
spi = SPI(1,1)
178+
spi = SPI(1, 1)
170179
print(spi.xfer2([32, 11, 110, 22, 220]))
171180
spi.close()
172181

173182
# /dev/spidev1.0
174-
spi = SPI(2,0)
183+
spi = SPI(2, 0)
175184
print(spi.xfer2([32, 11, 110, 22, 220]))
176185
spi.close()
177186

178187
# /dev/spidev1.1
179-
spi = SPI(2,1)
188+
spi = SPI(2, 1)
180189
print(spi.xfer2([32, 11, 110, 22, 220]))
181190
spi.close()
182191

@@ -185,7 +194,7 @@ Example::
185194
.. class:: SPI(bus, client)
186195

187196
:param bus: bus number.
188-
:param client: client number.
197+
:param client: client device number.
189198
:returns: a new SPI object, optionally connected to the specified SPI
190199
device interface.
191200
:rtype: :class:`SPI`
@@ -268,6 +277,94 @@ Example::
268277
:returns: values transferred
269278
:rtype: list[int]
270279

280+
:mod:`GPIO` --- General Purpose I/O interface
281+
---------------------------------------------
282+
283+
TODO
284+
285+
Example::
286+
287+
# Use the config-pin command line tool to set a pin's function to GPIO
288+
# Then you can control it with the GPIO module from Python
289+
config-pin P9_14 gpio
290+
291+
import Adafruit_BBIO.GPIO as GPIO
292+
293+
# Set up pins as inputs or outputs
294+
GPIO.setup("P8_13", GPIO.IN)
295+
GPIO.setup("P8_14", GPIO.OUT)
296+
GPIO.setup("GPIO0_26", GPIO.OUT) # Alternative: use actual pin names
297+
298+
# Write a logic high or logic low
299+
GPIO.output("P8_14", GPIO.HIGH) # You can also write '1' instead
300+
GPIO.output("P8_14", GPIO.LOW) # You can also write '0' instead
301+
302+
.. module:: Adafruit_BBIO.GPIO
303+
304+
.. function:: setup()
305+
306+
:param str channel: UART channel to set up. One of "UART1", "UART2",
307+
"UART4" or "UART5"
308+
309+
.. attribute:: ALT0
310+
311+
Pin mode-- alternate function 0.
312+
313+
.. attribute:: BOTH
314+
315+
Edge detection-- detect both edges.
316+
317+
.. attribute:: FALLING
318+
319+
Edge detection-- detect falling edge.
320+
321+
.. attribute:: HIGH
322+
323+
Pin status-- logic low.
324+
325+
.. attribute:: IN
326+
327+
Pin mode-- input.
328+
329+
.. attribute:: LOW
330+
331+
Pin status-- logic low.
332+
333+
.. attribute:: OUT
334+
335+
Pin mode-- output.
336+
337+
.. attribute:: PUD_OFF
338+
339+
Pull-up/pull-down resistor type-- no pull-up/pull-down.
340+
341+
.. attribute:: PUD_DOWN
342+
343+
Pull-up/pull-down resistor type-- pull-down.
344+
345+
.. attribute:: PUD_UP
346+
347+
Pull-up/pull-down resistor type-- pull-up.
348+
349+
.. attribute:: RISING
350+
351+
Edge detection-- detect rising edge.
352+
353+
.. attribute:: VERSION
354+
355+
GPIO module version.
356+
357+
.. function:: cleanup()
358+
.. function:: output()
359+
.. function:: input()
360+
.. function:: add_event_detect()
361+
.. function:: remove_event_detect()
362+
.. function:: add_event_detected()
363+
.. function:: add_event_callback()
364+
.. function:: wait_for_edge()
365+
.. function:: gpio_function()
366+
.. function:: setwarnings()
367+
271368
Indices and tables
272369
==================
273370

0 commit comments

Comments
 (0)