Tool/software: TI-RTOS
Hi,
I am implementing a SPI slave receiver. The RTOS driver manages a SPI transaction consisting of a fixed number of data-frames.
In my situation I am receiving an unknown number of frames arriving at unknown times.
I am wondering if it is OK to set the transaction.count to 1 and loop. I have modified the spiloopback example to show what I mean.....
/* Initialize SPI handle with slave mode */
SPI_Params_init(&slaveSpiParams);
slaveSpiParams.mode = SPI_SLAVE;
slaveSpi = SPI_open(Board_SPI1, &slaveSpiParams);
if (slaveSpi == NULL) {
System_abort("Error initializing SPI\n");
}
else {
System_printf("SPI initialized\n");
}
/* Initialize slave SPI transaction structure */
slaveTransaction.count = 1;
slaveTransaction.txBuf = NULL;
slaveTransaction.rxBuf = (Ptr)slaveRxBuffer;
while(1) {
/* Initiate SPI transfer */
transferOK = SPI_transfer(slaveSpi, &slaveTransaction);
myRxBuffer[inPtr++] = slaveRxBuffer[0];
if(transferOK) {
/* Print contents of slave receive buffer */
System_printf("Slave: %s\n", slaveRxBuffer);
}
else {
System_printf("Unsuccessful slave SPI transfer");
}
}
Will this be OK or is there a better way of approaching it?
Thanks,
Richard