Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile byte isrFlag;
- byte loopFlag;
- // and many other variables
- void setup()
- {
- pinModeFast(2, INPUT); // LA.ch#0
- pinModeFast(12, OUTPUT); // LA.ch#1
- pinModeFast(13, OUTPUT); // LA.ch#2
- lastTrig = micros();
- isrFlag = LOW;
- loopFlag = LOW;
- digitalWriteFast(12, isrFlag);
- digitalWriteFast (13, loopFlag);
- noInterrupts();
- lastState = digitalReadFast(2);
- attachInterrupt(0, myISR, CHANGE);
- interrupts();
- }
- void loop()
- {
- loopFlag = ~loopFlag;
- digitalWriteFast(13, loopFlag);
- }
- void myISR()
- {
- thisTrig = micros();
- slab = thisTrig - lastTrig;
- isrFlag = ~isrFlag;
- digitalWriteFast(12, isrFlag);
- // code that checks lastState (HIGH/LOW) and slab (duration of lastState)
- // to identify SHORT-LOW, SHORT-HIGH, LONG-LOW, LONG-HIGH, VERYLONG-LOW and INVALID
- // sequence. INVALID sequence is ignored and decoder FSM is reset, others are
- // accumulated via a circular-queue until codeword-length is reached, at which point
- // codeword is processed i.e. matched with previous codeword to compare address bits
- // and if matched, data bits returned
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement