summaryrefslogtreecommitdiff
path: root/nuttx/configs/ne64badge/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-02-26 16:55:39 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-02-26 16:55:39 +0000
commitaebc66f8e146b28148f5e5755f6b3252774441f8 (patch)
tree92a85e68ccfe7771cb3684247ac04c4877fbe4e8 /nuttx/configs/ne64badge/src
parent11cdbe3e35d80775ba9887a995a1e3c124c7a063 (diff)
downloadpx4-nuttx-aebc66f8e146b28148f5e5755f6b3252774441f8.tar.gz
px4-nuttx-aebc66f8e146b28148f5e5755f6b3252774441f8.tar.bz2
px4-nuttx-aebc66f8e146b28148f5e5755f6b3252774441f8.zip
Finish m9s12 GPIO support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3318 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/ne64badge/src')
-rwxr-xr-xnuttx/configs/ne64badge/src/ne64badge_internal.h24
-rwxr-xr-xnuttx/configs/ne64badge/src/up_buttons.c52
-rwxr-xr-xnuttx/configs/ne64badge/src/up_leds.c56
3 files changed, 121 insertions, 11 deletions
diff --git a/nuttx/configs/ne64badge/src/ne64badge_internal.h b/nuttx/configs/ne64badge/src/ne64badge_internal.h
index c1ba3145b..7cba3a91c 100755
--- a/nuttx/configs/ne64badge/src/ne64badge_internal.h
+++ b/nuttx/configs/ne64badge/src/ne64badge_internal.h
@@ -44,6 +44,8 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
+#include "m9s12_internal.h"
+
/************************************************************************************
* Definitions
************************************************************************************/
@@ -93,8 +95,11 @@
* 40 PE5/IPIPE0/MODA J3 MODA " " " " "" " "
* 39 PE6/IPIPE1/MODB J3 MODB " " " " "" " "
* 38 PE7/NOACC/XCLKS_B pulled low pulled low
- *
- * 97 PK0/XADR14 N/C N/C
+ */
+
+#define NE64BADGE_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT_E | GPIO_PIN_0)
+
+/* 97 PK0/XADR14 N/C N/C
* 98 PK1/XADR15 N/C N/C
* 99 PK2/XADR16 N/C N/C
* 100 PK3/XADR17 N/C N/C
@@ -135,15 +140,22 @@
* 3 PH4/TXCLK/KWH4 BUTTON2 SW2
* 2 PH5/TXDV/KWH5 J5 XBEE_LOAD_H Not used on board
* 1 PH6/TXER/KWH6 J4 XBEE_LOAD_L Not used on board
- *
- * 8 PJ0/MDC/KWJ0 LED1 D21, red
+ */
+
+#define NE64BADGE_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT_H | GPIO_PIN_4)
+
+/* 8 PJ0/MDC/KWJ0 LED1 D21, red
* 9 PJ1/MDIO/KWJ1 LED2 D22, red
* 20 PJ2/CRS/KWJ2 J3 SPI_CS Not used on board
* 21 PJ3/COL/KWJ3 N/C
* 112 PJ6/SDA/KWJ6 J3 I2C_DATA Not used on board
* 111 PJ7/SCL/KWJ7 J3 I2C_CLOCK " " " " "" " "
- *
- * 51 PL6/TXER/KWL6 N/C N/C
+ */
+
+#define NE64BADGE_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_HIGH | GPIO_PORT_J | GPIO_PIN_0)
+#define NE64BADGE_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_HIGH | GPIO_PORT_J | GPIO_PIN_1)
+
+/* 51 PL6/TXER/KWL6 N/C N/C
* 52 PL5/TXDV/KWL5 N/C N/C
* 58 PL4/COLLED Collision LED red
* 59 PL3/DUPLED Full Duplex LED yellow
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 */
diff --git a/nuttx/configs/ne64badge/src/up_leds.c b/nuttx/configs/ne64badge/src/up_leds.c
index 3a0bda836..e6660b0c0 100755
--- a/nuttx/configs/ne64badge/src/up_leds.c
+++ b/nuttx/configs/ne64badge/src/up_leds.c
@@ -46,6 +46,8 @@
#include "ne64badge_internal.h"
+#ifdef CONFIG_ARCH_LEDS
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -54,16 +56,30 @@
* CONFIG_DEBUG_VERBOSE too)
*/
-#undef LED_DEBUG /* Define to enable debug */
+#undef LED_DEBUG /* Define to enable debug */
+#undef LED_VERBOSE /* Define to enable verbose debug */
#ifdef LED_DEBUG
# define leddbg lldbg
-# define ledvdbg llvdbg
+# ifdef LED_VERBOSE
+# define ledvdbg lldbg
+# else
+# define ledvdbg(x...)
+# endif
#else
+# undef LED_VERBOSE
# define leddbg(x...)
# define ledvdbg(x...)
#endif
+/* Dump GPIO registers */
+
+#ifdef LED_VERBOSE
+# define led_dumpgpio(m) m9s12_dumpgpio(m)
+#else
+# define led_dumpgpio(m)
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -84,9 +100,16 @@
*
****************************************************************************/
-#ifdef CONFIG_ARCH_LEDS
void up_ledinit(void)
{
+ /* Configure all LED GPIO lines */
+
+ led_dumpgpio("up_ledinit() Entry)");
+
+ hcs12_configgpio(NE64BADGE_LED1);
+ hcs12_configgpio(NE64BADGE_LED2);
+
+ led_dumpgpio("up_ledinit() Exit");
}
/****************************************************************************
@@ -95,6 +118,23 @@ void up_ledinit(void)
void up_ledon(int led)
{
+ switch (led)
+ {
+ default:
+ case 0 : /* STARTED, HEAPALLOCATE, IRQSENABLED */
+ hcs12_gpiowrite(NE64BADGE_LED1, true);
+ hcs12_gpiowrite(NE64BADGE_LED2, true);
+ break;
+
+ case 1 : /* STACKCREATED */
+ hcs12_gpiowrite(NE64BADGE_LED1, false);
+ hcs12_gpiowrite(NE64BADGE_LED2, true);
+ break;
+
+ case 2 : /* INIRQ, SIGNAL, ASSERTION, PANIC */
+ hcs12_gpiowrite(NE64BADGE_LED2, false);
+ break;
+ }
}
/****************************************************************************
@@ -103,6 +143,16 @@ void up_ledon(int led)
void up_ledoff(int led)
{
+ switch (led)
+ {
+ default:
+ case 0 : /* STARTED, HEAPALLOCATE, IRQSENABLED */
+ case 1 : /* STACKCREATED */
+ hcs12_gpiowrite(NE64BADGE_LED1, true);
+ case 2 : /* INIRQ, SIGNAL, ASSERTION, PANIC */
+ hcs12_gpiowrite(NE64BADGE_LED2, true);
+ break;
+ }
}
#endif /* CONFIG_ARCH_LEDS */