This is my first post ever, so sorry if this isn't formatted correctly. I downloaded i2c_t3 from github and was trying to use it with my Teensy 3.6. I want to set up an I2C interface that has two slaves on the bus. When I compile it says that the declaration of Wire in i2c_t3 interferes with a declaration made in WireKinetis. This is the error that it's outputting:
Compiling 'TeensyMotorControl' for 'Teensy 3.6'
WireKinetis.cpp.o*: In function i2c0_isr
WireKinetis.cpp:805: multiple definition of i2c0_isr
Error linking for board Teensy 3.6
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3\i2c_t3.cpp:1317: first defined here
Build failed for project 'TeensyMotorControl'
ld.exe: Disabling relaxation: it will not work with multiple definitions
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of i2c1_isr
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of i2c2_isr
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire2
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire2 changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire1
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire1 changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
collect2.exe*: error: ld returned 1 exit status
This is the code that I'm running with (the file name is I2C.cpp, which is the I2C.h):
//
//
//
#include "I2C.h"
#include<i2c_t3.h>
const int ClockSpeed = 400000; //Max Clock Frequency is 400kHz
const int Timeout = 200000; //200ms Timeout
// Temperature Variable
const int TemperatureAddress = 0x48;
const int TemperatureLength = 2; //Temperature Data is 2 Bytes
char TemperatureBuffer[TemperatureLength];
const int TemperaturePointer = 0x00; //To Read Temperature
//Pressure Variables
const int PressureAddress = 0x77;
const int PressureLength = 3; //Pressure Data is 3 Bytes Long
char PressureBuffer[PressureLength];
const int ResetPressure = 0x1E;
const int InitPressureSequence = 0x48;
const int ReadPressure = 0x00;
void Init_I2C() { //Initialize I2C
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_3_4, I2C_PULLUP_EXT, ClockSpeed); //Set for Master Mode, Pins 3 & 4 400kHz Clock
Wire.setDefaultTimeout(200000); // 200ms Timeout
Wire.setOpMode(I2C_OP_MODE_ISR); //Set it to be an interrupt based operation
SetTemperaturePointer();
ResetPressureSensor();//This is done here in order to check if we can talk to the sensor
}
void SetTemperaturePointer() { //Set Pointer to temperature for temperature sensor. Only needs to be done on reset.
Wire.beginTransmission(TemperatureAddress); // Write to the Teperature Sensor
Wire.write(TemperaturePointer); // Write Pointer to the Temperature Sensor
Wire.endTransmission(); // End Transmission
if (Wire.getError()) {
Serial.println("Temperature Sensor Failed to Initialize");
}
else {
Serial.println("Temperature Sensor Successfully Initiliazed");
}
}
void ResetPressureSensor() {
Wire.beginTransmission(PressureAddress); //Write to Pressure Sensor
Wire.write(ResetPressure); //Reset It
Wire.endTransmission(); //End
if (Wire.getError()) { //Was there an error?
Serial.println("Pressure Sensor Failed to Initialize");
}
else {
Serial.println("Pressure Sensor Successfully Initiliazed");
}
}
Compiling 'TeensyMotorControl' for 'Teensy 3.6'
WireKinetis.cpp.o*: In function i2c0_isr
WireKinetis.cpp:805: multiple definition of i2c0_isr
Error linking for board Teensy 3.6
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\i2c_t3\i2c_t3.cpp:1317: first defined here
Build failed for project 'TeensyMotorControl'
ld.exe: Disabling relaxation: it will not work with multiple definitions
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of i2c1_isr
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of i2c2_isr
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire2
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire2 changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire1
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire1 changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
WireKinetis.cpp.o*: In function Print::availableForWrite()
WireKinetis.h:132: multiple definition of Wire
i2c_t3.cpp.o*: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\Print.h:61: first defined here
ld.exe: Warning: size of symbol Wire changed from 20 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\i2c_t3\i2c_t3.cpp.o to 108 in C:\Users\Brandons pc\AppData\Local\Temp\VMBuilds\TeensyMotorControl\teensy36\Debug\Wire\WireKinetis.cpp.o
collect2.exe*: error: ld returned 1 exit status
This is the code that I'm running with (the file name is I2C.cpp, which is the I2C.h):
//
//
//
#include "I2C.h"
#include<i2c_t3.h>
const int ClockSpeed = 400000; //Max Clock Frequency is 400kHz
const int Timeout = 200000; //200ms Timeout
// Temperature Variable
const int TemperatureAddress = 0x48;
const int TemperatureLength = 2; //Temperature Data is 2 Bytes
char TemperatureBuffer[TemperatureLength];
const int TemperaturePointer = 0x00; //To Read Temperature
//Pressure Variables
const int PressureAddress = 0x77;
const int PressureLength = 3; //Pressure Data is 3 Bytes Long
char PressureBuffer[PressureLength];
const int ResetPressure = 0x1E;
const int InitPressureSequence = 0x48;
const int ReadPressure = 0x00;
void Init_I2C() { //Initialize I2C
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_3_4, I2C_PULLUP_EXT, ClockSpeed); //Set for Master Mode, Pins 3 & 4 400kHz Clock
Wire.setDefaultTimeout(200000); // 200ms Timeout
Wire.setOpMode(I2C_OP_MODE_ISR); //Set it to be an interrupt based operation
SetTemperaturePointer();
ResetPressureSensor();//This is done here in order to check if we can talk to the sensor
}
void SetTemperaturePointer() { //Set Pointer to temperature for temperature sensor. Only needs to be done on reset.
Wire.beginTransmission(TemperatureAddress); // Write to the Teperature Sensor
Wire.write(TemperaturePointer); // Write Pointer to the Temperature Sensor
Wire.endTransmission(); // End Transmission
if (Wire.getError()) {
Serial.println("Temperature Sensor Failed to Initialize");
}
else {
Serial.println("Temperature Sensor Successfully Initiliazed");
}
}
void ResetPressureSensor() {
Wire.beginTransmission(PressureAddress); //Write to Pressure Sensor
Wire.write(ResetPressure); //Reset It
Wire.endTransmission(); //End
if (Wire.getError()) { //Was there an error?
Serial.println("Pressure Sensor Failed to Initialize");
}
else {
Serial.println("Pressure Sensor Successfully Initiliazed");
}
}