Help to adapt i2c code from i2c_t3.h to Wire.h

M4ngu

Well-known member
Hi there, I'm trying to adapt the 16n firmware for Teensy 4
As the original code is made for Teensy 3.2 & LC, I have to adapt the i2c part for the Wire library, but no idea how to set to master/slave and the i2c pullup. Any idea about how to?

original code:
Code:
if(i2cMaster){
  Wire.begin(I2C_MASTER, I2C_ADDRESS, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
  Wire.setDefaultTimeout(10000); // 10ms
} else {
  Wire.begin(I2C_SLAVE, I2C_ADDRESS, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
  Wire.onReceive(i2cWrite);
  Wire.onRequest(i2cReadRequest);
}

So I have this to setup the i2c for the Wire.h library
Code:
if(i2cMaster){
  Wire.setSDA(18);
  Wire.setSCL(19);
  Wire.setTimeout(10000); // 10ms
  Wire.setClock(400000);
  Wire.begin(I2C_ADDRESS);
} else {
  Wire.setSDA(18);
  Wire.setSCL(19);
  Wire.setTimeout(10000); // 10ms
  Wire.setClock(400000);
  Wire.begin(I2C_ADDRESS);
  Wire.onReceive(i2cWrite);
  Wire.onRequest(i2cReadRequest);
}
Also, is there something I'm doing wrong here?
thanks in advance
 
Back
Top