/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) 
This function is always used in thread mode. */
unsigned long I2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) 
This function is always used in thread mode. */
unsigned long I2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
{
    unsigned long ulStatus;
    xASSERT((ulBase == I2C1_BASE) || (ulBase == I2C2_BASE));
    I2CMasterWriteRequestS2(ulBase, ucData, xfalse);
    do
    {
        ulStatus = I2CStatusGet(ulBase);
        if(xHWREG(ulBase + I2C_SR1) & 0x0F00)
            break;
    }
    while(!(ulStatus == I2C_EVENT_MASTER_BYTE_TRANSMITTED));
    if(bEndTransmition)
    {
        I2CStopSend(ulBase);
    }
    return (ulStatus & (I2C_SR1_ARLO | I2C_SR1_AF));
}