Dear Alice,
I appreciate your reply. However, I have to disagree. I can not find any API functions to select a different slave for each transaction short of calling the init function again (as I mentioned before).
I'm using Peripherals Tool and selected "Universal Driver" for Flexcomm. This generates initialization code based on the CMSIS driver. The CMSIS driver is not using SPI_WriteData() but SPI_MasterTransferNonBlocking() and SPI_TransferHandleIRQInternal() in fsl_spi.c.
The latter includes this piece of code:
/* select slave to talk with */
tx_ctrl |= ((uint32_t)SPI_DEASSERT_ALL & (uint32_t)SPI_ASSERTNUM_SSEL(handle->sselNum));
/* set width of data */
tx_ctrl |= SPI_FIFOWR_LEN(handle->dataWidth);
That is, in each interrupt request, the slave is selected according to handle->sselNum.
A quick solution is to add an API call (to fsl_spi_cmsis.c) in order to change sselNum.
uint8_t SPI3_getSSEL() {
return SPI3_InterruptDriverState.handle->masterHandle.sselNum;
}
void SPI3_setSSEL(uint8_t slave) {
SPI3_InterruptDriverState.handle->masterHandle.sselNum = slave;
}
This sets sselNum of Flexcomm3. Should be called before a call to Transfer().
Further resource locking is recommended.
Best regards,
Daniel