Use arduino's bitWrite to simplify DATA0/DATA1 ISRs

This commit is contained in:
Adam Goldsmith 2020-03-28 17:09:09 -04:00
parent 34eb7e8add
commit 3cbbf24257

View File

@ -26,23 +26,21 @@ volatile size_t bitCount = 0; // number of bits recieved
volatile unsigned long weigand_idle_start; volatile unsigned long weigand_idle_start;
inline void gotBit() { inline void gotBit(char bit) {
weigand_idle_start = millis(); weigand_idle_start = millis();
Serial.print(bit, BIN);
bitWrite(dataBits, DATA_SIZE - bitCount, bit);
bitCount++; bitCount++;
} }
// interrupt that happens when INTO goes low (0 bit) // interrupt that happens when INTO goes low (0 bit)
void ISR_INT0() { void ISR_INT0() {
//Serial.print("0"); gotBit(0);
dataBits &= ~(1UL << (DATA_SIZE - bitCount));
gotBit();
} }
// interrupt that happens when INT1 goes low (1 bit) // interrupt that happens when INT1 goes low (1 bit)
void ISR_INT1() { void ISR_INT1() {
//Serial.print("1"); gotBit(1);
dataBits |= 1UL << (DATA_SIZE - bitCount);
gotBit();
} }
void setup() { void setup() {