ESP32 as SPI slave

jjwsei
Posts: 6
Joined: Fri Mar 01, 2019 1:31 pm

ESP32 as SPI slave

Postby jjwsei » Tue Sep 08, 2020 8:07 pm

I have run the spi_slave example in the ESP-IDF V3.3.2 and it works as I would expect. Now I am attempting to modify it in order to achieve the following:

1) The host MCU will at a 1hz rate send state information to the ESP32 over SPI which will then be relayed via BT to a smartphone app.
2) The ESP32 will process BT packets, at a random time determined by the app user, and should immediately upon receipt transfer the data over SPI to the host MCU.

I am using the handshake line in order to let the host MCU know that there is data waiting. I currently have the spi_slave_transmit command inside a task that is called every 15mS.

The issue that I am having trouble solving is getting the data that is received from the BT link to be immediately transferred to the host MCU. Currently the BT data is always lagging by one read which I assume is do to the call to spi_slave_transmit.

I have attempted to instead of using spi_slave_transmit, use spi_slave_queue_trans and spi_slave_get_trans_result but I am not able to achieve what I mention above.

First off, is what I am attempting to do possible with the ESP32? Secondly, what is the best approach to accomplishing it?

Thanks in advance!

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google Adsense [Bot], ShinyGlossy and 213 guests