summaryrefslogtreecommitdiff
path: root/src/bwbootloader/timer.h
diff options
context:
space:
mode:
authorNicolas Schodet2010-06-17 00:44:17 +0200
committerNicolas Schodet2010-06-20 19:09:38 +0200
commit9c9b1e87e7bca6ba0c5c101b0b76a514a820ea7c (patch)
tree89b791b65ca2d4f9283abe899957e792cab7c65f /src/bwbootloader/timer.h
parent35370c5301abeede6017e971a44c7b3200d40aa7 (diff)
bwbootloader: add start delay
Diffstat (limited to 'src/bwbootloader/timer.h')
-rw-r--r--src/bwbootloader/timer.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/bwbootloader/timer.h b/src/bwbootloader/timer.h
new file mode 100644
index 0000000..8f03a86
--- /dev/null
+++ b/src/bwbootloader/timer.h
@@ -0,0 +1,54 @@
+#ifndef timer_h
+#define timer_h
+/* timer.h */
+/* binwatch - Tiny binary wristwatch. {{{
+ *
+ * Copyright (C) 2010 Nicolas Schodet
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Contact :
+ * Web: http://ni.fr.eu.org/
+ * Email: <nico at ni.fr.eu.org>
+ * }}} */
+
+static inline void
+timer_init (void)
+{
+ TCCR0B = 0b101;
+}
+
+static inline void
+timer_uninit (void)
+{
+ TCCR0B = 0;
+ TCNT0 = 0;
+ GTCCR = _BV (PSR0);
+ TIFR = _BV (TOV0);
+}
+
+static inline uint8_t
+timer_overflowed (void)
+{
+ if (TIFR & _BV (TOV0))
+ {
+ TIFR = _BV (TOV0);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#endif /* timer_h */