Page 1 of 1

Bidirectional SPI - Man in the Middle

Posted: Sun Mar 03, 2024 8:29 pm
by tim-hilt
I want to make my standing desk accessible via WiFi. I analysed the signal, which I found out was Bidirectional SPI. Usually SPI is transmitted on two wires. Bidirectional SPI is a mode, where a single wire is used to transmit and receive data.

I have attached a picture of how I think of the connections.

The motor has an idle-mode that it enters if no buttons are pressed for a few seconds. In idle mode the clock-signal is slowed down by a factor of 1000. As far as I understood, this can be realized by setting values in the SPI clock divider register on some microcontrollers (e.g. RP2040).

So in summary, I need esp-idf to have the following features:
  • Bidirectional SPI mode
  • Master- and slave-modes for SPI
  • SPI clock division (or other mechanism)
Can this project be achieved with esp-idf? I might also have gotten a few things wrong here, as I'm not the most experienced embedded-developer. Please correct me if this is the case!

Re: Bidirectional SPI - Man in the Middle

Posted: Mon Mar 04, 2024 3:09 pm
by MicroController
tim-hilt wrote:
Sun Mar 03, 2024 8:29 pm
So in summary, I need esp-idf to have the following features:
  • Bidirectional SPI mode
  • Master- and slave-modes for SPI
  • SPI clock division (or other mechanism)
Master and slave modes are supported via the IDF's SPI drivers, the clock frequency can be pretty freely configured with spi_bus_add_device().

The bi-directional part seems not to be directly supported, but should be possible by manually reconfiguring the IO pins (open-collector output, RX & TX routed to the same pin).

Re: Bidirectional SPI - Man in the Middle

Posted: Tue Mar 05, 2024 1:43 am
by ESP_Sprite
Note that the ESP32s SPI slave function is not intended to replicate the functionality of an existing device... you probably want to take a long and hard look at the existing protocol and see if you can implement it using SPI slave, or if you're better off using some other GPIO or even bitbanging it using the 'fast GPIO' functionality.