PreviousNext
stopSPI
Help > OS functions > SPI > stopSPI

Function

 

Stop SPI communication

Purpose

 

Suspend SPI transmissions whenever it suits to Slave

Syntax

 

void stopSPI()

Parameters

 

  –

Return value

 

  –

Output values

 

SPI Status is switched to User stop.

Preconditions

 

  –

Remarks

 

     stopSPI is useful e.g. to avoid violation during the preparation of data to bufferCOM.

     SPI transmission is stopped but SPI remains active (enabled). Communication can continue after the next startSPI.

     stopSPI is not needed after successful SPI reception to protect data received in bufferCOM. Data is protected by OS (and SPI status stays in mode 3F) until the slave allows further communication e.g. by the startSPI(0).

     startSPI and stopSPI are not fully complementary. Receiving is allowed just after enableSPI without previous startSPI, startSPI is meaningful after previous startSPI not followed by stopSPI etc.

     See IQRF SPI Technical guide and Example E07-SPI.

Side effects

 

The current packet is lost by both sides if SPI communication is running on background at this moment.

See also

 

enableSPI, disableSPI, startSPI, getStatusSPI, restartSPI

Example

 

if (!getStatusSPI())      // If SPI is not in progress

{

  stopSPI();               // Prohibit Master from transmitting

                           //   (not to destroy bufferCOM in background)

  bufferCOM[0] = ...      // Prepare data to send 

  bufferCOM[1] = ...

  startSPI(2);             // Request to send

}