I'm still not having much luck with this. I've found some other code examples but I still can't seem to get anything useful out of it. Here is what I have along with the I2C functions for the programming language:
//Slave hex address is 0x5A
//Temperature address is 0x07
func main()
var true,temp,a;
var buffer[100];
print("Testing I2C component\n");
pause(1000);
I2C_Open(I2C_FAST);//1mhz
print("I2C Open\n");
I2C_Idle();
I2C_Start();
print("Started\n");
I2C_Write(0x07);
print("Write Complete\n");
I2C_Idle();
true:= I2C_Write(0x00);
print(true,"\n"); //Returns a 1
temp:= I2C_Read();
print(temp,"\n"); //Returns a 0
print(readbyte(0x5a),"\n"); //Returns a 0
pause(10000);
endfunc
func readbyte(var address)
var r;
I2C_Idle(); //Wait for bus Idle
I2C_Start(); //Generate Start condition
I2C_Write(0x01); //send control byte for write
I2C_Idle(); //Wait for bus Idle
I2C_Write(HIbyte(address)); //Send High Address
I2C_Idle(); //Wait for bus Idle
I2C_Write(LObyte(address)); //Send Low Address
I2C_Idle(); //Wait for bus Idle
I2C_Restart(); //Generate Restart
I2C_Write(0x00); //send control byte for Read
I2C_Idle(); //Wait for bus Idle
r := I2C_Read(); //Read Length number of bytes to Data
I2C_Nack(); //send Not Ack
I2C_Stop(); //Send Stop Condition
return r;
endfunc
//------------------------------//
// I2C Functions //
//------------------------------//
/*
I2C_Open("speed"); // Configure the I2C module, speed can be I2C_SLOW, I2C_MED, I2C_FAST (100khz, 400khz, 1mhz)
I2C_Close(); // Disable the I2C1 module.
I2C_Start(); // Generate a Start condition.
I2C_Stop(); // Generate a Stop condition.
I2C_Restart(); // Generate a Restart condition.
I2C_Read(); // Read a single byte from the I2C Bus.
I2C_Write("byte"); // Write a byte to the I2C bus, Returns TRUE if ok
I2C_Ack(); // Generate the acknowledge condition.
I2C_Nack(); // Generate the negative acknowledge condition.
I2C_DataRdy(); // Return TRUE if the I2C receive buffer is full.
I2C_Idle(); // Wait until the I2C Bus is Inactive.
I2C_Gets("buffer", "length"); // Read length bytes from the I2C device to a buffer
I2C_Puts("buffer"); // Write an asciiz string to the I2C device