Skip to content

Commit e92be15

Browse files
committed
Revert "Temporary fix for pulseIn() regression."
This reverts commit 8ddc519. To be substituted by ASM generated code
1 parent 9cc7b7e commit e92be15

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

hardware/arduino/avr/cores/arduino/wiring_pulse.c

Lines changed: 4 additions & 20 deletions
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)