summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-04-30 14:05:44 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-04-30 14:05:44 -0600
commitbc484165db04a5c4c8bcfbce28e48eb3d6a11cbb (patch)
treebc858da2be851749fd9ff99571cfe144b2844410
parentc45aa638678d72635e08ede22bf775013034522a (diff)
downloadnuttx-bc484165db04a5c4c8bcfbce28e48eb3d6a11cbb.tar.gz
nuttx-bc484165db04a5c4c8bcfbce28e48eb3d6a11cbb.tar.bz2
nuttx-bc484165db04a5c4c8bcfbce28e48eb3d6a11cbb.zip
SAM4S Xplained Pro: update LED conrol logic. From Bob Doiron
-rw-r--r--nuttx/configs/sam4s-xplained-pro/include/board.h12
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c42
-rw-r--r--nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c4
3 files changed, 36 insertions, 22 deletions
diff --git a/nuttx/configs/sam4s-xplained-pro/include/board.h b/nuttx/configs/sam4s-xplained-pro/include/board.h
index a4e008b5d..a28238e8d 100644
--- a/nuttx/configs/sam4s-xplained-pro/include/board.h
+++ b/nuttx/configs/sam4s-xplained-pro/include/board.h
@@ -222,12 +222,12 @@
#define LED_STARTED 0 /* NuttX has been started OFF */
#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
-#define LED_STACKCREATED 0 /* Idle stack created ON */
-#define LED_INIRQ 0 /* In an interrupt No change */
-#define LED_SIGNAL 0 /* In a signal handler No change */
-#define LED_ASSERTION 0 /* An assertion failed No change */
-#define LED_PANIC 0 /* The system has crashed OFF */
-#define LED_IDLE 0 /* MCU is is sleep mode Not used */
+#define LED_STACKCREATED 1 /* Idle stack created ON */
+#define LED_INIRQ 2 /* In an interrupt OFF */
+#define LED_SIGNAL 2 /* In a signal handler OFF */
+#define LED_ASSERTION 4 /* An assertion failed No change */
+#define LED_PANIC 3 /* The system has crashed Flash @ 250ms */
+#define LED_IDLE 4 /* MCU is is sleep mode Not used */
/* Thus if D301 is statically on, NuttX has successfully booted and is,
* apparently, running normmally.
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c b/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
index a06be9ab4..4921a5301 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_autoleds.c
@@ -65,7 +65,7 @@
* LED_STARTED NuttX has been started OFF
* LED_HEAPALLOCATE Heap has been allocated OFF
* LED_IRQSENABLED Interrupts enabled OFF
- * LED_STACKCREATED Idle stack created ON
+ * LED_STACKCREATED Idle stack created ON
* LED_INIRQ In an interrupt No change
* LED_SIGNAL In a signal handler No change
* LED_ASSERTION An assertion failed No change
@@ -73,6 +73,9 @@
* LED_IDLE MCU is is sleep mode Not used
*/
+#define LED_OFF true /* GPIO high for OFF */
+#define LED_ON false /* GPIO low for ON */
+
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
@@ -114,26 +117,28 @@ void board_led_initialize(void)
void board_led_on(int led)
{
- bool led1on = false;
-
switch (led)
{
- case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */
+ case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED - off while initializing */
+ sam_gpiowrite(GPIO_D301, LED_OFF);
break;
- case 1: /* LED_STACKCREATED */
- led1on = true;
+ case 1: /* LED_STACKCREATED - turn on when ready */
+ sam_gpiowrite(GPIO_D301, LED_ON);
break;
- default:
- case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
+ case 2: /* LED_INIRQ, LED_SIGNAL - turn off inside irqs/signal processing */
+ sam_gpiowrite(GPIO_D301, LED_OFF);
return;
- case 3: /* LED_PANIC */
+ case 3: /* LED_PANIC - flash */
+ sam_gpiowrite(GPIO_D301, LED_ON);
+ break;
+
+ default:
break;
}
- sam_gpiowrite(GPIO_D301, led1on);
}
/****************************************************************************
@@ -142,10 +147,19 @@ void board_led_on(int led)
void board_led_off(int led)
{
- if (led != 2)
- {
- sam_gpiowrite(GPIO_D301, false);
- }
+ switch (led)
+ {
+ default:
+ break;
+
+ case 2: /* LED_INIRQ, LED_SIGNAL - return to on after irq/signal processing */
+ sam_gpiowrite(GPIO_D301, LED_ON);
+ return;
+
+ case 3: /* LED_PANIC - flashes */
+ sam_gpiowrite(GPIO_D301, LED_OFF);
+ break;
+ }
}
#endif /* CONFIG_ARCH_LEDS */
diff --git a/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c b/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
index a0c8a092f..ead93669f 100644
--- a/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
+++ b/nuttx/configs/sam4s-xplained-pro/src/sam_userleds.c
@@ -116,7 +116,7 @@ void sam_setled(int led, bool ledon)
return;
}
- sam_gpiowrite(ledcfg, ledon);
+ sam_gpiowrite(ledcfg, !ledon); /* 0 = on, 1 = off */
}
/****************************************************************************
@@ -128,7 +128,7 @@ void sam_setleds(uint8_t ledset)
bool ledon;
ledon = ((ledset & BOARD_D301_BIT) != 0);
- sam_gpiowrite(GPIO_D301, ledon);
+ sam_gpiowrite(GPIO_D301, !ledon); /* 0 = on, 1 = off */
}
#endif /* !CONFIG_ARCH_LEDS */