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);