Skip to content

Commit a72e1b7

Browse files
author
Martino Facchin
committed
pulseIn: use old behaviour for timeout
now timeout is passed to ASM function as (full_timeout - elapsed_timeout)
1 parent adca790 commit a72e1b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "wiring_private.h"
2626
#include "pins_arduino.h"
2727

28-
//include PORT similar to the ones defined in Arduino.h
28+
//include PORT as the ones defined in Arduino.h
2929
#define PA 1
3030
#define PB 2
3131
#define PC 3
@@ -100,7 +100,7 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
100100
if (numloops++ == maxloops)
101101
return 0;
102102

103-
width = countPulseASM(bit, stateMask, maxloops);
103+
width = countPulseASM(bit, stateMask, (maxloops - numloops));
104104
return clockCyclesToMicroseconds(width * 15 + 30);
105105
}
106106

0 commit comments

Comments
 (0)