Skip to content

Commit 1a63b36

Browse files
committed
Revert "Temporary fix for pulseIn() regression."
This reverts commit 8ddc5198f6ef8b2816a61b7b0fcce99f927d11a0. To be substituted by ASM generated code
1 parent 550f8b6 commit 1a63b36

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

cores/arduino/wiring_pulse.c

+4-20
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,9 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
6161
width++;
6262
}
6363

64-
// convert the reading to microseconds. There will be some error introduced by
64+
// convert the reading to microseconds. The loop has been determined
65+
// to be 20 clock cycles long and have about 16 clocks between the edge
66+
// and the start of the loop. There will be some error introduced by
6567
// the interrupt handlers.
66-
67-
// Conversion constants are compiler-dependent, different compiler versions
68-
// have different levels of optimization.
69-
#if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==2
70-
// avr-gcc 4.3.2
71-
return clockCyclesToMicroseconds(width * 21 + 16);
72-
#elif __GNUC__==4 && __GNUC_MINOR__==8 && __GNUC_PATCHLEVEL__==1
73-
// avr-gcc 4.8.1
74-
return clockCyclesToMicroseconds(width * 24 + 16);
75-
#elif __GNUC__<=4 && __GNUC_MINOR__<=3
76-
// avr-gcc <=4.3.x
77-
#warning "pulseIn() results may not be accurate"
78-
return clockCyclesToMicroseconds(width * 21 + 16);
79-
#else
80-
// avr-gcc >4.3.x
81-
#warning "pulseIn() results may not be accurate"
82-
return clockCyclesToMicroseconds(width * 24 + 16);
83-
#endif
84-
68+
return clockCyclesToMicroseconds(width * 21 + 16);
8569
}

0 commit comments

Comments
 (0)