1.22.25.15 SPI_SLAVE_CALLBACK Typedef

C

/* SPI slave mode */

typedef void (*SPI_SLAVE_CALLBACK) (uintptr_t context )

Summary

Pointer to a SPI Call back function when SPI is configued in slave mode.

Description

This data type defines the required function signature for the SPI slave event handling callback function. Application must register a pointer to an event handling function whose function signature (parameter and return value types) match the types specified by this function pointer in order to receive event calls back from the PLIB. The parameters and return values are described here and a partial example implementation is provided.

Parameters

Param Description
context Allows the caller to provide a context value (usually a pointer to the callers context)

Returns

None.

Example

void APP_SPICallBack(uintptr_t contextHandle)
{
    if( SPI1_ErrorGet() == SPI_SLAVE_ERROR_NONE )
    {
        //Exchange was completed without error
    }
}

SPI1_CallbackRegister(&APP_SPICallBack, NULL);

Remarks

The context parameter contains a handle to the client context, provided at the time the event handling function was registered using the SPIx_CallbackRegister function. This context handle value is passed back to the client as the "context" parameter. It can be any value (such as a pointer to the client's data) necessary to identify the client context or instance of the client that made the data exchange request. The event handler function executes in the PLIB's interrupt context. It is recommended of the application to not perform process intensive or blocking operations within this function.