Introduction: *Preliminary* SPI on the Pi: Communicating With a SPI 3-axis Accelerometer Using a Raspberry Pi

Step by step guide on how to setup Raspbian, and communicate with a SPI device using bcm2835 SPI library (NOT bit banged!)

This is still very preliminary... I need to add better pictures of physical hookup, and work through some of the awkward code.

Step 1: Starting With a Blank SD Card, Download Raspbian Image, and Install Onto SD Card

Visit http://www.raspberrypi.org/downloads for instructions on how to install Raspbian

I downloaded:
    Raspbian image, and used
    Win32DiskImager to install on SD card

There's also more information at http://elinux.org/RPi_Easy_SD_Card_Setup

Step 2: Connect Raspberry Pi to TV/Monitor, and Run Through Initial Setup

(Internet connection not required yet)

Set timezone
enable SSH
Update

Then, Finish.

Terminal code:
reboot

Step 3: Optional: Operate Pi Headless

Excellent tutorial at
http://elinux.org/RPi_Remote_Access

I use Putty (Windows) or Terminal (Mac) to connect with SSH

Step 4: Recommended: Update OS

Terminal Code:
sudo apt-get update
sudo apt-get upgrade

Step 5: Optional: Setup IP Address E-mailer

I've set up my Pi to e-mail me it's IP address each time it boots.  This makes my life easier when I need to remote login using SSH.

Excellent tutorial at
http://elinux.org/RPi_Email_IP_On_Boot_Debian

Step 6: Optional - Setup VNC

Excellent tutorial at
http://elinux.org/RPi_VNC_Server

I didn't go through the entire tutorial... just the following steps:
$ sudo apt-get install tightvncserver
$ tightvncserver
$ vncserver :1 -geometry 1200x800 -depth 24

And, I created a script to keep my typing to a minimum.

Step 7: Install BCM2835 SPI Library

https://gist.github.com/3183536

Excellent documentation (and examples) at http://www.open.com.au/mikem/bcm2835

Terminal code:
cd;
// wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.5.tar.gz; // My Pi can't figure out this URL - unable to resolve host name?
wget http://67.192.60.197/mikem/bcm2835/bcm2835-1.5.tar.gz
tar xvfz bcm2835-1.5.tar.gz;
cd bcm2835-1.5;
./configure;
make;
sudo make install

Step 8: Get ADXL362 SPI Example

Note: Code is still very basic... need to improve


get ADXL362_RaspPi from https://github.com/annem/ADXL362_RaspPi
(How to do this on Pi, using wget?  I'm having trouble with this... "unable to resolve host address 'github.com'")

Step 9: Phyiscally Connect ADXL362 Breakout to Raspberry Pi GPIO

More details to come...

More info about ADXL362 (ultra low power 3-axis accelerometer) at analog.com/ADXL362

Connect 3v3, GND, SPI0 MOSI, SPI0 MISO, SPI0 SCLK, SPI0 CE0 N on Raspberry Pi to
VDDand VIO, GND (2), MOSI, MISO, SCLK, and CSB on ADXL362 Breakout board.


Step 10: Compile and Run ADXL362_RaspPi

terminal code:
gcc -o ADXL362_RaspPi -I ../bcm2835-1.5/src ../bcm2835.c ADXL_RaspPi.c
sudo ./ADXL362_RaspPi

Which I combines into a script called compileADXL362.