Skip to content

Commit f25179c

Browse files
authored
Add SPI instructions to README (#158)
1 parent 61af64e commit f25179c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,49 @@ ser.close()
204204
```
205205
* [Loopback test with UART1 and UART2](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart#testing-and-using-the-uart)
206206

207+
208+
### [SPI](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/spi)
209+
* Use [`config-pin` to set pin mode](https://github.com./beagleboard/bb.org-overlays/tree/master/tools/beaglebone-universal-io) for [SPI pins](http://beagleboard.org/static/images/cape-headers-spi.png)
210+
* SPI0
211+
* SPI0_CS0: `config-pin p9.17 spi_cs`
212+
* SPI0_D1: `config-pin p9.18 spi`
213+
* SPI0_D0: `config-pin p9.21 spi`
214+
* SPI0_SCLK: `config-pin p9.22 spi_sclk`
215+
* SPI1
216+
* SPI1_CS0: `config-pin p9.20 spi_cs`
217+
* SPI1_CS0: `config-pin p9.28 spi_cs`
218+
* SPI1_CS1: `config-pin p9.19 spi_cs`
219+
* SPI1_CS1: `config-pin p9.42 spi_cs`
220+
* SPI1_D0: `config-pin p9.29 spi`
221+
* SPI1_D1: `config-pin p9.30 spi`
222+
* SPI1_SCLK: `config-pin p9.31 spi_sclk`
223+
* Example:
224+
```
225+
from Adafruit_BBIO.SPI import SPI
226+
#spi = SPI(bus, device) #/dev/spidev<bus>.<device>
227+
228+
# /dev/spidev0.0
229+
spi = SPI(1,0)
230+
print(spi.xfer2([32, 11, 110, 22, 220]))
231+
spi.close()
232+
233+
# /dev/spidev0.1
234+
spi = SPI(1,1)
235+
print(spi.xfer2([32, 11, 110, 22, 220]))
236+
spi.close()
237+
238+
# /dev/spidev1.0
239+
spi = SPI(2,0)
240+
print(spi.xfer2([32, 11, 110, 22, 220]))
241+
spi.close()
242+
243+
# /dev/spidev1.1
244+
spi = SPI(2,1)
245+
print(spi.xfer2([32, 11, 110, 22, 220]))
246+
spi.close()
247+
```
248+
249+
207250
## Running tests
208251

209252
Install py.test to run the tests. You'll also need the python compiler package for pytest:

0 commit comments

Comments
 (0)