50
edits
Chet Manly (talk | contribs) |
Chet Manly (talk | contribs) |
||
| Line 172: | Line 172: | ||
interrupts(); | interrupts(); | ||
} | } | ||
// --- Interrupt service routines | |||
ISR(TIMER1_COMPA_vect) { | |||
// Begin a conversion on the first channel in the sequence and record the time. | |||
readComplete = false; | |||
index = 0; | |||
ADMUX = channelSequence[index]; | |||
bitSet(ADCSRA, ADSC); // ADSC == "Analog-Digital converter Start Conversion" | |||
sampleTime = micros(); | |||
} | |||
ISR(ADC_vect) { | |||
// Store the conversion result. | |||
rawADC[index] = ADC; | |||
// Check if all channels have been read. If not, start the next one. | |||
if (index == maxIndex) readComplete = true; | |||
else { | |||
index++; | |||
ADMUX = channelSequence[index]; | |||
bitSet(ADCSRA, ADSC); | |||
} | |||
} | |||
// --- Interrupt service routines | |||
ISR(TIMER0_COMPA_vect) { | |||
// Debounce the button. See comments in 'AccelCalib.ino'. | |||
static volatile uint16_t btnHistory = 0xFFFF; | |||
</pre> | </pre> | ||
edits