Talking over SPI between the Raspberry-Pi and SRF
- Font size: Larger Smaller
- Hits: 729
- 2 Comments
- Subscribe to this entry
- Bookmark
Here is the code for my quick SRF SPI python class.
http://openmicros.org/images/EVE/SRFSPI.zip
This was just a quick class to implement the SRF's SPI protocol and give a couple of TX/RX buffers.
At the bottom of the script is a simple test routine that sends out a--HELLO---- , grabs what ever is already in the SRF's internal buffer then goes into AT command mode and queries the firmware version.
If you would like to give it a go here is how.
First up SPI firmware for the SRF is here on Github, grab the SerialPassThru-V0.68-24MHz-SPI.bin file and flash your XRF/SRF (yes this will work on an XRF), If you have an EVE the SRF will be preloaded with this SPI firmware.
I found the quickest way to get SPI working on Raspbian was using WiringPi great loader tool.
Install WirepinPi then run the following command
$ gpio load spi
This brings up the SPI drivers and give the user access.
The SRFSPI class I have done is in python3 and requires the Quick2Wire python libraries
Install the Quick2Wire libray from github
That should be all the setup done, to run the SRFSPI.py script type the following
$ python3 SRFSPI.py
Let me know how you get on
Matt
Comments
-
Please login first in order for you to submit comments

Hi,
I followed your recipe, and I all but succeeded, I received the following output:
>> a--HELLO----
[97, 45, 45, 72, 69, 76, 76, 79, 45, 45, 45, 45]
111
109
109
91
221
93
221
223
109
109
109
109
+++
[43, 43, 43]
107
107
107
ATVR
[65, 84, 86, 82, 13]
95
85
214
214
253
led in a strange way.
Ron