Use arduino's bitWrite to simplify DATA0/DATA1 ISRs
This commit is contained in:
parent
34eb7e8add
commit
3cbbf24257
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user