SAM4S Xplained Pro: update LED conrol logic. From Bob Doiron
This commit is contained in:
parent
020583efa2
commit
ae4584f0db
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
case 2: /* LED_INIRQ, LED_SIGNAL - turn off inside irqs/signal processing */
|
||||
sam_gpiowrite(GPIO_D301, LED_OFF);
|
||||
return;
|
||||
|
||||
case 3: /* LED_PANIC - flash */
|
||||
sam_gpiowrite(GPIO_D301, LED_ON);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
|
||||
return;
|
||||
|
||||
case 3: /* LED_PANIC */
|
||||
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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user