To be honest mate...if you insist on using your own compiler, then you are going to run into problems as I said earlier.
I don't know how long the Mods or Admin will allow the discussion of porting code to another system....
Having said that...I would look up how YOUR compiler works with the I2C bus and concentrate on that. The Wire library is a wrapper for I2C and as such will just confuse you if you don't know the I2C protocol.
Here is some of my code for the CCS C compiler...I hope I don't get banned or repremanded for posting it here.
It may help because it looks like it is closer to your compiler....
/*****************************************************************************/
/* COMMUNICATIONS FUNCTIONS */
/*****************************************************************************/
/***** Function to write configuration settings to I2C bus *******************/
void AS1130_config(char AS_addr, char ram_reg, char command, char data)
{
i2c_start();
i2c_write(AS_addr);
i2c_write(REGISTERSELECTION);
i2c_write(ram_reg);
i2c_stop();
i2c_start();
i2c_write(AS_addr);
i2c_write(command);
i2c_write(data);
i2c_stop();
}
/*****************************************************************************/
/* EXT EEPROM COMMUNICATIONS FUNCTIONS */
/*****************************************************************************/
/***** Function to write data to external EEPROM *****************************/
//Standard I2C Protocol (see datasheet)
void write_ext_EEPROM(long int address, BYTE data)
{
short int status;
i2c_start();
i2c_write(EEPROM_WRITE_ADDR);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(EEPROM_WRITE_ADDR);
while(status==1)
{
i2c_start();
status=i2c_write(EEPROM_WRITE_ADDR);
// delay_cycles(200);
}
i2c_stop();
}
/***** Function to read data from external EEPROM ****************************/
//Standard I2C Protocol (see datasheet)
BYTE read_ext_EEPROM(long int address)
{
BYTE data;
i2c_start();
i2c_write(EEPROM_WRITE_ADDR);
i2c_write(address>>8);
i2c_write(address);
i2c_start();
i2c_write(EEPROM_READ_ADDR);
data=i2c_read(0);
i2c_stop();
return(data);
}
Seriously, you need to understand the I2C protocol fully before Wire or bit banged (or anything in between) I2C will make any sense.
Here is a link to the EEprom's datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21754M.pdf
Sections 4, 5 and 6 are pretty revealing as is the I2C description in the AS1130 datasheet.