1.35.21.38 USARTx_SPI_IsBusy Function

C

/* x = USART SPI instance number */

/* USART SPI master (non-blocking) mode */

bool USARTx_SPI_IsBusy (void):

Summary

Returns transfer status of SPI

Description

In master mode, this function returns true if the SPI module is busy with a transfer. The application can use the function to check if 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.

Precondition

The USART_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
// USARTx_SPI_IsBusy() function. This example shows a blocking while
// loop. The function can also be called periodically.

uint8_t dataBuffer[20];

USART1_SPI_Initialize();
USART1_SPI_Write(dataBuffer, 20);

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

Remarks

None