diff options
author | Martino Facchin <m.facchin@arduino.cc> | 2015-03-02 13:22:07 +0100 |
---|---|---|
committer | Martino Facchin <m.facchin@arduino.cc> | 2015-05-29 15:01:37 +0200 |
commit | 1a63b36583fe0a6c5371933b6d7ccfc086a7f45c (patch) | |
tree | 55c1b1fd9d8db669c5d8870e7d9186830303473a /cores/arduino | |
parent | 550f8b61acd68f6f2a83dcc9455857d9659ad38f (diff) |
Revert "Temporary fix for pulseIn() regression."
This reverts commit 8ddc5198f6ef8b2816a61b7b0fcce99f927d11a0.
To be substituted by ASM generated code
Diffstat (limited to 'cores/arduino')
-rw-r--r-- | cores/arduino/wiring_pulse.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/cores/arduino/wiring_pulse.c b/cores/arduino/wiring_pulse.c index 830c454..0d96886 100644 --- a/cores/arduino/wiring_pulse.c +++ b/cores/arduino/wiring_pulse.c @@ -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); } |