I have issues using this lib with multi-master configuration:
The example code provided below(if replace with Wire lib, the code does work on Arduino uno/mega)
Master1:
#include <i2c_t3.h>
//#include <Wire.h>
#define I2C_ADDRESS_OTHER 0x2
#define I2C_ADDRESS_ME 0x1
void setup() {
Serial.begin(9600);
Wire.begin(I2C_MASTER, I2C_ADDRESS_ME, I2C_PINS_18_19, I2C_PULLUP_EXT, 100000);
// Wire.begin(I2C_ADDRESS_ME);
Wire.onReceive(receiveI2C);
}
void loop() {
delay(5000);
Wire.beginTransmission(I2C_ADDRESS_OTHER);
Wire.write("hello world from 0x1 to 0x2");
Wire.endTransmission();
Serial.println("Send to master2");
}
void receiveI2C(size_t howMany) {
while (Wire.available() > 0) {
char c = Wire.read();
Serial.print(c);
}
Serial.println();
}
Master 2:
#include <i2c_t3.h>
//#include <Wire.h>
#define I2C_ADDRESS_OTHER 0x1
#define I2C_ADDRESS_ME 0x2
void receiveI2C(size_t count);
void setup() {
Serial.begin(9600);
// Wire.begin(I2C_ADDRESS_ME);
Wire.begin(I2C_MASTER, I2C_ADDRESS_ME, I2C_PINS_18_19, I2C_PULLUP_EXT, 100000);
Wire.onReceive(receiveI2C);
}
void loop() {
delay(5000);
Wire.beginTransmission(I2C_ADDRESS_OTHER);
Wire.write("hello world from 0x2 to 0x1");
Wire.endTransmission();
Serial.println("Send to master1");
}
void receiveI2C(size_t count) {
while (Wire.available() > 0) {
char c = Wire.read();
Serial.print(c);
}
Serial.println();
}
I2C bass spesifications tells me that it should be working hardware wise.
https://www.nxp.com/docs/en/user-guide/UM10204.pdf
I have issues using this lib with multi-master configuration:
The example code provided below(if replace with Wire lib, the code does work on Arduino uno/mega)
Master1:
Master 2:
I2C bass spesifications tells me that it should be working hardware wise.
https://www.nxp.com/docs/en/user-guide/UM10204.pdf