From 134358b9abc571c1dc4474161eb65d6dd62c4d6e Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Wed, 30 Apr 2008 01:35:45 +0200 Subject: * digital/io/src - implement chrono under host. --- digital/io/src/chrono.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/digital/io/src/chrono.c b/digital/io/src/chrono.c index 4244fbd2..eb8abace 100644 --- a/digital/io/src/chrono.c +++ b/digital/io/src/chrono.c @@ -30,6 +30,12 @@ #include "io.h" /* Registers for timer/counter 1 */ +#ifdef HOST +#include +#include +#include "modules/host/mex.h" +#endif + /** * Number of overflow of the timer/counter 1 before doing the last one. */ @@ -59,6 +65,12 @@ static volatile uint8_t chrono_match_over_ = 0; */ static volatile uint8_t chrono_ov_count_; +#ifdef HOST +/** SIGALRM handler. */ +void +signal_alarm (int signal); +#endif + /* Initialize the chrono timer/counter 1. */ void chrono_init (void) @@ -69,6 +81,11 @@ chrono_init (void) 0, 0, 0, 0, 0, 1, 0, 0); /* Enable overflow interrupt */ set_bit (TIMSK, TOIE1); +#else + /* Set-up SIGALRM handler */ + signal (SIGALRM, &signal_alarm); + /* Alarm in 90 seconds */ + alarm (90); #endif } @@ -88,8 +105,17 @@ SIGNAL (SIG_OVERFLOW1) break; } } +#else +/* SIGALRM handler */ +void +signal_alarm (int signal) +{ + /* End of match! */ + chrono_match_over_ = 1; +} #endif + /* Match over? */ uint8_t chrono_is_match_over (void) @@ -140,5 +166,11 @@ chrono_end_match (uint8_t block) asserv_reset (); /* Block indefinitely */ if (block) - while (42); + while (42) +#ifdef HOST + { + mex_node_wait (); + } +#endif + ; } -- cgit v1.2.3