lucamacavero
Member
Hi all,
some days ago I asked for a question: basically I had to implement an emulation of two sensors that behave as a SPI slave for testing purposes. Working with Arduino UNO was fine, but Arduino can behave as a single SPI slave, so two Arduinos for two sensors. Not the best.
I switched to Teensy 4.1 thinking that it would be possible to set up an interrupt to do what I wanted, that is to dynamically reply to the requests of the System Under Test. Well no, it is not possible. The only way to do that was to bit-bang SPI.
Here it is, SoftwareSpi_T4 is a small library that bit-bangs SPI. It allows you to emulate multiple slaves (as many as the free pins you have I guess).
I was able to run two SPI slave up to 2 Mbps each, with no inter-byte delay. Above this threshold, my logic analyzer is too bad to go .
Master implementation has not been tested yet.
Any comments or suggestions are welcome.
Luca
some days ago I asked for a question: basically I had to implement an emulation of two sensors that behave as a SPI slave for testing purposes. Working with Arduino UNO was fine, but Arduino can behave as a single SPI slave, so two Arduinos for two sensors. Not the best.
I switched to Teensy 4.1 thinking that it would be possible to set up an interrupt to do what I wanted, that is to dynamically reply to the requests of the System Under Test. Well no, it is not possible. The only way to do that was to bit-bang SPI.
Here it is, SoftwareSpi_T4 is a small library that bit-bangs SPI. It allows you to emulate multiple slaves (as many as the free pins you have I guess).
I was able to run two SPI slave up to 2 Mbps each, with no inter-byte delay. Above this threshold, my logic analyzer is too bad to go .
Master implementation has not been tested yet.
Any comments or suggestions are welcome.
Luca