/* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations.  */
unsigned long xI2CMasterError(unsigned long ulBase)
/* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations.  */
unsigned long xI2CMasterError(unsigned long ulBase)
{
    unsigned long ulStatus;
    xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE));
    ulStatus = (xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M);
    if((ulStatus == I2C_I2STAT_M_TX_DAT_NACK) ||
       (ulStatus == I2C_I2STAT_M_RX_DAT_NACK))
    {
        return xI2C_MASTER_ERR_ADDR_ACK;
    }
    if((ulStatus == I2C_I2STAT_M_TX_SLAW_NACK) ||
       (ulStatus == I2C_I2STAT_M_RX_SLAR_NACK))
    {
        return xI2C_MASTER_ERR_DATA_ACK;
    }
    if((ulStatus == I2C_I2STAT_M_TX_ARB_LOST))
    {
        return xI2C_MASTER_ERR_ARB_LOST;
    }
    return xI2C_MASTER_ERR_NONE;
}