SPI Slave transmit function

Uint64_t
Posts: 7
Joined: Sat Feb 25, 2023 11:52 am

SPI Slave transmit function

Postby Uint64_t » Mon Feb 27, 2023 5:23 pm

I am in the function with the maximum delay waiting for the master to send me data in order to send him the data stored in sendbufer in response. But while I was waiting, I decided to change the data in sendbufer. The question is what data will go to the master new or previous.
Task1
t.length=128*8;
t.tx_buffer=sendbuf;
t.rx_buffer=recvbuf;
ret=spi_slave_transmit(RCV_HOST, &t, portMAX_DELAY);

Task2
sendbuf[0] = 0xA5;
...

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

Re: SPI Slave transmit function

Postby ESP_Sprite » Tue Feb 28, 2023 12:41 am

It's undefined, as in, we don't guarantee anything about the state the data is in. In practice, it may be that the first few words still are 'old' data as they're already hoovered up by the DMA subsystem and waiting in a FIFO somewhere, but whatever behaviour you see, better not depend on it as there's no guarantee it won't change in future HW/SW versions.

Uint64_t
Posts: 7
Joined: Sat Feb 25, 2023 11:52 am

Re: SPI Slave transmit function

Postby Uint64_t » Tue Feb 28, 2023 5:44 am

Do you have any ideas how you can implement such an algorithm over the SPI bus.since the master needs to have up-to-date latest data at the time of their receipt.

Who is online

Users browsing this forum: No registered users and 65 guests