########################
# HOWTO : SPI using linux  3.8.x
# using device trees
########################

########################
# References
########################

http://hipstercircuits.com/enable-spi-with-device-tree-on-beaglebone-black-copy-paste
http://elinux.org/BeagleBone_Black_Enable_SPIDEV
http://www.linux.com/learn/tutorials/746860-how-to-access-chips-over-the-spi-on-beaglebone-black

# add lines to optargs in uEnv.txt
optargs=quiet drm.debug=7 capemgr.enable_partno=BB-SPIDEV0,BB-SPIDEV1

- separate line
- before mmc_args

# run from systemd service (bash script)
echo BB-SPIDEV0 > /sys/devices/bone_capemgr.8/slots

# For testing, there is a spidev driver test available here
https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c

# The newer version of spidev supports quad transfers, and
# the test program has been updated; available here
# (though not supported in our version of spidev)
https://www.kernel.org/doc/Documentation/spi/spidev_test.c
https://raw.github.com/torvalds/linux/master/Documentation/spi/spidev_test.c

# to build it:
gcc -o spidev_test spidev_test.c

# to run it
sudo ./spidev_test -h
./spidev_test: invalid option -- 'h'
Usage: ./spidev_test [-DsbdlHOLC3]
  -D --device   device to use (default /dev/spidev1.1)
  -s --speed    max speed (Hz)
  -d --delay    delay (usec)
  -b --bpw      bits per word 
  -l --loop     loopback
  -H --cpha     clock phase
  -O --cpol     clock polarity
  -L --lsb      least significant bit first
  -C --cs-high  chip select active high
  -3 --3wire    SI/SO signals shared