Jump to main content

##

# 2.110.57 SERCOMx_SPI_ErrorGet Function

## C

    /* x = SERCOM instance number */

    /* SPI slave mode */

    SPI_SLAVE_ERROR SERCOMx_SPI_ErrorGet(void)

## Summary

Returns the error status of SPI transfer

## Description

This function returns the error status of the last SPI transfer. Applicaiton must check the status of a transfer in the application callback and take appropriate action in case there is an error during the data transfer. Calling this API clears the error status flags.

## Precondition

The SERCOMx_SPI_Initialize() should have been called

## Parameters

None.

## Returns

SPI_SLAVE_ERROR - SPI Slave Errors

## Example

    void SPIEventHandler(uintptr_t context )
    {
        if (SERCOM0_SPI_ErrorGet() == SPI_SLAVE_ERROR_NONE)
        {
            nBytesAvailable = SERCOM0_SPI_ReadCountGet();

            nBytesRead = SERCOM0_SPI_Read(APP_RxData, nBytesAvailable);
        }
        else
        {
            // Handle error
        }

    }

    SERCOM0_SPI_CallbackRegister(SPIEventHandler, (uintptr_t) 0);

## Remarks

None.