I have the ESP32 set up as a slave device using SPI as the communication protocol. As such the ESP32 listens for commands from the controller and sends responses to the controller. This means that the ESP is either in receive only mode (when listening) or send only mode (when responding). The clock is of course generated by the controller.
So lets say that the controller wants to send 40 bytes of command data to the ESP32. I obviously need a rx_buffer setting up but do I need a tx_buffer as well?
Similarly, when the ESP is responding, do I need both buffers or can I just supply a tx_buffer?
I am trying to keep heap usage as low as possible and some messages could be large. I do not want to allocate say 10K for a rx_buffer when I am not going to receive anything other than 0x00 when the ESP is sending 10K of data to the controller.
Thanks in advance,
Mark
SPI Tx & Rx Buffer Sizes
Re: SPI Tx & Rx Buffer Sizes
A option would be to create two functions. One for when the rx_buffer is minimal and another when the rx_buffer is using the 10k
Code: Select all
void SPI_ReadMinimal(void)
{
uint8_t tx_data[10000];
transmitter.tx_buffer = tx_data;
transmitter.rx_buffer = NULL;
transmitter.length = ?;
}
void SPI_ReadMaximal(void)
{
uint8_t tx_data[10000];
uint8_t rx_data[10000];
transmitter.tx_buffer = tx_data;
transmitter.rx_buffer = rx_data;
transmitter.length = ?;
}
-
- Posts: 34
- Joined: Thu Dec 24, 2015 12:04 pm
Re: SPI Tx & Rx Buffer Sizes
Thank you for taking the time to respond. The essence of the question is not how to code this but what does the SDK expect.
So, if the ESP32 is only sending data to the SPI master does the SDK need the rx_buffer field to be pointing to a valid buffer?
Regards,
Mark
So, if the ESP32 is only sending data to the SPI master does the SDK need the rx_buffer field to be pointing to a valid buffer?
Regards,
Mark
Re: SPI Tx & Rx Buffer Sizes
The answer is in the coding example i gave. The answer is no.So, if the ESP32 is only sending data to the SPI master does the SDK need the rx_buffer field to be pointing to a valid buffer?
Who is online
Users browsing this forum: Bing [Bot], ok-home and 122 guests