Page 1 of 1

Syncronous/Asyncronous SPI??

Posted: Tue Aug 07, 2012 8:39 pm
by formica
Dear all,
I'm a little bit confused about the SPI API. Reading the documentation there are some function used for a syncronous communication and others for asyncronous one.
I know that that the SPI protocol has a dedicate clock line so it is intrinsically syncronous.
So, what does it means ASYNCRONOUS in this case?

I'm trying to establish a monodirectional communication between two microcontrollers (STM32F103RBT6) using spi. This is my idea: the first one (master) generates the clock while the second one (the slave) use this clock to read the data. The two MOSI pins should be connected together (the clock pins as well).
Is it correct?
Which api functions should I use in this case in both micro?

Thanks in advance
Roberto

Re: Syncronous/Asyncronous SPI??

Posted: Tue Aug 07, 2012 8:46 pm
by Giovanni
Hi Roberto,

Synchronous/asynchronous is about the behavior of the SPI functions and does not affect the way the data is transferred, for example:

spiStartSend() - Asynchronous function, it starts a transmission and returns immediately, the transfer continues in background, a (optional) callback is invoked when the transfer is finished.

spiSend() - Synchronous function, it starts a transmission and returns when the operation has been completed, it waits inside.

Read that as blocking/non-blocking.

About the SPI driver, it is master-only, you need custom code on the slave side.

Giovanni

Re: Syncronous/Asyncronous SPI??

Posted: Mon Nov 02, 2015 3:27 pm
by Raul
Hi all,

If a thread calls spiSend(), presumably the wait for completion would make it transition into a sleeping state while the DMA transfer takes place, and if then it were another thread in a ready state will this one start executing?

If so, what would it happen when the DMA transfer is completed and the second thread is still executing, the SPI caller will be resumed once the second thread sleeps/stops?

Raul

Re: Syncronous/Asyncronous SPI??

Posted: Mon Nov 02, 2015 3:44 pm
by Giovanni
Hi,

This is correct, in general drivers never do "busy waiting" and behave nicely with other threads. The exception is when you see a function with "Polled" inside, those are meant to do polling, for example gptPolledDelay().

Giovanni