Bidirectional SPI - Man in the Middle

tim-hilt
Posts: 5
Joined: Thu Feb 29, 2024 4:03 pm

Bidirectional SPI - Man in the Middle

Postby tim-hilt » Sun Mar 03, 2024 8:29 pm

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!
Attachments
circuit.png
circuit.png (105.2 KiB) Viewed 1726 times

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Bidirectional SPI - Man in the Middle

Postby MicroController » Mon Mar 04, 2024 3:09 pm

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).

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Bidirectional SPI - Man in the Middle

Postby ESP_Sprite » Tue Mar 05, 2024 1:43 am

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.

Who is online

Users browsing this forum: No registered users and 101 guests