This question is a refresh of a past unanswered question by another developer.
If the SPI is initialized and deinitialized using SPIInit() and SPIdeinit() and then initialized again (for example to switch from master to slave modes), any subsequent calls to SPIReadWritePolling freeze.
No exceptions called. Just frozen.
spiError = SPIInit(txSSPport, Constant.dataBits, Constant.SPI_CLOCK_18_MHZ, false, 1, null);
/* some SPI comms here without problems */
spiError = SPIInit(txSSPport, Constant.dataBits, Constant.SPI_CLOCK_18_MHZ, true, 1, null);
SPIreturn = SPIReadWritePolling(4, read_buffer, write_buffer, 1, 10); // Freezes here!!!
Frozen at SPIReadWritePolling.
I have declared the SPI API functions as:
[DllImport(“SPILib_Dll.dll”, CharSet = CharSet.Auto)]
public static extern bool SPIInit(…
Any ideas on how to circumvent this? We need to switch from master to slave SPI.