/********************************************************************
*  HEADER MODULE:           i2c_if.h
*
*  Serial Data Interface Module Headers
*
*********************************************************************
*
*  DESCRIPTION:
*
*  Prototypes for I2C Serial Interface for the C8051F120 and other Silabs chips
*
*
*  INCLUDE FILES
*/

/*
* NOTES:
*
*
*  REVISION LOG:
*
*  Date     Name             Version  Reason
*  -------  ---------------- -------  -------------------------------
*  08-31-05 E.Burzic/D.Juges 0.0.1    Initial design
*********************************************************************/

#define READ    		1
#define WRITE   		0

/*---------------------------------------------------------------------*
*	FUNCTION PROTOTYPES
*---------------------------------------------------------------------*/

/* ----- I2C functions ----- */

/* FUNCTION: I2C_Init()
* Initialise SMB transceiver (turn off interrupts and set clock)
*/
void I2C_Init( void );

/* I2CSendAddr() sends a slave address over the I2C bus
*	which selects the specified device
*	rd is TRUE for read, and FALSE for write
*	The function sets _i2c_error TRUE if there was an error while accessing
*	the device.
*/
void I2CSendAddr( unsigned char addr, unsigned char rd );

/* I2CSendByte() sends a byte over the I2C bus to the currently
*	selected device
*	The function sets _i2c_error TRUE if there was an error while accessing
*	the device.
*/
void I2CSendByte( unsigned char bt );

/* I2CSendStop() asserts the stop condition over the I2C bus.
*	This function cannot fail.
*/
void I2CSendStop( void );

/* FUNCTION: I2CGetByte()
* get a byte and acknowledge
*/
unsigned char I2CGetByte( void );


/* FUNCTION: I2CGetLastByte()
* Get a byte and do not acknowledge to force slave to stop sending data
*/
unsigned char I2CGetLastByte( void );

/* FUNCTION: I2CCheckError()
*	Returns 0 if no error during previous I2C function, a non-zero
*	error code otherwise.
*/
unsigned char I2CCheckError( void );

