/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) 
This function is always used in thread mode. */
unsigned long xI2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) 
This function is always used in thread mode. */
unsigned long xI2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
{
    unsigned long ulStatus;
    xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) ||
            (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) ||
            (ulBase == I2C4_BASE));
    xASSERT(!(ucSlaveAddr & 0x80));
    xI2CMasterWriteRequestS1(ulBase, ucSlaveAddr, ucData, xfalse);
    while (!(xHWREG(ulBase + I2C_CON) & I2C_CON_SI));
    ulStatus = xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M;
    if(!(ulStatus == I2C_I2STAT_M_TX_DAT_ACK))
    {
        ulStatus = xI2CMasterError(ulBase);
        I2CStopSend(ulBase);
        return ulStatus;
    }
    if(bEndTransmition)
    {
        I2CStopSend(ulBase);
    }
    return xI2C_MASTER_ERR_NONE;
}