Skip to content

Commit

Permalink
Revert "Temporary fix for pulseIn() regression."
Browse files Browse the repository at this point in the history
This reverts commit 8ddc519.
To be substituted by ASM generated code
  • Loading branch information
facchinm committed May 29, 2015
1 parent 5933a7e commit 0c9f0d5
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions hardware/arduino/avr/cores/arduino/wiring_pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,9 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
width++;
}

// convert the reading to microseconds. There will be some error introduced by
// convert the reading to microseconds. The loop has been determined
// to be 20 clock cycles long and have about 16 clocks between the edge
// and the start of the loop. There will be some error introduced by
// the interrupt handlers.

// Conversion constants are compiler-dependent, different compiler versions
// have different levels of optimization.
#if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==2
// avr-gcc 4.3.2
return clockCyclesToMicroseconds(width * 21 + 16);
#elif __GNUC__==4 && __GNUC_MINOR__==8 && __GNUC_PATCHLEVEL__==1
// avr-gcc 4.8.1
return clockCyclesToMicroseconds(width * 24 + 16);
#elif __GNUC__<=4 && __GNUC_MINOR__<=3
// avr-gcc <=4.3.x
#warning "pulseIn() results may not be accurate"
return clockCyclesToMicroseconds(width * 21 + 16);
#else
// avr-gcc >4.3.x
#warning "pulseIn() results may not be accurate"
return clockCyclesToMicroseconds(width * 24 + 16);
#endif

return clockCyclesToMicroseconds(width * 21 + 16);
}

0 comments on commit 0c9f0d5

Please sign in to comment.