Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I've never used SPI before (for serial communication) and was wondering if any experienced Pi users out there know if the Pi board can use SPI to send and receive data to other MCUs on different boards.

If so, do these other boards need to be Pi's as well? Or can it be any other SPI-capable board?

How does SPI communication work on a Pi? Does it work in the form of user-level terminal commands, like:

// Turn a green LED on
send_to_spi 0x39943

Or is it something that has to be written in C and exist inside a running application? Any concrete examples or articles with concrete examples are greatly appreciated. Thanks in advance.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

It is possible to connect the RPI to other devices via spi. You need to enable the kernel module and allow yourself access to the device.

sudo modprobe spi_bcm2708
sudo chown `id -u`.`id -g` /dev/spidev0.*

Then you can use this c file to test the dpi-device: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/spi/spidev_test.c

Have a look at these links:

https://projects.drogon.net/understanding-spi-on-the-raspberry-pi/

http://mitchtech.net/raspberry-pi-arduino-spi/

http://elinux.org/RPi_Low-level_peripherals

Best of luck BjB

share|improve this answer
    
Awesome answer - thanks @BjB. It's tough to ask for something specific when you're not even sure what to ask! Your answer provides me with everything I need, thanks again. –  zharvey Dec 10 '12 at 14:04
    
Isn't it better to add you user to the spi group?. pi seems to be added by default in raspbian. –  John La Rooy Dec 11 '13 at 3:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.