All of the examples that I’ve seen are examples of setting up the Pi Pico as an SPI Master. In the application that I’m working on I need the pico to be configured as a slave. Can anyone provide me with an example that will enable the same functionality as would be achieved with this: https://os.mbed.com/docs/mbed-os/v6.16/apis/spislave.html
The standard Wire library in ArduinoCore-mbed is I2C slave capable and the RP2040 has it implemented. No need to go to the Mbed-os abstraction level.
Essentially this is a duplicate of
You should be able to implement an I2C slave with the begin(SLAVE_ADDRESS) / onReceive / onRequest callback functions just fine, just as described in official tutorials like
I2C won’t work for me because I’m connecting boards via several feet of ethernet cable and I2C doesn’t work well much past 50cm. Based on what I’ve read SPI is good to a couple of meters which is why I’m trying to use it.
ArduinoCore-mbed per the patches did not seem to be adding DEVICE_SPISLAVE capabilities to the RP2040 implementations, only STM32 has it.
However, Arduino-Pico by Earlephilhower, an alternative (I would even say, better) implementation of the Arduino core does have a SPISlave library with an example and documentation.
If you want it in ArduinoCore-mbed, you need to file an issue there, or add to the SPI slave impelementation to the patch files, recompile the whole of mbed-os etc. (a pain).
That seem a bit paradoxical because higher-frequency signals (usually SPI, multiple MHz) should degrade more over longer distances than lower-frequency signals (usally I2C, 400kHz standard).
And just to have mentioned it, there are “I2C to differential I2C” converters, which give the I2C signal a much, much longer distance.
Also, RS485 (again, differential), or Ethernet would come in question for longer distances. Some boards like “WIZNET W5500 EVB Pico” even come with on-board ethernet chips, directly integrated.