Raspberry Pi SPI Client

spiPie

This example application illustrates the use of a Raspberry Pi to communicate with an Inventek Systems’ Serial-to-Wifi evaluation board over the SPI bus.

In order to build and run this application you must have the GCC toolchain installed on your Raspberry Pi as well as the Broadcom bcm2835 C library which can be obtained from the link provided in the download section.  Once these requirements have been met, you will need to wire the Raspberry Pi to your Serial-to-Wifi EVB according to the diagram above.  These connections allow the Raspberry Pi to send AT Commands to the EVB enabling an interface for wireless internet connectivity.

The SPI Benchmark application will connect the EVB to your wireless network and, as such, the correct SSID must be provided.  The SSID is set by issuing the AT command C1=… on line 68 of the file SPI_Benchmark.cpp.  The default setting is the string SSID which should be changed as appropriate.  Additionally, by default the application assumes an open network and, as a result, the security settings may need to be changed as appropriate.

Once these changes have been made the SPI Benchmark application can be built using the command

          g++   SPI_Benchmark.cpp   Serial2Wifi_SPI_Client.cpp   -l bcm2835   -l rt   -o SPI_Benchmark

which will generate an executable named SPI_Benchmark in your current working directory.  This executable must be run as super user from the command line

          sudo   ./SPI_Benchmark   PacketSize   IPAddress   Port

The input argument PacketSize is the number of bytes in a single packet which must be an integer value within the range of 1 and 1460 bytes. The input arguments IPAddress and Port are the IP Address and port number of the server that we will be connecting to. A valid set of input arguments would thus be:

          sudo   ./SPI_Benchmark   1460   10.10.1.90   8022

Once the application has been built you will need to provide a server for the client to join to.  The Hercules SETUP utility is freeware and provides this requisite functionality.  You can download the Hercules utility at the link provided.  Once downloaded, a server can be started by clicking the Listen button on either the TCP Server or UDP tab of this application.


Links

SPI Benchmark zip file

Broadcom bcm2835 C library for the Raspberry Pi

Hercules SETUP Utility

2015-07-24T17:39:43+00:00 2018-06-07T00:12:40+00:00