   return;  
 }
 
-
 // Enable next measurement cycle
-void ready_next(chanTDC7200* channel) {
-  // needs to set the enable bit (START_MEAS in CONFIG1)
+void ready_next(struct chanTDC7200 *channel) {
+    // needs to set the enable bit (START_MEAS in CONFIG1)
     writeTDC7200(channel, CONFIG1, 0x03);  // measurement mode 2 ('01')
 }
 

  
  digitalWrite(channel->CSB, HIGH);

// read the CALIBRATION1 register
   // take the chip select low to select the device:
  digitalWrite(channel->CSB, LOW);

  SPI.transfer(CALIBRATION1);

// data is clocked on the rising edge of the clock (seems to be SPI_MODE0)
// max clock speed: 20 mHz
// Using TDC7200 timing mode 1...
void setup() {
  int i;
  // start the SPI library:
  SPI.begin();
  
  pinMode(intPin, INPUT);

  for(i = 0; i < ARRAY_SIZE(channels); ++i) {
    pinMode(channels[i].ENABLE,OUTPUT);
    pinMode(channels[i].INTB,INPUT);
    pinMode(channels[i].CSB,OUTPUT);
    pinMode(channels[i].STOP,INPUT);
    TDC_setup(&channels[i]);
  }
  
  attachInterrupt(interrupt, coarseTimer, RISING);

  delay(10);
  
  for(i = 0; i < ARRAY_SIZE(channels); ++i)
      ready_next(&channels[i]);
  
  Serial.begin(115200);
  Serial.println("Starting...");
}

void loop() {
  int i;

  for(i = 0; i < ARRAY_SIZE(channels); ++i) {
    if(channels[i].STOP)
      channels[i].stopTime = coarseCount;

    if(channels[i].INTB) {
      channels[i].result = TDC_calc(&channels[i]);
      ready_next(&channels[i]);
    }
  }
     
   // if we have both channels, subtract channel 0 from channel 1, print result, and reset vars
  if (channels[0].result && channels[1].result) { 
    output_ti();
    for(i = 0; i < ARRAY_SIZE(channels); ++i) {
      channels[i].result = 0;
      channels[i].stopTime = 0;
    }
  }
}  

// ISR for timer. NOTE: uint_64 rollover would take
