/*
**     $Author: Bipsen $
**     $Filename: i2c_library.h $
**     $Release: 1.00 $
**     $Revision: 37.2 $
**     $Date: 1993/12/20 12:54:48 $
**
**     Headerfile to include in programs using i2c.library
** 
*/

#include <exec/libraries.h>
#include <exec/types.h>

extern 	struct Library *I2C_Base;

/*--- functions in v37.0 or higher ---*/
#pragma libcall I2C_Base AllocI2C 1E 9002
#pragma libcall I2C_Base FreeI2C 24 0
#pragma libcall I2C_Base SetDelay 2A 001
#pragma libcall I2C_Base InitI2C 30 0
#pragma libcall I2C_Base SendI2C 36 91003
#pragma libcall I2C_Base ReceiveI2C 3C 91003
/*--- functions in v38.0 or higher ---*/
#pragma libcall I2C_Base GetI2COpponent 42 0

/* Proto-types for functions */

BYTE AllocI2C(UBYTE Delay_Type,char *Name);
void FreeI2C(void);
void SetDelay(ULONG ticks);
void InitI2C(void);
UBYTE SendI2C(UBYTE addr, int number, UBYTE i2cdata[]);
UBYTE ReceiveI2C(UBYTE addr, int number, UBYTE i2cdata[]);
STRPTR GetI2COpponent(void);

/* Definitions for return-codes etc. */

/* Type of delay to pass as 1st parameter in AllocI2C */
#define DELAY_TIMER 1	/* Use timer.device for SCL-delay  */
#define DELAY_LOOP  2	/* Use for/next-loop for SCL-delay */

/* When using timer.device for delay, please notice, that the parameter */
/* for SetDelay() will be in UNIT_MICROHZ. A value of 10 will probably  */
/* give a clock-rate below 100 KHz as specified by the I2C-bus standard */


/* Error-codes returned by AllocI2C */
enum {I2C_OK=0, I2C_PORT_BUSY, I2C_BITS_BUSY, I2C_NO_MISC_RESOURCE,
      I2C_ERROR_PORT, I2C_ACTIVE, I2C_NO_TIMER };

/* I2C_OK                Operation was OK                    */
/* I2C_PORT_BUSY         Could not allocate parallel-port    */
/* I2C_BITS_BUSY         Could not allocate the needed bits  */
/* I2C_NO_MISC_RESOURCE  Could not get misc.resource         */
/* I2C_ERROR_PORT        Could not open messageport          */
/* I2C_ACTIVE            I2C-bus already active              */
/* I2C_NO_TIMER          Cannot get timer                    */

