]> git.droids-corp.org - protos/rc_servos.git/commitdiff
fix interrupt locking
authorOlivier Matz <zer0@droids-corp.org>
Tue, 8 Oct 2013 20:39:39 +0000 (22:39 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Tue, 8 Oct 2013 20:39:39 +0000 (22:39 +0200)
cli/sei were reversed

main.c

diff --git a/main.c b/main.c
index e434690b0d80b115296eb201e27d4621fd1a0e4b..923a8ea1bcd4ce553b2b089644768e77294f0b6c 100644 (file)
--- 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;