This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How does SPI_transfer work ?

In my case,

TM4C is SPI master and it writes a request to a SPI slave peripheral in some format,

say

<STX><MD><A5><FF><ETX>

The SPI slave peripheral will respond only after it receives the whole format <STX>...<ETX> .

The data size is set to 8 bits.

The response size is of 10 bytes.

How do I use SPI_Transfer is this case ?

The following does not seem to work fine:-

uint8_t txBuffer[5];
uint8_t rxBuffer[10];

SPI_Transaction spiTransaction;

bool retValue;

/* Initialize slave SPI transaction structure */
spiTransaction.txBuf = (Ptr)txBuffer;
spiTransaction.rxBuf = (Ptr)rxBuffer;

/* Command */
txBuffer[0] = STX;
txBuffer[1] = MD;
txBuffer[2] = A5;
txBuffer[3] = FF;
txBuffer[4] = ETX;

/* send command */
spiTransaction.count = 5;
GPIO_write(SPI_SS, GPIO_WR_LOW);

retValue = SPI_transfer(Spi, &spiTransaction);

GPIO_write(SPI_SS, GPIO_WR_HIGH);

/* read Response */
spiTransaction.count = 10;
/* Command */
txBuffer[0] = 0;
txBuffer[1] = 0;
txBuffer[2] = 0;
txBuffer[3] = 0;
txBuffer[4] = 0;

GPIO_write(SPI_SS, GPIO_WR_LOW);

retValue = SPI_transfer(Spi, &spiTransaction);

GPIO_write(SPI_SS, GPIO_WR_HIGH);

BUT, we are not receiving anything from the SPI slave peripheral.