I finally had some free time and could test the SPI slave lib posted above.
The good news is that generally speaking, it works . Master talks to slave and slave talks to master.
Now what's strange is that the slave messages returned to the master (answers) are corrupt.
Here's the result of the samples (SPISlave_SafeMaster on an ESP and SPISlave_Test on another ESP):
Basically, the only change I made is that the slave now dumps not only the questions but also its answers on the serial port.
As you can see, the answer dumped by the master is corrupt, but still, it has the right length and the characters are always the same except one.
I first thought of a MSB-LSB issue, but then I noticed that the only character that changes skips one value: d-f-h-j-l-n-p, so it looks like answers are shifted one bit to the left.
I changed the master code to shift answers back to the right and then answers were OK (well, I'm losing the highest bit but it doesn't matter in 7-bit ascii):
Finally, I took a look at the signals on my scope and (although its SPI decoding is flaky), playing with the "sampling clock edge" setting, I noticed I could fix some bytes:
So obviously, there is a timing issue, like if the MISO signal changes on the clock edge when the master samples the signal.
I will look again at the SPI registers and see if I find something related to those timings.
Kind regards,
Vicne