summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/chrono.c
diff options
context:
space:
mode:
authorJérémy Dufour2009-04-27 18:23:45 +0200
committerJérémy Dufour2009-04-27 18:23:45 +0200
commitfb3cfa5a0ac1acb58c2067cd1aad0339b534f982 (patch)
tree169d6611cce0d04d3b3d6591c8a180c238af6fa4 /digital/io/src/chrono.c
parent4f77a9904f90a3056c2ec89f497d0ffafd3f345e (diff)
* digital/io/src (fixes #66):
- add a system to enable or disable the chrono module, - call chrono update function every main loop.
Diffstat (limited to 'digital/io/src/chrono.c')
-rw-r--r--digital/io/src/chrono.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/digital/io/src/chrono.c b/digital/io/src/chrono.c
index 6397f4f8..254e0e1b 100644
--- a/digital/io/src/chrono.c
+++ b/digital/io/src/chrono.c
@@ -64,10 +64,18 @@
*/
static uint32_t chrono_ov_count_;
+/**
+ * Status of the chrono module.
+ * Set to 0 if the module is disabled, otherwise set to a non 0 value.
+ */
+static uint8_t chrono_enabled_ = 0;
+
void
chrono_init (void)
{
+ /* Enable chrono. */
+ chrono_enable ();
/* Set the overflow counter to the maximum of overflow before the end of
* the match. */
chrono_ov_count_ = CHRONO_MATCH_OVERFLOW_COUNT;
@@ -77,7 +85,7 @@ void
chrono_update (void)
{
/* Decrement overflow counter if it is possible. */
- if (chrono_ov_count_)
+ if (chrono_enabled_ && chrono_ov_count_)
chrono_ov_count_--;
}
@@ -90,6 +98,24 @@ chrono_is_match_over (void)
return 1;
}
+void
+chrono_enable (void)
+{
+ chrono_enabled_ = 1;
+}
+
+void
+chrono_disable (void)
+{
+ chrono_enabled_ = 0;
+}
+
+uint8_t
+chrono_enabled (void)
+{
+ return chrono_enabled_;
+}
+
uint32_t
chrono_remaining_time (void)
{