diff options
-rw-r--r-- | cores/arduino/wiring_pulse.c | 11 | ||||
-rw-r--r-- | libraries/HID/HID.cpp | 11 |
2 files changed, 5 insertions, 17 deletions
diff --git a/cores/arduino/wiring_pulse.c b/cores/arduino/wiring_pulse.c index 76383e9..3212f13 100644 --- a/cores/arduino/wiring_pulse.c +++ b/cores/arduino/wiring_pulse.c @@ -69,25 +69,22 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) uint8_t port = digitalPinToPort(pin); uint8_t stateMask = (state ? bit : 0); - // convert the timeout from microseconds to a number of times through - // the initial loop; it takes 16 clock cycles per iteration. - unsigned long numloops = 0; - unsigned long maxloops = microsecondsToClockCycles(timeout); + unsigned long maxMicros = micros() + timeout; // wait for any previous pulse to end while ((*portInputRegister(port) & bit) == stateMask) - if (numloops++ == maxloops) + if (micros() > maxMicros) return 0; // wait for the pulse to start while ((*portInputRegister(port) & bit) != stateMask) - if (numloops++ == maxloops) + if (micros() > maxMicros) return 0; unsigned long start = micros(); // wait for the pulse to stop while ((*portInputRegister(port) & bit) == stateMask) { - if (numloops++ == maxloops) + if (micros() > maxMicros) return 0; } return micros() - start; diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp index c629eb9..c5954ed 100644 --- a/libraries/HID/HID.cpp +++ b/libraries/HID/HID.cpp @@ -27,16 +27,7 @@ static u8 HID_ENDPOINT_INT; //================================================================================ //================================================================================ - -// HID report descriptor - -#define LSB(_x) ((_x) & 0xFF) -#define MSB(_x) ((_x) >> 8) - -#define RAWHID_USAGE_PAGE 0xFFC0 -#define RAWHID_USAGE 0x0C00 -#define RAWHID_TX_SIZE 64 -#define RAWHID_RX_SIZE 64 +// HID Interface static u8 HID_INTERFACE; |