PDA

View Full Version : Audio library/adaptor compatible w/ i2c_t3?



ninja118
04-06-2016, 11:06 PM
Is it possible to use the secondary I2C bus (pins 29/30 on the bottom side of Teensy 3.2) at the same time as using the audio library to control an attached audio adaptor?

I'd like to have the Teensy control its attached audio adapter, as usual, and at the same time have the Teensy listen as a slave on the secondary I2C bus.

I've tried to take a simple audio sketch that works, and add the i2c_t3 library, and then try to set up slave operation on the secondary bus, as shown in the i2c_t3 library examples (e.g., "Wire1.begin....")

However, compiling yields an error that suggests there's a conflict between the i2c_t3 library and the audio library's use of the Wire library:

.../Contents/Java/hardware/teensy/avr/libraries/i2c_t3/i2c_t3.h:803:15: error: conflicting declaration 'i2c_t3 Wire'
extern i2c_t3 Wire;

.../Contents/Java/hardware/teensy/avr/libraries/Wire/Wire.h:104:16: error: 'Wire' has a previous declaration as 'TwoWire Wire'
extern TwoWire Wire;
^
Error compiling for board Teensy 3.2 / 3.1.

Is there a way to use i2c_t3 library while also using the audio library and audio adaptor?

Or, is there a way to achieve the goal without using i2c_t3? I.e., using the secondary I2C bus (pins 29/30) at the same time the primary I2C bus is being used by the audio library to control the audio adaptor?

Or, is there a way to use the primary I2C bus (pins 18/19) to connect to an external master (and have the Teensy be a slave on it), all while the Teensy is talking to the audio adaptor on that same I2C bus (as a master) to the audio adaptor?

Any help greatly appreciated!

MichaelMeissner
04-06-2016, 11:19 PM
Typically what you have to do is go through all of the libraries that you use and change them to use i2c_t3 instead of Wire. Unfortunately, there are 4 files in Audio that use Wire:


./hardware/teensy/avr/libraries/Audio/control_sgtl5000.cpp
./hardware/teensy/avr/libraries/Audio/control_wm8731.cpp
./hardware/teensy/avr/libraries/Audio/control_cs4272.cpp
./hardware/teensy/avr/libraries/Audio/control_ak4558.cpp


It would be nice if i2c_t3.h could somehow be a superset of Wire to avoid this problem.

ninja118
04-07-2016, 10:10 AM
Awesome, that did the trick, thanks!! Successfully receiving as a slave on secondary I2C bus, while also controlling audio adaptor via Audio library.

Out of curiosity, is it necessary to use i2c_t3 to access the secondary I2C bus on Teensy pins 29/30? Or can the standard Wire library somehow handle this also?

Also, in case it's helpful for others, I'm running Arduino 1.6.8 with Teensyduino 1.28 *beta* on Mac OS-X.

MichaelMeissner
04-07-2016, 01:21 PM
AFAIK, you need to use i2c_t3 to access the secondary i2c bus (pins 29/30 on Teensy 3.1/3.2 and 22/23 on Teensy LC). Also, if you wanted to switch from using 19/18 for the first i2c bus to the alternate pins (17/16) you would need to use i2c_t3.

ninja118
04-07-2016, 06:21 PM
Go it -- thanks again!

sju
10-08-2016, 02:35 PM
Hello,

I am new to the process of working with libraries. It the CPP files being directly updated in like a text editor?


Steven

ChrisJ
05-24-2017, 05:04 AM
Any chance you could post the modified files? Thanks in advance.

[edit]Scratch that, I went in and replaced wire.h with i2c_t3.h in all the library cpp files listed and recompiled, and everything worked first time. For me, I didn't need to tweak any other code in the library. Thanks!