#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <i2c.h>

/************************************************************************
*    Function Name:  MasterWriteI2C2
*    Description:    This routine is used to write a byte to the I2C bus.
*                    The input parameter data_out is written to the 
*                    I2CTRN register. If IWCOL bit is set,write collision 
*                    has occured and -1 is returned, else 0 is returned.             
*    Parameters:     unsigned char : data_out                                   
*    Return Value:   char 
*************************************************************************/

#ifdef _I2C_V2_2


char MasterWriteI2C2(unsigned char data_out)
{
    I2C2TRN = data_out;

    if(I2C2STATbits.IWCOL)        /* If write collision occurs,return -1 */
        return -1;
    else
    {
        return 0;
    }
}




#else
#warning "Does not build on this target"
#endif
