Skip to content

Commit

Permalink
ISR Commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
csBlueChip committed Jun 20, 2015
1 parent 5e7a1c1 commit 66dee2f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions irISR.cpp
Expand Up @@ -27,14 +27,14 @@ ISR (TIMER_INTR_NAME)
if (irparams.rawlen >= RAWBUF) irparams.rcvstate = STATE_OVERFLOW ; // Buffer overflow

switch(irparams.rcvstate) {
//......................................................................
case STATE_IDLE: // In the middle of a gap
if (irdata == MARK) {
if (irparams.timer < GAP_TICKS) {
// Not big enough to be a gap.
if (irparams.timer < GAP_TICKS) { // Not big enough to be a gap.
irparams.timer = 0;

} else {
// gap just ended, record duration and start recording transmission
// Gap just ended; Record duration; Start recording transmission
irparams.overflow = false;
irparams.rawlen = 0;
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
Expand All @@ -43,43 +43,43 @@ ISR (TIMER_INTR_NAME)
}
}
break;

case STATE_MARK: // timing MARK
if (irdata == SPACE) { // MARK ended, record time
//......................................................................
case STATE_MARK: // Timing Mark
if (irdata == SPACE) { // Mark ended; Record time
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
irparams.timer = 0;
irparams.rcvstate = STATE_SPACE;
}
break;

case STATE_SPACE: // timing SPACE
if (irdata == MARK) { // SPACE just ended, record it
//......................................................................
case STATE_SPACE: // Timing Space
if (irdata == MARK) { // Space just ended; Record time
irparams.rawbuf[irparams.rawlen++] = irparams.timer;
irparams.timer = 0;
irparams.rcvstate = STATE_MARK;

} else if (irparams.timer > GAP_TICKS) { // SPACE
// big SPACE, indicates gap between codes
// Mark current code as ready for processing
} else if (irparams.timer > GAP_TICKS) { // Space
// A long Space, indicates gap between codes
// Flag the current code as ready for processing
// Switch to STOP
// Don't reset timer; keep counting space width
// Don't reset timer; keep counting Space width
irparams.rcvstate = STATE_STOP;
}
break;

case STATE_STOP: // waiting, measuring gap
if (irdata == MARK) irparams.timer = 0 ; // reset gap timer
//......................................................................
case STATE_STOP: // Waiting; Measuring Gap
if (irdata == MARK) irparams.timer = 0 ; // Reset gap timer
break;

case STATE_OVERFLOW: // Flag up a read overflow
//......................................................................
case STATE_OVERFLOW: // Flag up a read overflow; Stop the State Machine
irparams.overflow = true;
irparams.rcvstate = STATE_STOP;
break;
}

// If requested, flash LED L (D13) while receiving IR data
if (irparams.blinkflag) {
if (irdata == MARK) BLINKLED_ON() ; // turn pin 13 LED on
else BLINKLED_OFF() ; // turn pin 13 LED off
}
}

0 comments on commit 66dee2f

Please sign in to comment.