SPI is included with the Adafruit_BBIO library. The following are the basics on how to use it.

You can import the SPI module:
Copy Code
from Adafruit_BBIO.SPI import SPI
Once you've imported it, you'll want to initialize the bus and device:
Copy Code
spi = SPI(0,0)
The BeagleBone Black (BBB) includes SPI0, as well as SPI1. SPI1 is currently not available by default as the HDMI interface is utilizing one of the pins.
Note: It is not possible to use SPI1 on the BeagleBone Black without disabling the HDMI interface.
There are four /dev/spidev* bus and device combinations available. They are available by executing the following code:
Copy Code
#import the library
from Adafruit_BBIO.SPI import SPI

#Only need to execute one of the following lines:
#spi = SPI(bus, device) #/dev/spidev<bus>.<device>
spi = SPI(0,0)	#/dev/spidev1.0
spi = SPI(0,1)	#/dev/spidev1.1
spi = SPI(1,0)	#/dev/spidev2.0
spi = SPI(1,1)	#/dev/spidev2.1
If you'd like to disable HDMI to access SPI1, you can add the following to your uEnv.txt file in the small FAT partition on your BBB:
Copy Code
mkdir /mnt/boot
mount /dev/mmcblk0p1 /mnt/boot
nano /mnt/boot/uEnv.txt
#change contents of uEnv.txt to the following:
optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

Pins used for SPI0 and SPI1

PORT CS0 DO DI SCLK
SPI0 P9_17 P9_21 P9_18 P9_22
SPI1 P9_28 P9_29 P9_30 P9_31
Last updated on 2014-04-20 at 04.21.30 AM Published on 2013-06-13 at 09.16.24 PM