I have a project using the teensy audio adapter board + a pair of I2C devices -- a BNO055 IMU and a MCP23017 I/O expander, powered over USB. I2C bus uses SDA0/SCL0 on pins 18 & 19. With I2S audio output enabled, the IMU will give a few seconds of readings before locking up. Commenting out either the call to read quaternion data from the IMU or declaring a different audio output type (swapping AudioOutputI2S for AudioOutputAnalog, for instance), all is fine. I'm using a slightly modified version of the Adafruit BNO055 library. Audio library is unchanged. I'm using my own library for the MCP23017, but in the example code below, while the Expander is instantiated, it's not used. Serial output hums along for 3-4 seconds, then everything locks up. BNO055 hardware is my own breakout design and uses 10K pullups as well as an I2C address of 0x28. The code below distills the problem to its essentials. Note that in loop(), I'm not using the AudioOutput device at all. I'm doing something I shouldn't be doing, but it's not obvious to me what that is. Perhaps my pullups are too aggressive? Any insight would be greatly appreciated.
Code:
#include <Audio.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include "MCP23017.h"
AudioPlaySdWav playWav1;
// Use one of these 3 output types: Digital I2S, Digital S/PDIF, or Analog DAC
AudioOutputI2S audioOutput;
//AudioOutputSPDIF audioOutput;
//AudioOutputAnalog audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
// Use these with the audio adaptor board
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
imu::Quaternion q;
Adafruit_BNO055 bno = Adafruit_BNO055();
MCP23017 Expander(0x20);
uint16_t val;
// set interval for IMU samples
uint8_t sample_interval = 100;
uint32_t last_sample_time = 0;
void setup() {
Serial.begin(115200);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(8);
// Comment these out if not using the audio adaptor board.
// This may wait forever if the SDA & SCL pins lack
// pullup resistors
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
if(!bno.begin())
{
// here was a problem detecting the BNO055 ... check your connections
//Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1); //lock up
}
bno.setExtCrystalUse(true);
Expander.begin();
delay(500);
}
void loop() {
int n;
// Update button and orientation state
if(millis() - last_sample_time > sample_interval)
{
q = bno.getQuat();
last_sample_time = millis();
Serial.print("Qx: " );
Serial.println(q.x());
}
}