I2C support for Arduino based on Wire library.
But, when I try to work with a DS1307 RTC chip, I found that repeated start mode not covered by original Wire library:
Wire library can't send second START condition without STOPping the I2C bus. Some chips, like DS1307, reset internal address register after that.
So, what can we do?
1. Forget about Wire library and use another - one for example, from Peter Fleury.
2. Upgrade Wire library with new functionality (my way).
OK, new Wire function prototype is:
uint8_t TwoWire::transmitAndRequest(uint8_t quantity)
And it must be used instead of endTransmission():
This code provides transmission buffer sending, than running receiving after REPEATED START. Function returns read bytes count. The highest bit (0x80) is a error flag, so if we got a value > 127, it is an error code, same as for endTransmission() (without this bit, of course).
Download modified Wire library: Wire.zip (tested with Arduino IDE 0014).