Code: Select all
unsigned long bigBuf[numSamplesToTake];
void IRAM_ATTR onTimer(){
if (isSampling){
adcBuffer[bufferIndex] = numSamples;
//bigBuf[numSamples] = (micros());
bufferIndex++;
if (haveWritten && bufferIndex >= writeSize){
toWrite = bufferIndex;
bufferIndex = 0;
uint16_t* t = adcBuffer;
adcBuffer = sdBuffer;
sdBuffer = t;
haveWritten = false;
shouldWrite = true;
}
numSamples++;
if (numSamples >= numSamplesToTake){
isSampling = false;
haveWritten = false;
shouldWrite = true;
}
}
}