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;
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() {