Add control for Nucleus2g GPIOs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2742 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
cbfefda2f3
commit
3ad9fa0557
@ -122,16 +122,22 @@
|
||||
#define BOARD_FLASHCFG_VALUE 0x0000303a
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
/* The Nucleus2G has 3 LEDs... two on the Babel CAN board and a "heartbeat" LED."
|
||||
* The LEDs on the Babel CAN board are capabl of OFF/GREEN/RED/AMBER status.
|
||||
* In normal usage, the two LEDs on the Babel CAN board would show CAN status, but if
|
||||
* CONFIG_ARCH_LEDS is defined, these LEDs will be controlled as follows for NuttX
|
||||
* debug functionality (where NC means "No Change").
|
||||
*
|
||||
/* LED1 LED2 HEARTBEAT */
|
||||
#define LED_STARTED 0 /* OFF OFF OFF */
|
||||
#define LED_HEAPALLOCATE 1 /* GREEN OFF OFF */
|
||||
#define LED_IRQSENABLED 2 /* OFF GREEN OFF */
|
||||
#define LED_STACKCREATED 3 /* GREEN GREEN OFF */
|
||||
|
||||
#define LED_STARTED 0
|
||||
#define LED_HEAPALLOCATE 1
|
||||
#define LED_IRQSENABLED 2
|
||||
#define LED_STACKCREATED 3
|
||||
|
||||
#define LED_INIRQ 4
|
||||
#define LED_SIGNAL 5
|
||||
#define LED_ASSERTION 6
|
||||
#define LED_PANIC 7
|
||||
#define LED_INIRQ 4 /* NC NC ON */
|
||||
#define LED_SIGNAL 5 /* NC RED NC */
|
||||
#define LED_ASSERTION 6 /* RED NC NC */
|
||||
#define LED_PANIC 7 /* RED RED NC (1Hz flashing) */
|
||||
|
||||
/* Alternate pin selections *********************************************************/
|
||||
|
||||
|
@ -100,10 +100,24 @@
|
||||
* P2[11]/EINT1/I2STX_CLK HEARTBEAT
|
||||
* P2[12]/EINT2/I2STX_WS EXTRA_LED
|
||||
* P2[13]/EINT3/I2STX_SDA 5V_ENABLE
|
||||
*
|
||||
* P3[25]-P3[26] Not connected
|
||||
*
|
||||
* P4[28]-P4[29] P4[28]-P4[29]
|
||||
*/
|
||||
|
||||
P3[25]-P3[26] Not connected
|
||||
#define NUCLEUS2G_LED1_A (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN0)
|
||||
#define NUCLEUS2G_LED1_B (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN1)
|
||||
#define NUCLEUS2G_LED2_A (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN2)
|
||||
#define NUCLEUS2G_LED2_B (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN3)
|
||||
#define NUCLEUS2G_232_ENABLE (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN5)
|
||||
#define NUCLEUS2G_232_POWERSAVE (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN5)
|
||||
#define NUCLEUS2G_232_VALID (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN5)
|
||||
#define NUCLEUS2G_HEARTBEAT (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN11)
|
||||
#define NUCLEUS2G_EXTRA_LED (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN12)
|
||||
#define NUCLEUS2G_5V_ENABLE (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT2 | GPIO_PIN13)
|
||||
#define NUCLEUS2G_5V_DISABLE (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT2 | GPIO_PIN13)
|
||||
|
||||
P4[28]-P4[29] P4[28]-P4[29]
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
#include "lpc17_internal.h"
|
||||
#include "nucleus2g_internal.h"
|
||||
|
||||
/************************************************************************************
|
||||
@ -72,6 +74,22 @@
|
||||
|
||||
void lpc17_boardinitialize(void)
|
||||
{
|
||||
/* Enable +5V needed for CAN */
|
||||
|
||||
#if defined(CONFIG_LPC17_CAN1) || defined(CONFIG_LPC17_CAN2)
|
||||
lpc17_configgpio(NUCLEUS2G_5V_ENABLE);
|
||||
#else
|
||||
lpc17_configgpio(NUCLEUS2G_5V_DISABLE);
|
||||
#endif
|
||||
|
||||
/* If UART0 is used, enabled the MAX232 driver */
|
||||
|
||||
#ifdef CONFIG_LPC17_UART0
|
||||
lpc17_configgpio(NUCLEUS2G_232_ENABLE);
|
||||
#else
|
||||
lpc17_configgpio(NUCLEUS2G_232_POWERSAVE);
|
||||
#endif
|
||||
|
||||
/* Configure SPI chip selects if 1) SPI is not disabled, and 2) the weak function
|
||||
* lpc17_spiinitialize() has been brought into the link.
|
||||
*/
|
||||
|
@ -49,7 +49,9 @@
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
#include "lpc17_internal.h"
|
||||
|
||||
#include "nucleus2g_internal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
@ -58,6 +60,17 @@
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LED_OFF 0
|
||||
#define LED_ON 1
|
||||
#define LED_GREEN 2
|
||||
#define LED_PLUSGREEN 3
|
||||
#define LED_MINUSGREEN 4
|
||||
#define LED_RED 5
|
||||
#define LED_PLUSRED 6
|
||||
#define LED_MINUSRED 7
|
||||
#define LED_NC 8
|
||||
#define LED_PREV 9
|
||||
|
||||
/* Enables debug output from this file (needs CONFIG_DEBUG with
|
||||
* CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
@ -76,10 +89,188 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const uint8_t g_led1on[8] =
|
||||
{
|
||||
LED_OFF, LED_GREEN, LED_OFF, LED_GREEN,
|
||||
LED_NC, LED_NC, LED_PLUSRED, LED_PLUSRED
|
||||
};
|
||||
|
||||
static const uint8_t g_led1off[8] =
|
||||
{
|
||||
LED_OFF, LED_OFF, LED_GREEN, LED_OFF,
|
||||
LED_NC, LED_NC, LED_MINUSRED, LED_PREV
|
||||
};
|
||||
|
||||
static const uint8_t g_led2on[8] =
|
||||
{
|
||||
LED_OFF, LED_OFF, LED_GREEN, LED_GREEN,
|
||||
LED_NC, LED_PLUSRED, LED_NC, LED_PLUSRED
|
||||
};
|
||||
|
||||
static const uint8_t g_led2off[8] =
|
||||
{
|
||||
LED_OFF, LED_OFF, LED_OFF, LED_GREEN,
|
||||
LED_NC, LED_MINUSRED, LED_NC, LED_PREV
|
||||
};
|
||||
|
||||
static const uint8_t g_ledhbon[8] =
|
||||
{
|
||||
LED_OFF, LED_OFF, LED_OFF, LED_OFF,
|
||||
LED_ON, LED_NC, LED_NC, LED_NC
|
||||
};
|
||||
|
||||
static const uint8_t g_ledhboff[8] =
|
||||
{
|
||||
LED_OFF, LED_OFF, LED_OFF, LED_OFF,
|
||||
LED_OFF, LED_NC, LED_NC, LED_NC
|
||||
};
|
||||
|
||||
static bool g_prevled1a;
|
||||
static bool g_currled1a;
|
||||
static bool g_prevled1b;
|
||||
static bool g_currled1b;
|
||||
static bool g_prevled2a;
|
||||
static bool g_currled2a;
|
||||
static bool g_prevled2b;
|
||||
static bool g_currled2b;
|
||||
static bool g_prevledhb;
|
||||
static bool g_currledhb;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_led1
|
||||
****************************************************************************/
|
||||
|
||||
void up_led1(uint8_t newstate)
|
||||
{
|
||||
bool led1a = false;
|
||||
bool led1b = false;
|
||||
|
||||
switch (newstate)
|
||||
{
|
||||
default:
|
||||
case LED_OFF:
|
||||
case LED_ON:
|
||||
break;
|
||||
|
||||
case LED_GREEN:
|
||||
led1b = true;
|
||||
break;
|
||||
|
||||
case LED_PLUSGREEN:
|
||||
led1b = true;
|
||||
case LED_MINUSGREEN:
|
||||
led1a = g_currled1a;
|
||||
break;
|
||||
|
||||
case LED_RED:
|
||||
break;
|
||||
|
||||
case LED_PLUSRED:
|
||||
led1a = true;
|
||||
case LED_MINUSRED:
|
||||
led1b = g_currled1b;
|
||||
break;
|
||||
|
||||
case LED_NC:
|
||||
led1a = g_currled1a;
|
||||
led1b = g_currled1b;
|
||||
break;
|
||||
|
||||
case LED_PREV:
|
||||
led1a = g_prevled1a;
|
||||
led1b = g_prevled1b;
|
||||
break;
|
||||
}
|
||||
|
||||
lpc17_gpiowrite(NUCLEUS2G_LED1_A, led1a);
|
||||
lpc17_gpiowrite(NUCLEUS2G_LED1_B, led1b);
|
||||
g_prevled1a = g_currled1a;
|
||||
g_currled1a = led1a;
|
||||
g_prevled1b = g_currled1b;
|
||||
g_currled1b = led1b;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_led2
|
||||
****************************************************************************/
|
||||
|
||||
void up_led2(uint8_t newstate)
|
||||
{
|
||||
bool led2a = false;
|
||||
bool led2b = false;
|
||||
|
||||
switch (newstate)
|
||||
{
|
||||
default:
|
||||
case LED_OFF:
|
||||
case LED_ON:
|
||||
break;
|
||||
|
||||
case LED_GREEN:
|
||||
led2b = true;
|
||||
break;
|
||||
|
||||
case LED_PLUSGREEN:
|
||||
led2b = true;
|
||||
case LED_MINUSGREEN:
|
||||
led2a = g_currled2a;
|
||||
break;
|
||||
|
||||
case LED_RED:
|
||||
break;
|
||||
|
||||
case LED_PLUSRED:
|
||||
led2a = true;
|
||||
case LED_MINUSRED:
|
||||
led2b = g_currled2b;
|
||||
break;
|
||||
|
||||
case LED_NC:
|
||||
led2a = g_currled2a;
|
||||
led2b = g_currled2b;
|
||||
break;
|
||||
|
||||
case LED_PREV:
|
||||
led2a = g_prevled2a;
|
||||
led2b = g_prevled2b;
|
||||
break;
|
||||
}
|
||||
|
||||
lpc17_gpiowrite(NUCLEUS2G_LED2_A, led2a);
|
||||
lpc17_gpiowrite(NUCLEUS2G_LED2_B, led2b);
|
||||
g_prevled2a = g_currled2a;
|
||||
g_currled2a = led2a;
|
||||
g_prevled2b = g_currled2b;
|
||||
g_currled2b = led2b;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_led2
|
||||
****************************************************************************/
|
||||
|
||||
void up_ledhb(uint8_t newstate)
|
||||
{
|
||||
bool ledhb = false;
|
||||
|
||||
switch (newstate)
|
||||
{
|
||||
default:
|
||||
case LED_OFF:
|
||||
break;
|
||||
|
||||
case LED_ON:
|
||||
ledhb = true;
|
||||
break;
|
||||
}
|
||||
lpc17_gpiowrite(NUCLEUS2G_HEARTBEAT, ledhb);
|
||||
g_prevledhb = g_currledhb;
|
||||
g_currledhb = newstate;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -90,6 +281,14 @@
|
||||
|
||||
void up_ledinit(void)
|
||||
{
|
||||
/* Configure all LED GPIO lines */
|
||||
|
||||
lpc17_configgpio(NUCLEUS2G_LED1_A);
|
||||
lpc17_configgpio(NUCLEUS2G_LED1_B);
|
||||
lpc17_configgpio(NUCLEUS2G_LED2_A);
|
||||
lpc17_configgpio(NUCLEUS2G_LED2_B);
|
||||
lpc17_configgpio(NUCLEUS2G_HEARTBEAT);
|
||||
lpc17_configgpio(NUCLEUS2G_EXTRA_LED);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -98,6 +297,9 @@ void up_ledinit(void)
|
||||
|
||||
void up_ledon(int led)
|
||||
{
|
||||
up_led1(g_led1on[led]);
|
||||
up_led2(g_led2on[led]);
|
||||
up_ledhb(g_ledhbon[led]);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -106,6 +308,9 @@ void up_ledon(int led)
|
||||
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
up_led1(g_led1off[led]);
|
||||
up_led2(g_led2off[led]);
|
||||
up_ledhb(g_ledhboff[led]);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
Loading…
Reference in New Issue
Block a user