summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2010-07-18 23:52:32 +0200
committerNicolas Schodet2010-07-18 23:52:32 +0200
commit932c73a6405792aa134d122f946dbaa1bff696ff (patch)
tree89054773c9b38c953a5ecd01a48b491df4eb31d8
parentebfd74a1c078bd3e78a18fd723b3f1f572e7c1f0 (diff)
src/common: add button
-rw-r--r--src/common/button.c45
-rw-r--r--src/common/button.h35
2 files changed, 80 insertions, 0 deletions
diff --git a/src/common/button.c b/src/common/button.c
new file mode 100644
index 0000000..716941d
--- /dev/null
+++ b/src/common/button.c
@@ -0,0 +1,45 @@
+/* button.c */
+/* 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>
+ * }}} */
+#include "io.h"
+#include "button.h"
+
+/** Button port. */
+#define BUTTON_IO B, 1
+
+void
+button_init (void)
+{
+ /* Button is shared with leds, no PORT init. */
+}
+
+void
+button_wait (void)
+{
+ /* Wait until button is pressed. */
+ while (IO_GET (BUTTON_IO))
+ ;
+ /* Wait until button is released. */
+ while (!IO_GET (BUTTON_IO))
+ ;
+}
diff --git a/src/common/button.h b/src/common/button.h
new file mode 100644
index 0000000..e76211a
--- /dev/null
+++ b/src/common/button.h
@@ -0,0 +1,35 @@
+#ifndef button_h
+#define button_h
+/* button.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>
+ * }}} */
+
+/** Initialise button. */
+void
+button_init (void);
+
+/** Wait until the button is pressed and released. */
+void
+button_wait (void);
+
+#endif /* button_h */