I have been using http://playground.arduino.cc/Main/SoftwareI2CLibrary till now.
Now another library I am using, (display related) is hardcoded to using Wire.
The old code can be summed up like:
#define SDA_PORT PORTC
#define SDA_PIN 3
#define SCL_PORT PORTC
#define SCL_PIN 4
#define I2C_SLOWMODE 1
#include <SoftI2CMaster.h>
byte deviceAddress = 11;
#define CYCLE //feature to read
void setup()
{
i2c_init();
}
void loop() {
//read a word
i2c_start(deviceAddress << 1 | I2C_WRITE);
i2c_write(CYCLE);
i2c_rep_start(deviceAddress << 1 | I2C_READ);
byte b1 = i2c_read(false);
byte b2 = i2c_read(true);
i2c_stop();
}
it just works
now I tried to convert that to use Wire library:
#include <Wire.h>
byte deviceAddress = 11;
#define CYCLE //feature to read
void setup()
{
Wire.begin();
}
void loop() {
//read a word
Wire.beginTransmission(deviceAddress);
Wire.write(CYCLE);
Wire.endTransmission();
Wire.requestFrom(deviceAddress,2);
byte b1=0;
byte b2=0;
while(Wire.available()) {
b1 = Wire.read();
b2 = Wire.read();
}
needless to say, it does not work - what am I doing wrong ?