i2c_t3 Library Incompatible with Audio Library

grinch

Well-known member
Hi, I am trying to use the i2c_t3 library (found linked on the Teensy website i2c page) to do fast DMA based i2c to control an LED driver.

Simultaneously, I am trying to run an audio library program.

Because the audio library uses the Wire library for some objects (which i am not using for my project btw), it has conflicting definitions with the i2c_t3 library.

This happens even when I make a completely blank sketch with both included:

Code:
#include <i2c_t3.h>
#include <Audio.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

I get the following error:

Code:
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o: In function `i2c0_isr':
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Wire/WireKinetis.cpp:912: multiple definition of `i2c0_isr'
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o:/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.cpp:1134: first defined here
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Disabling relaxation: it will not work with multiple definitions
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o: In function `Print::availableForWrite()':
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Wire/WireKinetis.h:133: multiple definition of `i2c1_isr'
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o:/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Print.h:61: first defined here
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o: In function `Print::availableForWrite()':Multiple libraries were found for "SD.h"
Used: /private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/SD
 Not used: /private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/libraries/SD
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Wire/WireKinetis.h:133: multiple definition of `Wire1'
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o:/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Print.h:61: first defined here
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire1' changed from 20 in /var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o to 108 in /var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o: In function `Print::availableForWrite()':
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/libraries/Wire/WireKinetis.h:133: multiple definition of `Wire'
/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o:/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Print.h:61: first defined here
/private/var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/AppTranslocation/1AE95969-E134-4286-9B52-BCFDC8FF82AD/d/Teensyduino.app/Contents/Java/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Warning: size of symbol `Wire' changed from 20 in /var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/i2c_t3/i2c_t3.cpp.o to 108 in /var/folders/j0/_sxbhppj1b9bmytyldk9lt600000gp/T/arduino_build_778229/libraries/Wire/WireKinetis.cpp.o
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.2 / 3.1.

Do you have any suggestions on how to fix / work around this? I would rather not switch to wire since I want to use DMA because of speed.
 
My solution was to edit the 6 control files in the Audio library like this example for one of the files:

Code:
#include <Arduino.h>
#include "control_sgtl5000.h"
//#include "Wire.h"
#include "i2c_t3.h"

Perhaps there is a better way as now there will be failures for when you wish to use the Wire library.
 
Yeah that worked as a temporary expedient. Definitely don't love the idea of having to just into library code tho.

For now I'm using the built-in DAC on the Teensy 3.2, so I don't have to use any of the control objects, but on a later project I'm going to be using the CS42448 codec. Are there any potential side effects of this change to the control object code that I should be aware of?
 
I don't really know but I doubt there are any side effects.

I don't believe you will see any speed improvement in using the i2c_t3 unless you use the added functions that the library provides.
If you use the standard function Wire.endTransmission() the library will block the same as the standard wire library until all the data has been sent.

The added function Wire.sendTransmission() does not block.

Some other notes I made about the library: the data is single buffered and when using sendTransmission() one needs to use the function Wire.done() to see if the previous transmission has finished before starting another. So to gain efficiency one needs to carefully control I2C writes and distribute processing to allow useful work to be done in between I2C transfers.
 
Back
Top