summaryrefslogtreecommitdiff
path: root/nuttx/configs/ne64badge/src/up_buttons.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/configs/ne64badge/src/up_buttons.c')
-rwxr-xr-xnuttx/configs/ne64badge/src/up_buttons.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/nuttx/configs/ne64badge/src/up_buttons.c b/nuttx/configs/ne64badge/src/up_buttons.c
index 2472b6694..ec43c3bed 100755
--- a/nuttx/configs/ne64badge/src/up_buttons.c
+++ b/nuttx/configs/ne64badge/src/up_buttons.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * configs/ne64badge/src/up_leds.c
+ * configs/ne64badge/src/up_buttons.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@@ -50,6 +50,34 @@
* Definitions
****************************************************************************/
+/* Enables debug output from this file (needs CONFIG_DEBUG with
+ * CONFIG_DEBUG_VERBOSE too)
+ */
+
+#undef BUTTON_DEBUG /* Define to enable debug */
+#undef BUTTON_VERBOSE /* Define to enable verbose debug */
+
+#ifdef BUTTON_DEBUG
+# define btndbg lldbg
+# ifdef BUTTON_VERBOSE
+# define btnvdbg lldbg
+# else
+# define btnvdbg(x...)
+# endif
+#else
+# undef BUTTON_VERBOSE
+# define btndbg(x...)
+# define btnvdbg(x...)
+#endif
+
+/* Dump GPIO registers */
+
+#ifdef BUTTON_VERBOSE
+# define btn_dumpgpio(m) m9s12_dumpgpio(m)
+#else
+# define btn_dumpgpio(m)
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -68,6 +96,14 @@
void up_buttoninit(void)
{
+ /* Configure all button GPIO lines */
+
+ btn_dumpgpio("up_buttoninit() Entry)");
+
+ hcs12_configgpio(NE64BADGE_BUTTON1);
+ hcs12_configgpio(NE64BADGE_BUTTON2);
+
+ btn_dumpgpio("up_buttoninit() Exit");
}
/****************************************************************************
@@ -76,7 +112,19 @@ void up_buttoninit(void)
uint8_t up_buttons(void)
{
- return 0;
+ uint8_t ret = 0;
+
+ if (hcs12_gpioread(NE64BADGE_BUTTON1))
+ {
+ ret |= BUTTON1;
+ }
+
+ if (hcs12_gpioread(NE64BADGE_BUTTON2))
+ {
+ ret |= BUTTON2;
+ }
+
+ return ret;
}
#endif /* CONFIG_ARCH_BUTTONS */