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
Syncronous/Asyncronous SPI??
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Syncronous/Asyncronous SPI??
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
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??
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
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
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Syncronous/Asyncronous SPI??
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
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