http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html
Original post guides through enabling RPi to connect to a micro controller.
He uses wheezy, but this works fine in nOS 2.2 as of March 2014.
I am only saving the commands required to enable it and test.
Background of SPI available at original link.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo shutdown -h now
#After reboot, check spidev0.0 is in fact available
ls /dev/
wget http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git\;a=blob_plain\;f=Documentation/spi/spidev_test.c -O spidev_test.c
#Original link command did not have escape letter, which did not work on my pi connection through SSH, so this one includes two escapes for ;
nano spidev_test.c
#change the device to spidev0.0
gcc spidev_test.c
sudo ./a.out
#if it does not work it will print 00s
#if it does work it will print FF 40 00 95 DE AD BE EF BA AD F0 0D
#MISO and MOSI pins needs to be connected (GPIO 9 and GPIO 10)
#Positioning PI's HDMI port towards me, SD slot on the left, USB on the right, GPIO count begins from left bottom pin [1], incrementing to right up to GPIO 13.
#Then the top row left [14], to top right [26]
No comments:
Post a Comment