diff options
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/IPAddress.h | 3 | ||||
-rw-r--r-- | cores/arduino/wiring_pulse.c | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/cores/arduino/IPAddress.h b/cores/arduino/IPAddress.h index b20ab58..d762f2c 100644 --- a/cores/arduino/IPAddress.h +++ b/cores/arduino/IPAddress.h @@ -21,7 +21,8 @@ #define IPAddress_h #include <stdint.h> -#include <Printable.h> +#include "Printable.h" +#include "WString.h" // A class to make it easier to handle and pass around IP addresses diff --git a/cores/arduino/wiring_pulse.c b/cores/arduino/wiring_pulse.c index 3212f13..d6e0434 100644 --- a/cores/arduino/wiring_pulse.c +++ b/cores/arduino/wiring_pulse.c @@ -69,22 +69,24 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) uint8_t port = digitalPinToPort(pin); uint8_t stateMask = (state ? bit : 0); - unsigned long maxMicros = micros() + timeout; + unsigned long startMicros = micros(); // wait for any previous pulse to end - while ((*portInputRegister(port) & bit) == stateMask) - if (micros() > maxMicros) + while ((*portInputRegister(port) & bit) == stateMask) { + if (micros() - startMicros > timeout) return 0; + } // wait for the pulse to start - while ((*portInputRegister(port) & bit) != stateMask) - if (micros() > maxMicros) + while ((*portInputRegister(port) & bit) != stateMask) { + if (micros() - startMicros > timeout) return 0; + } unsigned long start = micros(); // wait for the pulse to stop while ((*portInputRegister(port) & bit) == stateMask) { - if (micros() > maxMicros) + if (micros() - startMicros > timeout) return 0; } return micros() - start; |