Demo code can be downloaded here

Connection diagram

Note: I have an older raspberry pi which may be wired slightly differently to the new models.

Explanatory note

The Raspberry Pi's I/O can be a little limited. It can be extended using a slave processor on the I2C or SPI bus. This little project deals shows how a low cost board like the STM32F0Discovery can be used as a slave I/O processor for the Raspberry Pi. Communications are carried out using the SPI bus and a Python extension library called py-spidev.
The communications protocol in question is quite simple (an 8 bit command with an 8 bit parameter earns a 16 bit reply) however it could be easily extended. The demo code shows how a Python script on a Raspberry Pi can set/reset an I/O pin on the STM32F0Discovery board. There are of course many other possibilities - you could change the duty of a PWM output which might change a servo motor position or alter the power being supplied to some device, you could acquire some analogue data etc. This is a proof of concept, use it as you will.
The Raspberry Pi Python script is called The STM32F0Discovery code is spread across a number of C progs and a Makefile.
Back to STM32F0Discovery home