From c7494c80fac7ae9be63a3943e92adbab50694ebd Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 21 Jun 2012 16:14:56 -0300 Subject: [PATCH] fw/accel.c: fix update() add interrupt-friendly update_irq() Still untested. --- fw/sweep.c | 14 +++++++++++++- fw/sweep.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fw/sweep.c b/fw/sweep.c index 059c286..3aac954 100644 --- a/fw/sweep.c +++ b/fw/sweep.c @@ -84,6 +84,17 @@ ISR(TIMER1_OVF_vect) } +uint32_t uptime_irq(void) +{ + uint32_t t; + + t = t_up+TCNT1; + if (TIFR1 & TOV1) + t += ICR1; + return t; +} + + uint32_t uptime(void) { uint32_t a, b; @@ -92,7 +103,8 @@ uint32_t uptime(void) do { cli(); a = t_up; - d = ICR1; + d = TCNT1; + cli(); b = t_up; sei(); } diff --git a/fw/sweep.h b/fw/sweep.h index 08b325e..b0113e4 100644 --- a/fw/sweep.h +++ b/fw/sweep.h @@ -29,7 +29,9 @@ struct sweep { extern volatile bool sweeping; +uint32_t uptime_irq(void); uint32_t uptime(void); + void sweep_image(const struct sweep *sweep); void sweep_init(void);