From 3cbbf242571c7a02b0c81eb32c1363bd72fe1dbe Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 28 Mar 2020 17:09:09 -0400 Subject: [PATCH] Use arduino's bitWrite to simplify DATA0/DATA1 ISRs --- hidReader.ino | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hidReader.ino b/hidReader.ino index 421cf27..3b6c36b 100644 --- a/hidReader.ino +++ b/hidReader.ino @@ -26,23 +26,21 @@ volatile size_t bitCount = 0; // number of bits recieved volatile unsigned long weigand_idle_start; -inline void gotBit() { +inline void gotBit(char bit) { weigand_idle_start = millis(); + Serial.print(bit, BIN); + bitWrite(dataBits, DATA_SIZE - bitCount, bit); bitCount++; } // interrupt that happens when INTO goes low (0 bit) void ISR_INT0() { - //Serial.print("0"); - dataBits &= ~(1UL << (DATA_SIZE - bitCount)); - gotBit(); + gotBit(0); } // interrupt that happens when INT1 goes low (1 bit) void ISR_INT1() { - //Serial.print("1"); - dataBits |= 1UL << (DATA_SIZE - bitCount); - gotBit(); + gotBit(1); } void setup() {