1.2.21.71 1.3.25.71 1.4.21.71 1.5.25.71 1.6.22.71 1.7.23.71 1.9.19.71 1.29.23.71 1.30.18.71 1.31.18.71 1.32.26.71 1.33.16.71 1.37.18.71 1.38.21.71 1.39.18.71 1.40.20.71 SERCOMx_I2C_ErrorGet Function

C

/* x = SERCOM instance number */

/* I2C master mode */

SERCOM_I2C_ERROR SERCOMx_I2C_ErrorGet(void)			

/* I2C slave mode */
SERCOM_I2C_SLAVE_ERROR SERCOMx_I2C_ErrorGet(void)	

Summary

Returns the I2C error that occurred on the bus.

Description

This function returns the I2C error that occurred on the bus. The function can be called to identify the error cause.

Precondition

SERCOMx_I2C_Initialize must have been called for the associated SERCOM I2C instance.

Parameters

None.

Returns

Returns error of type SERCOM_I2C_ERROR (when I2C is in master mode) or SERCOM_I2C_SLAVE_ERROR (when I2C is in slave mode), identifying the error that has occurred.

Example

I2C in master mode:

if(SERCOM0_I2C_ErrorGet() == SERCOM_I2C_ERROR_NONE)
{
    //Transfer is completed successfully
}
else
{
    //Error occurred during transfer.
}

I2C in slave mode:

SERCOM_I2C_SLAVE_ERROR i2c_error;

i2c_error = SERCOM0_I2C_ErrorGet();

if(i2c_error)
{
    //Error occurred during transfer.
    if (i2c_error & SERCOM_I2C_SLAVE_ERROR_BUSERR)
    {
        // I2C Bus error has occured
    }
    if (i2c_error & SERCOM_I2C_SLAVE_ERROR_COLL)
    {
        // I2C bus collision error has occured
    }
    // Handle other error bits here ...
}
else
{
    //Transfer is completed successfully
}

Remarks

The return type of the API is SERCOM_I2C_ERROR when I2C is configured in master mode.

The return type of the API is SERCOM_I2C_SLAVE_ERROR when I2C is configured in slave mode