ZKIT-ARM-1769: LED1 is now user controllable. From Rashid Fatah
This commit is contained in:
parent
8f9c70da3b
commit
4a6c2b0c9d
@ -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)
|
||||
}
|
||||
|
@ -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. */
|
||||
|
||||
if (!g_initialized)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/* We will always control the HB LED */
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
off = true;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
off = false;
|
||||
g_ncstate = false;
|
||||
break;
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user