Connecting two SPI Master with ESP32 Slave-to-Slave bridge.
Posted: Wed Jul 30, 2025 12:53 pm
Hello all,
1) One idea is to copy the received value into the buffer of the already queued transaction. But that is specifically forbidden according to documentation. "This function hands over ownership of the buffers in trans_desc to the SPI slave driver; the application is not to access this memory until spi_slave_queue_trans is called to hand ownership back to the application."
2) Another idea is to complete reset and newly initialize SPI B ("spi_slave_free()" + "spi_slave_initialize()"). This actuially seems to work, but what an overhead.
- I need to have two SPI Master devices to communicate with each other (let's assume two Raspberry Pis)
- My plan is to put an ESP32 in the middle with two SPI slaves configured. What is receives on one side A is relayed to the other side B and vice versa.
- When it did receive something on A, it would signal through GPIO to master B to start pickup and vice versa.
- I do not know if A or B starts to communicate first. So I configure a transaction in SPI slave A and B with "spi_slave_queue_trans()" and (busy) wait (loop) with "spi_slave_get_trans_result()"
- If for A "spi_slave_get_trans_result" directly returns nothing there, it loops to check B with "spi_slave_get_trans_result" nothing there and continous the loop until something ... let's say ... arrives in A
- I take the value received from A and want to put it in that on B with "spi_slave_queue_trans()". But wait!! There already still is the trabnsaction in the queue that I had to put there to be able to listen if B would send something first.
- So before I can inform B through GPIO, to pick up the data, I have to discard that transaction from B's queue. But there seems to be no way to do that.
1) One idea is to copy the received value into the buffer of the already queued transaction. But that is specifically forbidden according to documentation. "This function hands over ownership of the buffers in trans_desc to the SPI slave driver; the application is not to access this memory until spi_slave_queue_trans is called to hand ownership back to the application."
2) Another idea is to complete reset and newly initialize SPI B ("spi_slave_free()" + "spi_slave_initialize()"). This actuially seems to work, but what an overhead.