does spi write suspend processing?

10 Dec 2010

If I execute the following (from the SPI example):

int response = device.write(0xFF);

will processing be suspended until the shift out and in is completed? If so is there another way to use SPI that will allow processing to continue and provide an interrupt or status bit when the shift is completed?

I would like to use the SPI to do 16 bit transfers at 100khz but I can't stop doing other things for 160 us while they occur.

10 Dec 2010

Hi Daniel,

Yes, the spi write() method sends the value you pass, and returns the value shifted in, so the transaction has to complete before it returns. The method is interruptible, but it will not return until the data is available.

If you want to write to the SPI device and ignore the responses, or deal with them asynchronously, one option would be to write the data straight out e.g.

LPC_SSP0->DR = 0xFF; // SSP0 (p11, p12, p13) or SSP1 (p5, p6, p7)

The main aim with the API was to keep it simple and atomic (rather than people getting strange results due to stale data in FIFOs etc).

Simon