ZKIT-ARM-1769: LED1 is now user controllable. From Rashid Fatah
This commit is contained in:
parent
773a693ee2
commit
8f57ee9e07
@ -5617,4 +5617,6 @@
|
|||||||
endpoint from 0xff (invalid) to 10. This is not a critical change
|
endpoint from 0xff (invalid) to 10. This is not a critical change
|
||||||
but will avoid a complaint from the Linux driver when it overrides
|
but will avoid a complaint from the Linux driver when it overrides
|
||||||
the 0xff value (2013-9-22).
|
the 0xff value (2013-9-22).
|
||||||
|
* configs/zkit-arm-1769: LED1 is not user controllable after booting.
|
||||||
|
From Rashid Fatah (2013-9-23).
|
||||||
|
|
||||||
|
@ -161,16 +161,22 @@
|
|||||||
* on board the ZKIT-ARM-1769. The following definitions
|
* on board the ZKIT-ARM-1769. The following definitions
|
||||||
* describe how NuttX controls the LEDs:
|
* describe how NuttX controls the LEDs:
|
||||||
*/
|
*/
|
||||||
/* LED1 LED2 */
|
|
||||||
#define LED_STARTED 0 /* OFF OFF = Still initializing */
|
/* LED1 LED2 */
|
||||||
#define LED_HEAPALLOCATE 0 /* OFF OFF = Still initializing */
|
#define LED_STARTED 0 /* OFF OFF */
|
||||||
#define LED_IRQSENABLED 0 /* OFF OFF = Still initializing */
|
#define LED_HEAPALLOCATE 1 /* ON OFF */
|
||||||
#define LED_STACKCREATED 1 /* ON OFF = Initialization complete */
|
#define LED_IRQSENABLED 2 /* OFF ON */
|
||||||
#define LED_INIRQ 2 /* N/C ON = In an interrupt handler */
|
#define LED_STACKCREATED 3 /* OFF OFF */
|
||||||
#define LED_SIGNAL 2 /* N/C ON = In a signal handler (glowing) */
|
|
||||||
#define LED_ASSERTION 2 /* N/C ON = In an assertion */
|
/* After the system is booted, this logic will no longer use LED 1.
|
||||||
#define LED_PANIC 2 /* N/C ON = Oops! We crashed. (flashing) */
|
* LED 1 is available for use by application software using lpc17_led
|
||||||
#define LED_IDLE 3 /* OFF N/C = LPC17 in sleep mode (LED1 glowing) */
|
* (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 ***************************************************************/
|
/* Button definitions ***************************************************************/
|
||||||
/* The ZKIT-ARM-1769 supports several buttons. All will read "1" when open and "0"
|
/* 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_RD GPIO_CAN1_RD_1
|
||||||
#define GPIO_CAN1_TD GPIO_CAN1_TD_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_CAN2_TD GPIO_CAN2_TD_2
|
||||||
#define GPIO_I2C1_SDA GPIO_I2C0_SDA
|
#define GPIO_I2C1_SDA GPIO_I2C0_SDA
|
||||||
#define GPIO_I2C1_SCL GPIO_I2C0_SCL
|
#define GPIO_I2C1_SCL GPIO_I2C0_SCL
|
||||||
@ -336,6 +342,18 @@ extern "C" {
|
|||||||
|
|
||||||
void lpc17_boardinitialize(void);
|
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
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
@ -80,7 +82,30 @@
|
|||||||
* Private Data
|
* 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
|
* Private Functions
|
||||||
@ -100,7 +125,6 @@ void up_ledinit(void)
|
|||||||
|
|
||||||
lpc17_configgpio(ZKITARM_LED1);
|
lpc17_configgpio(ZKITARM_LED1);
|
||||||
lpc17_configgpio(ZKITARM_LED2);
|
lpc17_configgpio(ZKITARM_LED2);
|
||||||
g_ncstate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -109,26 +133,48 @@ void up_ledinit(void)
|
|||||||
|
|
||||||
void up_ledon(int led)
|
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)
|
switch (led)
|
||||||
{
|
{
|
||||||
case 0:
|
case LED_INIRQ:
|
||||||
case 2:
|
case LED_SIGNAL:
|
||||||
off = true;
|
case LED_ASSERTION:
|
||||||
break;
|
case LED_PANIC:
|
||||||
|
lpc17_gpiowrite(ZKITARM_LED2, false);
|
||||||
case 1:
|
g_nestcount++;
|
||||||
off = false;
|
|
||||||
g_ncstate = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
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)
|
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:
|
lpc17_led(ZKITARM_LED2, true);
|
||||||
case 1:
|
g_nestcount = 0;
|
||||||
off = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
off = g_ncstate;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
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 */
|
#endif /* CONFIG_ARCH_LEDS */
|
||||||
|
Loading…
Reference in New Issue
Block a user