/* Initialize I2C slave function. This function is to 7-bit slave addresses and enable General Call function of specified I2C port.  */
void I2CSlaveInit(unsigned long ulBase, unsigned long ulSlaveAddr, unsigned long ulGeneralCall)
/* Initialize I2C slave function. This function is to 7-bit slave addresses and enable General Call function of specified I2C port.  */
void I2CSlaveInit(unsigned long ulBase, unsigned long ulSlaveAddr, unsigned long ulGeneralCall)
{
    xASSERT(
            (ulBase == I2C0_BASE) ||
            (ulBase == I2C1_BASE) ||
            (ulBase == I2C2_BASE)
            );
    if(ulGeneralCall == I2C_GENERAL_CALL_EN)
    {
        ulSlaveAddr |= ADR_GC;
        xHWREG(ulBase + I2C_ADR0) = ulSlaveAddr;
    }
    else if(ulGeneralCall == I2C_GENERAL_CALL_DIS)
    {
        ulSlaveAddr &= ~ADR_GC;
        xHWREG(ulBase + I2C_ADR0) = ulSlaveAddr;
    }
    else
    {
        while(1);
    }
    xHWREG(ulBase + I2C_CONSET) = CONSET_AA;
    xHWREG(ulBase + I2C_CONCLR) = CONCLR_SIC | CONCLR_STAC | CONCLR_I2CENC;
}