From: Olivier Matz Date: Tue, 8 Oct 2013 20:39:39 +0000 (+0200) Subject: fix interrupt locking X-Git-Url: http://git.droids-corp.org/?p=protos%2Frc_servos.git;a=commitdiff_plain;h=516dc48d0a1c47e354856d3f71b2e5bd0454cf4e fix interrupt locking cli/sei were reversed --- diff --git a/main.c b/main.c index e434690..923a8ea 100644 --- a/main.c +++ b/main.c @@ -173,16 +173,16 @@ static void poll_input_capture(void) if ((TIFR1 & _BV(ICF1)) == 0) return; - sei(); - icp = ICR1; cli(); + icp = ICR1; + sei(); rising = TCCR1B & _BV(ICES1); /* change the edge type */ TCCR1B ^= _BV(ICES1); - /* clear the flag */ + /* clear the flag by writing a one */ TIFR1 = TIFR1 | _BV(ICF1); diff = icp - icp_prev;