1.2.21.45 1.3.25.45 1.4.21.45 1.5.25.45 1.6.22.45 1.7.23.45 1.9.19.45 1.29.23.45 1.30.18.45 1.31.18.45 1.32.26.45 1.33.16.45 1.37.18.45 1.38.21.45 1.39.18.45 1.40.20.45 SERCOMx_SPI_IsBusy Function

C

/* x = SERCOM instance number */

/* SPI master (non-blocking mode) and slave mode */

bool SERCOMx_SPI_IsBusy (void):		

Summary

Returns the busy status of SPI PLIB

Description

SPI master mode

In master mode, this function returns true if the SERCOM SPI module is busy with a transfer. The application can use the function to check if SERCOM SPI module is busy before calling any of the data transfer functions. The library does not allow a data transfer operation if another transfer operation is already in progress. This function can be used as an alternative to the callback function when the library is operating in interrupt mode thereby allowing the application to implement a synchronous interface to the library.

SPI slave mode

In slave mode, this function returns true if SPI slave is busy with a data transfer. The status is returned true when the SPI chip select is driven to active state by SPI master. The status is returned as false when the SPI chip select is driven inactive.

Precondition

The SERCOMx_SPI_Initialize() should have been called once. The module should have been configured for interrupt mode operation in MHC.

Parameters

None.

Returns

Param Description
true Transfer is currently in progress (in master mode) or chip select is in active state when SPI is (in slave mode)
false Transfer is completed (in master mode) or chip select is in inactive state (in slave mode)

Example

SPI master (non-blocking mode) mode

// The following code example demonstrates the use of the
// SERCOMx_SPI_IsBusy() function. This example shows a blocking while
// loop. The function can also be called periodically.

uint8_t dataBuffer[20];

SERCOM0_SPI_Initialize();
SERCOM0_SPI_Write(dataBuffer, 20);

while (SERCOM0_SPI_IsBusy() == true)
{
    // Wait here till the transfer is done.
}

SPI slave mode

while (SERCOM0_SPI_IsBusy() == true)
{
    // Wait here till the chip select is asserted by the SPI master
}

Remarks

None