- // test if the field exists
- if (AT91C_BASE_ADC->ADC_SR & ADC_END_OF_CONVERSION(ADC_CHAN_HF_LOW)) {
- analogCnt++;
- analogAVG += AT91C_BASE_ADC->ADC_CDR[ADC_CHAN_HF_LOW];
- AT91C_BASE_ADC->ADC_CR = AT91C_ADC_START;
- if (analogCnt >= 32) {
- if ((MAX_ADC_HF_VOLTAGE_LOW * (analogAVG / analogCnt) >> 10) < MF_MINFIELDV) {
- vtime = GetTickCount();
- if (!timer) timer = vtime;
- // 50ms no field --> card to idle state
- if (vtime - timer > 50) return 2;
- } else
- if (timer) timer = 0;
- analogCnt = 0;
- analogAVG = 0;
+ b = *upTo++;
+
+ if(upTo >= dmaBuf + DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
+ upTo = dmaBuf; // start reading the circular buffer from the beginning
+ if(behindBy > (9*DMA_BUFFER_SIZE/10)) {
+ Dbprintf("About to blow circular buffer - aborted! behindBy=%d", behindBy);
+ ret = 1;
+ break;