What is the right way to use this? I thought it might be something like this:
char lsb;
read
{
i2c_read_char(*lsb);
}
I have tried some other stuff but think I am just confused on a couple different levels. All my other I2C.LIB functions are compiling, just not sure on how to address this one.
[i2c.lib description]
/* START FUNCTION DESCRIPTION ********************************************
i2c_read_char
SYNTAX: int i2c_read_char(char *ch);
DESCRIPTION: Reads 8 bits from slave.
Allows for clocks stretching on all SCL going high.
This is NOT in the protocol for I2C, but allows
I2C slaves to be implemented on slower devices.
PARAMETER1: char * ch - 1 character return buffer.
RETURN VALUE: 0 success, -1 clock stretching timeout
END DESCRIPTION **********************************************************/
nodebug int i2c_read_char(char *ch)
{
auto char res,cnt;
for ( cnt=0,res=0;cnt<8;cnt++ )
{
i2c_SDA_H();
cWAIT_5_us;
if (i2c_wSCL_H()) return -1; // too long clock stretching
res<<=1;
if (i2c_SDA()) res|=0x01;
i2c_SCL_L();
cWAIT_5_us;
}
*ch=res; return 0;
}
/*** BeginHeader i2c_check_ack /
int i2c_check_ack();
/** EndHeader */