I've been playing some time with I2C bus on the arduino, without a lot of luck so far.
I just found the I2C library from "fat16lib", found at (can't post)
Everything was working in the minut.
I'm so asking a really simple question.
What is the "Wire" library equivalent to this short source code, to read the register on an i2C componant (an AMIS-30624 stepper driver) :
// read the GetfullStatus1
if (rtc.start(add | I2C_WRITE)) { // send a START on the i2c bus, for slave address "add" which is 0xC0
rtc.write(0x81); // ask for the register at address 0x81 in the ship buffer
}
if (rtc.restart(add | I2C_READ)) { // reconnect to the i2c bus and read from the slave
Serial.print("full Add read: ");
Serial.println(add, BIN);
for (int i=0 ; i<8 ; i++) { // the resgister is 8 bytes long, scroll through it
readbuf=0;
// read the 8 byte buffer
readbuf=rtc.read((i == 7)); // use read(0) to scroll through the buffer. Send rend(1) when last buffer read
Serial.print(i);
Serial.print(" -- ");
Serial.println(readbuf, BIN);
}
}
rtc.stop();
This is the result on the console :
full Add read: 11000000
0 -- 11100000
1 -- 0
2 -- 0
3 -- 0
4 -- 100000
5 -- 10000
6 -- 11111111
7 -- 0
With the wire, I tried without success something like :
Wire.beginTransmission(0xC0); // transmit to device address 0xC0
Wire.send(0x81); // ask for buffer 0x81
Wire.endTransmission(); // stop transmitting
for (int i=0 ; i<8 ; i++) {
Wire.requestFrom(0xC1, 1); // request 1 bytes from slave
c = Wire.receive(); // receive a byte as character
Serial.print ("read ");
Serial.print (0xC1,BIN);
Serial.print (" = ");
Serial.println(c,BIN); // print the character
}
I must be missing something...
Whatever, the library from "fat16lib" is working fine, and you can choose between hardware i2c or software i2c on the arduino, which may be usefull for some of you.
Thanks for your forthcoming help.
Prune