summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/chrono.h
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-23 10:23:03 +0200
committerJérémy Dufour2008-04-23 10:23:03 +0200
commit331037945d5e0146868a82707e7cc9e14942e58f (patch)
tree4481241989d33c7e7580a526e17fac38cb68396d /digital/io/src/chrono.h
parent14516e73922ef733cd6987143a1e725ba3d9fdba (diff)
* digital/io/src
- seperate chrono into two files (source and header) ; - add necessary functions to end the match ; - integrate it into the main loop ; - partial integration into the simulator (need to simulate a counter).
Diffstat (limited to 'digital/io/src/chrono.h')
-rw-r--r--digital/io/src/chrono.h62
1 files changed, 19 insertions, 43 deletions
diff --git a/digital/io/src/chrono.h b/digital/io/src/chrono.h
index 2003f290..fc715d6d 100644
--- a/digital/io/src/chrono.h
+++ b/digital/io/src/chrono.h
@@ -33,59 +33,35 @@
* match_duration / (1 / (AC_FREQ / (Prescaler * (TOP + 1))))
* It will overflow 79 times and them reset the timer/counter to 58982
* (TOP - ((TOP + 1) / 10)).
+ * @todo add the ability to unblock the chrono_end_match with a flag that can
+ * be unset with an uart command. Maybe dangerous...
*/
-#include "modules/utils/utils.h" /* regv */
-#include "io.h" /* Registers for timer/counter 1 */
+#include "common.h"
/**
- * 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.
+ * Initialize the chrono timer/counter 1.
+ * It starts it for a duration of 90s.
*/
-static uint8_t chrono_match_over;
+void
+chrono_init (void);
/**
- * Overflow counter.
+ * Match over?
+ * @return
+ * - 0 if the match is not finished yet
+ * - 1 if the match is over
*/
-static volatile uint8_t chrono_ov_count_;
+uint8_t
+chrono_is_match_over (void);
/**
- * Initialize the chrono timer/counter 1.
+ * End the match.
+ * This function is responsible of resetting the asserv board to stop the bot
+ * from moving and put the io board in a state where it will not do something.
+ * @param block blocking function until hardware reset?
*/
-static inline void
-chrono_init (void)
-{
- /* Presaler = 256 */
- TCCR1B = regv (ICNC1, ICES1, 5, WGM13, WGM12, CS12, CS11, CS10,
- 0, 1, 0, 0, 0, 1, 0, 0);
- /* Enable overflow interrupt */
- set_bit (TIMSK, TOIE1);
-}
-
-/* Overflow of timer/counter 1 handler. */
-SIGNAL (SIG_OVERFLOW1)
-{
- switch (++chrono_ov_count_)
- {
- case CHRONO_OVERFLOW_MAX:
- /* Last but not complete overflow */
- TCNT1 = CHRONO_RESTART_TIC;
- break;
- case CHRONO_OVERFLOW_MAX + 1:
- /* End of match! */
- chrono_match_over = 1;
- break;
- }
-}
+void
+chrono_end_match (uint8_t block);
#endif /* chrono_h */