From d23ee90c72d3e9ef14e4f2de4fb5967f18f8b19a Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Fri, 28 Mar 2008 02:03:30 +0100 Subject: * digital/io/src - use define for some configuration values; - use volatile for variable used inside and outside interruption (thanks to ni). --- digital/io/src/chrono.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'digital/io/src/chrono.h') diff --git a/digital/io/src/chrono.h b/digital/io/src/chrono.h index f28d67ef..2003f290 100644 --- a/digital/io/src/chrono.h +++ b/digital/io/src/chrono.h @@ -38,6 +38,16 @@ #include "modules/utils/utils.h" /* regv */ #include "io.h" /* Registers for timer/counter 1 */ +/** + * Number of overflow of the timer/counter 1 before doing the last one. + */ +#define CHRONO_OVERFLOW_MAX 70 + +/** + * Number of TIC to restart from for the last overflow. + */ +#define CHRONO_RESTART_TIC 58982 + /** * Match is finished. * This variable will be set to 0 when the match is over. @@ -47,7 +57,7 @@ static uint8_t chrono_match_over; /** * Overflow counter. */ -static uint8_t chrono_ov_count_; +static volatile uint8_t chrono_ov_count_; /** * Initialize the chrono timer/counter 1. @@ -67,11 +77,11 @@ SIGNAL (SIG_OVERFLOW1) { switch (++chrono_ov_count_) { - case 70: + case CHRONO_OVERFLOW_MAX: /* Last but not complete overflow */ - TCNT1 = 58982; + TCNT1 = CHRONO_RESTART_TIC; break; - case 71: + case CHRONO_OVERFLOW_MAX + 1: /* End of match! */ chrono_match_over = 1; break; -- cgit v1.2.3