 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 //  Analog Devices, Inc.
-//  October 2015
-//  By: Daniel H. Tatum & Juan Chong
+//  May 19, 2016
+//  By: Daniel H. Tatum & Juan J. Chong
 //  Written for the TeensyDuino Platform
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 //  Arduino_TX_ADIS16480_ADF7242.ino

  Tx.regWrite(0x084, yaw); // Write yaw data to ADF7242 packet buffer
  Tx.transmit();  // Transmit packet buffer
  Tx.closeSPI();  // End SPI transaction
  
}

void loop() {
  
  // Program is entirely interrupt driven. Only debug statements are optionally compiled here.
  
  #ifdef DEBUG
    Tx.dumpISB();
    delay(100);
  #endif

  // Write IMU data to serial port
  #ifdef DEBUG
    Serial.write(roll); // Write roll data to serial connection
    Serial.write(pitch); // Write pitch data to serial connection
    Serial.write(yaw); // Write yaw data to serial connection
    Serial.write(serialSyncWord); // Write synchronization word to serial connection
  #endif
  
}


  
  // Set interrupt pin on the MCU as an input and attach an interrupt
  pinMode(8, INPUT);
  attachInterrupt(8, transmitData, RISING);
}

// Read IMU data, cast it, and transmit it.
void grabSensorData() {
  IMU.configSPI();  // Begin SPI transactions
  roll = (char)(IMU.regRead(ROLL_C23_OUT) >> 8);  // Read roll register and cast to char
  pitch = (char)(IMU.regRead(PITCH_C31_OUT) >> 8);  // Read pitch register and cast to char
  yaw = (char)(IMU.regRead(YAW_C32_OUT) >> 8);  // Read pitch register and cast to char
  // 0xFF is a reserved word used for data synchronization
  if(roll == 0xFF) { // 0xFF represents 360 degrees
    roll = 0; // This makes sense since 0 and 360 degrees are the same place
  }
