Skip to content

Commit 64dd45c

Browse files
committed
Fixed unused variables warnings and indentation
1 parent b7855ab commit 64dd45c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

cores/arduino/wiring_pulse.c

+9-12
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
4040
uint8_t bit = digitalPinToBitMask(pin);
4141
uint8_t port = digitalPinToPort(pin);
4242
uint8_t stateMask = (state ? bit : 0);
43-
unsigned long width = 0; // keep initialization out of time critical area
4443

4544
// convert the timeout from microseconds to a number of times through
4645
// the initial loop; it takes approximately 16 clock cycles per iteration
47-
unsigned long numloops = 0;
4846
unsigned long maxloops = microsecondsToClockCycles(timeout)/16;
4947

50-
width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops);
48+
unsigned long width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops);
5149

52-
//prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out
50+
// prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out
5351
if (width)
5452
return clockCyclesToMicroseconds(width * 16 + 16);
5553
else
@@ -72,7 +70,6 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
7270
uint8_t bit = digitalPinToBitMask(pin);
7371
uint8_t port = digitalPinToPort(pin);
7472
uint8_t stateMask = (state ? bit : 0);
75-
unsigned long width = 0; // keep initialization out of time critical area
7673

7774
// convert the timeout from microseconds to a number of times through
7875
// the initial loop; it takes 16 clock cycles per iteration.
@@ -89,11 +86,11 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
8986
if (numloops++ == maxloops)
9087
return 0;
9188

92-
unsigned long start = micros();
93-
// wait for the pulse to stop
94-
while ((*portInputRegister(port) & bit) == stateMask) {
95-
if (numloops++ == maxloops)
96-
return 0;
97-
}
98-
return micros() - start;
89+
unsigned long start = micros();
90+
// wait for the pulse to stop
91+
while ((*portInputRegister(port) & bit) == stateMask) {
92+
if (numloops++ == maxloops)
93+
return 0;
94+
}
95+
return micros() - start;
9996
}

0 commit comments

Comments
 (0)