  * This demo will provide an audio passthrough, as well as exercise the
  * MIDI interface.
  * 
- * It will also perform a sweeo of the SPI MEM0 external RAM.
+ * It will also peform a sweep of SPI MEM0.
+ * 
+ * NOTE: SPI MEM0 can be used by a Teensy 3.1/3.2/3.5/3.6.
+ * pins.
  * 
  */
+//#include <i2c_t3.h>
 #include <Wire.h>
 #include <Audio.h>
 #include <MIDI.h>

  delay(100);
  AudioMemory(24);

  Serial.println("Enabling codec...\n");
  codecControl.enable();
  delay(100);
  
}

void loop() {  

  //////////////////////////////////////////////////////////////////
  // Write test data to the SPI Memory 0
  //////////////////////////////////////////////////////////////////
  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0++) {
    if ((spiAddress0 % 32768) == 0) {
      //Serial.print("Writing to ");
      //Serial.println(spiAddress0, HEX);
    }

    //mem0Write(spiAddress0, spiData0);
    spiMem0.write(spiAddress0, spiData0);
    spiData0 = (spiData0-1) & 0xff;
  }
  Serial.println("SPI0 writing DONE!");


  ///////////////////////////////////////////////////////////////////
  spiErrorCount0 = 0;
  spiAddress0 = 0;
  maskPhase = 0;

  for (spiAddress0=0; spiAddress0 <= SPI_MAX_ADDR; spiAddress0=spiAddress0+2) {
    if ((spiAddress0 % 32768) == 0) {
//      Serial.print("Reading ");
//      Serial.print(spiAddress0, HEX);
    }

    spiData0 = calcData(spiAddress0, loopPhase, maskPhase);
    int data = spiMem0.read16(spiAddress0);
    if (data != spiData0) {
      spiErrorCount0++;
      Serial.println("");
      Serial.print("ERROR MEM0: (expected) (actual):");
      Serial.print(spiData0, HEX); Serial.print(":");
      Serial.print(data, HEX);
      
      delay(100);
    }
    maskPhase = (maskPhase+1) % 2;

    if ((spiAddress0 % 32768) == 0) {
//      Serial.print(", data = ");
//      Serial.println(data, HEX);
//      Serial.println(String(" loopPhase: ") + loopPhase + String(" maskPhase: ") + maskPhase);
    }

    // Break out of test once the error count reaches 10
    if (spiErrorCount0 > 10) { break; }
