Skip to content

Commit 2cbdc12

Browse files
committed
Fixed unused variables warnings and indentation
1 parent 94a182e commit 2cbdc12

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

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

Lines changed: 9 additions & 12 deletions
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
}

hardware/arduino/sam/cores/arduino/wiring_pulse.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ uint32_t pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
7373
// the initial loop; it takes 18 clock cycles per iteration.
7474
unsigned long maxloops = microsecondsToClockCycles(timeout) / 10;
7575

76-
// wait for any previous pulse to end
77-
while ((p.pPort->PIO_PDSR & bit) == stateMask)
76+
// wait for any previous pulse to end
77+
while ((p.pPort->PIO_PDSR & bit) == stateMask)
7878
if (--maxloops == 0)
7979
return 0;
8080

@@ -90,4 +90,4 @@ uint32_t pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
9090
return 0;
9191
}
9292
return micros() - start;
93-
}
93+
}

0 commit comments

Comments
 (0)