summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-23 07:47:56 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-23 07:47:56 -0600
commita8a395338ce83c97e5ec1114777b64201c67a1af (patch)
tree85c8447d128497cca2750b05108705abd2832b89
parent560099443ce4381ff02e105e6e6d736f543e5f3c (diff)
downloadnuttx-a8a395338ce83c97e5ec1114777b64201c67a1af.tar.gz
nuttx-a8a395338ce83c97e5ec1114777b64201c67a1af.tar.bz2
nuttx-a8a395338ce83c97e5ec1114777b64201c67a1af.zip
ZKIT-ARM-1769: LED1 is now user controllable. From Rashid Fatah
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/configs/zkit-arm-1769/include/board.h40
-rw-r--r--nuttx/configs/zkit-arm-1769/src/up_leds.c113
3 files changed, 113 insertions, 42 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 15b158a99..589dd5c86 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5617,4 +5617,6 @@
endpoint from 0xff (invalid) to 10. This is not a critical change
but will avoid a complaint from the Linux driver when it overrides
the 0xff value (2013-9-22).
+ * configs/zkit-arm-1769: LED1 is not user controllable after booting.
+ From Rashid Fatah (2013-9-23).
diff --git a/nuttx/configs/zkit-arm-1769/include/board.h b/nuttx/configs/zkit-arm-1769/include/board.h
index 63dd4d914..fbaeff6d4 100644
--- a/nuttx/configs/zkit-arm-1769/include/board.h
+++ b/nuttx/configs/zkit-arm-1769/include/board.h
@@ -161,16 +161,22 @@
* on board the ZKIT-ARM-1769. The following definitions
* describe how NuttX controls the LEDs:
*/
- /* LED1 LED2 */
-#define LED_STARTED 0 /* OFF OFF = Still initializing */
-#define LED_HEAPALLOCATE 0 /* OFF OFF = Still initializing */
-#define LED_IRQSENABLED 0 /* OFF OFF = Still initializing */
-#define LED_STACKCREATED 1 /* ON OFF = Initialization complete */
-#define LED_INIRQ 2 /* N/C ON = In an interrupt handler */
-#define LED_SIGNAL 2 /* N/C ON = In a signal handler (glowing) */
-#define LED_ASSERTION 2 /* N/C ON = In an assertion */
-#define LED_PANIC 2 /* N/C ON = Oops! We crashed. (flashing) */
-#define LED_IDLE 3 /* OFF N/C = LPC17 in sleep mode (LED1 glowing) */
+
+ /* LED1 LED2 */
+#define LED_STARTED 0 /* OFF OFF */
+#define LED_HEAPALLOCATE 1 /* ON OFF */
+#define LED_IRQSENABLED 2 /* OFF ON */
+#define LED_STACKCREATED 3 /* OFF OFF */
+
+/* After the system is booted, this logic will no longer use LED 1.
+ * LED 1 is available for use by application software using lpc17_led
+ * (prototyped below)
+ */
+ /* LED1 LED2 */
+#define LED_INIRQ 4 /* NC ON (momentary) */
+#define LED_SIGNAL 5 /* NC ON (momentary) */
+#define LED_ASSERTION 6 /* NC ON (momentary) */
+#define LED_PANIC 7 /* NC ON (1Hz flashing) */
/* Button definitions ***************************************************************/
/* The ZKIT-ARM-1769 supports several buttons. All will read "1" when open and "0"
@@ -231,7 +237,7 @@
#define GPIO_CAN1_RD GPIO_CAN1_RD_1
#define GPIO_CAN1_TD GPIO_CAN1_TD_1
-#define GPIO_CAN2_RD GPIO_CAN2_RD_2
+#define GPIO_CAN2_RD GPIO_CAN2_RD_2
#define GPIO_CAN2_TD GPIO_CAN2_TD_2
#define GPIO_I2C1_SDA GPIO_I2C0_SDA
#define GPIO_I2C1_SCL GPIO_I2C0_SCL
@@ -336,6 +342,18 @@ extern "C" {
void lpc17_boardinitialize(void);
+/************************************************************************************
+ * Name: lpc17_led
+ *
+ * Description:
+ * Once the system has booted, these functions can be used to control LEDs 1
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_ARCH_LEDS
+void lpc17_led(int lednum, int state);
+#endif
+
#undef EXTERN
#if defined(__cplusplus)
}
diff --git a/nuttx/configs/zkit-arm-1769/src/up_leds.c b/nuttx/configs/zkit-arm-1769/src/up_leds.c
index 2b2dfb1e4..875c61fd7 100644
--- a/nuttx/configs/zkit-arm-1769/src/up_leds.c
+++ b/nuttx/configs/zkit-arm-1769/src/up_leds.c
@@ -48,6 +48,8 @@
#include <stdbool.h>
#include <debug.h>
+#include <arch/board/board.h>
+
#include "up_arch.h"
#include "up_internal.h"
@@ -80,7 +82,30 @@
* Private Data
****************************************************************************/
-static bool g_ncstate;
+/* LED definitions ******************************************************************
+
+/* The ZKit-ARM-1769 has 2 LEDs along the bottom of the board. Red or off.
+ * If CONFIG_ARCH_LEDS is defined, the LEDs will be controlled as follows for NuttX
+ * debug functionality (where NC means "No Change").
+ *
+ * During the boot phases. LED1 and LED2 will show boot status.
+ *
+ * LED1 LED2
+ * STARTED OFF OFF
+ * HEAPALLOCATE BLUE OFF
+ * IRQSENABLED OFF BLUE
+ * STACKCREATED OFF OFF
+ *
+ * After the system is booted, this logic will no longer use LED 1. LED 1
+ * is available for use by applications using lpc17_led (prototyped below)
+ */
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_initialized;
+static int g_nestcount;
/****************************************************************************
* Private Functions
@@ -100,7 +125,6 @@ void up_ledinit(void)
lpc17_configgpio(ZKITARM_LED1);
lpc17_configgpio(ZKITARM_LED2);
- g_ncstate = true;
}
/****************************************************************************
@@ -109,26 +133,48 @@ void up_ledinit(void)
void up_ledon(int led)
{
- bool off;
+ /* We will control LED1 and LED2 not yet completed the boot sequence. */
- switch (led)
+ if (!g_initialized)
{
- case 0:
- case 2:
- off = true;
- break;
+ bool led1 = false;
+ bool led2 = false;
+
+ switch (led)
+ {
+ case LED_STACKCREATED:
+ g_initialized = true;
+ case LED_STARTED:
+ default:
+ break;
+
+ case LED_HEAPALLOCATE:
+ led1 = true;
+ break;
+
+ case LED_IRQSENABLED:
+ led2 = true;
+ break;
+ }
+
+ lpc17_led(ZKITARM_LED1, led1);
+ lpc17_led(ZKITARM_LED2, led2);
+ }
- case 1:
- off = false;
- g_ncstate = false;
- break;
+ /* We will always control the HB LED */
+
+ switch (led)
+ {
+ case LED_INIRQ:
+ case LED_SIGNAL:
+ case LED_ASSERTION:
+ case LED_PANIC:
+ lpc17_gpiowrite(ZKITARM_LED2, false);
+ g_nestcount++;
default:
- return;
+ break;
}
-
- lpc17_gpiowrite(ZKITARM_LED1, off);
- lpc17_gpiowrite(ZKITARM_LED2, off);
}
/****************************************************************************
@@ -137,25 +183,30 @@ void up_ledon(int led)
void up_ledoff(int led)
{
- bool off;
+ /* In all states, OFF can only mean turning off the HB LED */
- switch (led)
+ if (g_nestcount <= 1)
{
- case 0:
- case 1:
- off = false;
- break;
-
- case 2:
- off = g_ncstate;
- break;
-
- default:
- return;
+ lpc17_led(ZKITARM_LED2, true);
+ g_nestcount = 0;
+ }
+ else
+ {
+ g_nestcount--;
}
+}
- lpc17_gpiowrite(ZKITARM_LED1, off);
- lpc17_gpiowrite(ZKITARM_LED2, off);
+/************************************************************************************
+ * Name: lpc17_led
+ *
+ * Description:
+ * Once the system has booted, this functions can be used to control LED 1
+ *
+ ************************************************************************************/
+
+void lpc17_led(int lednum, int state)
+{
+ lpc17_gpiowrite(ZKITARM_LED1, state);
}
#endif /* CONFIG_ARCH_LEDS */