diff -r dfe67409fbcd -r ec42f36d8614 src/timer.c --- a/src/timer.c Thu Apr 03 20:25:12 2014 +0300 +++ b/src/timer.c Thu Apr 03 22:24:46 2014 +0300 @@ -69,8 +69,10 @@ */ char timer_sleep (int cycles) { - // set timer - timer1_start(cycles); + if (cycles) { + // set timer + timer1_start(cycles); + } // sleep // TODO: PRR @@ -88,14 +90,14 @@ // cleanup SMCR = 0; - if (tbi(&TIMER_FLAGS, TIMER1_BUSY)) { + if (cycles && !tbi(&TIMER_FLAGS, TIMER1_BUSY)) { + // timeout + return 1; + } else { timer1_stop(); // interrupt return 0; - } else { - // timeout - return 1; } }