Kernel driver for SPI for the Raspberry Pi to drive hardware inferface boards for IO expansion is nearly finished.
You can download the pre-compiled kernel with spi driver included here — just make a backup of your original kernel.img file on the boot partition of your SD card and replace it with this one.
Power up the Raspberry Pi and log in.
type dmesg | grep spi and you should see
pi@raspberrypi:~$ dmesg | grep spi
in spi_init driver
bcm2835_spi_probe base 0x20204000, remapped 0xcc80c000
bcm2835_spi setbits wrote 0x00041030 to 0xcc80c000
bcm2835_spi clrbits wrote 0x00041000 to 0xcc80c000
bcm2835_spi bcm2835_spi.0: registered master spi0
spi spi0.0: setup mode 0, 8 bits/w, 20000 Hz max –> 0
bcm2835_spi bcm2835_spi.0: registered child spi0.0
spi spi0.1: setup mode 0, 8 bits/w, 20000 Hz max –> 0
bcm2835_spi bcm2835_spi.0: registered child spi0.1
bcm2835_spi_probe complete – 0
Now you need to switch over the pins from general IO to the SPI module. This should be in the pinctrl module, but in the meantime download http://gromit.cs.man.ac.uk/RaspberryPi/switchPinCtrl and execute it with root permissions.
now try sending the a character to the spi with chipselect 0. e.g.
echo -n x > /dev/spidev0.0
Or with chipselect 1:
echo -n x > /dev/spidev0.1
(The -n tells echo not to send a newline character)
Please let us know how you get on. We want to hear your comments and bug reports.
The following will be changed in future releases
- Alternative SPI modes (e.g. clock and data polarity/sample times)
- Clock speed (dependent on reading clock speed from board)
- GPIO pinmux/pinctrl
- User defined enable/disable of SPI
- Remove debugging statements
Source is available here: