I am trying to use i2c on a Teensy 3.2 with alternate pins (16 & 17). This requires the i2c_t3 library. I would like to use some of the features of the I2CDevlib as well. I am trying to compile the most basic project and am getting conflicts with the standard Wire library.
The error is “multiple definition of …” for i2c0_isr, i2c1_isr, Wire1, and Wire.
Something in the I2Cdevlib-Core library is including wire.h even though I specified I2CDEV_TEENSY_3X_WIRE which is supposed to switch to i2c_t3.h.
The function that causes this issue to occur is the alternate Wire.begin() statement with the alternate pin settings.
Any help would be appreciated!
Here is my main.cpp:
#define I2CDEV_IMPLEMENTATION I2CDEV_TEENSY_3X_WIRE
#include <I2Cdev.h>
void setup() {
// put your setup code here, to run once:
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_16_17, I2C_PULLUP_EXT,
I2C_RATE_400);
}
void loop() {
// put your main code here, to run repeatedly:
}
Here is my platformio.ini:
[env:teensy31]
platform = teensy
board = teensy31
framework = arduino
lib_deps =
11 ; I2Cdevlib-Core
build_type = debug
Here is the build output:
> Executing task: platformio run <
Processing teensy31 (platform: teensy; board: teensy31; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy31.html
PLATFORM: Teensy 4.6.0 > Teensy 3.1 / 3.2
HARDWARE: MK20DX256 72MHz, 64KB RAM, 256KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1), framework-arduinoteensy 1.148.0 (1.48)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 91 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <I2Cdevlib-Core> (/Users/jeff/workspaces/teensy_i2c_test/.pio/libdeps/teensy31/I2Cdevlib-Core_ID11)
| |-- <Wire> 1.0 (/Users/jeff/.platformio/packages/framework-arduinoteensy/libraries/Wire)
| |-- <i2c_t3> (/Users/jeff/.platformio/packages/framework-arduinoteensy/libraries/i2c_t3)
Building in debug mode
arm-none-eabi-g++ -o .pio/build/teensy31/firmware.elf -T mk20dx256.ld -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m4 -Wl,--defsym=__rtc_localtime=1579369911 -fsingle-precision-constant -Og -g2 -ggdb2 .pio/build/teensy31/src/main.cpp.o -L/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3 -L.pio/build/teensy31 -Wl,--start-group .pio/build/teensy31/lib889/libWire.a .pio/build/teensy31/lib1a6/libi2c_t3.a .pio/build/teensy31/libb77/libI2Cdevlib-Core_ID11.a .pio/build/teensy31/libFrameworkArduino.a -larm_cortexM4l_math -lm -lstdc++ -Wl,--end-group
.pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o): In function `i2c0_isr':
/Users/jeff/.platformio/packages/framework-arduinoteensy/libraries/i2c_t3/i2c_t3.cpp:1132: multiple definition of `i2c0_isr'
.pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o):/Users/jeff/.platformio/packages/framework-arduinoteensy/libraries/Wire/WireKinetis.cpp:912: first defined here
/Users/jeff/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Disabling relaxation: it will not work with multiple definitions
.pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o): In function `Print::flush()':
/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: multiple definition of `i2c1_isr'
.pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o):/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: first defined here
.pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o): In function `Print::flush()':
/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: multiple definition of `Wire1'
.pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o):/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: first defined here
/Users/jeff/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire1' changed from 108 in .pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o) to 20 in .pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o)
.pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o): In function `Print::flush()':
/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: multiple definition of `Wire'
.pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o):/Users/jeff/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.h:61: first defined here
/Users/jeff/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire' changed from 108 in .pio/build/teensy31/lib889/libWire.a(WireKinetis.cpp.o) to 20 in .pio/build/teensy31/lib1a6/libi2c_t3.a(i2c_t3.cpp.o)
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy31/firmware.elf] Error 1
================================================================================== [FAILED] Took 1.23 seconds ==================================================================================
The terminal process terminated with exit code: 1