/* 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 I2CMasterWriteS1(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 I2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
{
    unsigned long ulStatus;
    xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE));
    xASSERT(!(ucSlaveAddr & 0x80));
    I2CMasterWriteRequestS1(ulBase, ucSlaveAddr, ucData, xfalse);
    do
    {
        ulStatus = I2CStatusGet(ulBase);  
        if(xHWREG(ulBase + I2C_CSR) & 0x0F00)
            break;
    }
    while(!(ulStatus == I2C_MASTER_TX_EMPTY));
    if(bEndTransmition)
    {
        I2CStopSend(ulBase);
    }
    return (ulStatus & (I2C_CSR_ARBLOS | I2C_CSR_RXNACK));
}