From 3e529d139980d2ad292c8e0f2bc0ac6117a95bd1 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 8 Nov 2008 15:12:56 +0000 Subject: [PATCH] Initial vector handling logic git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1166 42af7a65-404d-4744-a932-0658087f49c3 --- configs/us7032evb1/include/board.h | 16 ++++---- configs/us7032evb1/ostest/ld.script | 1 + configs/us7032evb1/src/up_leds.c | 57 ++++++++++++++++++++++++----- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/configs/us7032evb1/include/board.h b/configs/us7032evb1/include/board.h index c481b14b62..e73022b621 100644 --- a/configs/us7032evb1/include/board.h +++ b/configs/us7032evb1/include/board.h @@ -55,18 +55,18 @@ /* LED definitions **********************************************************/ -/* The SH1_LPEVB has no user controllable LEDs. These are provided only - * in the event that CONFIG_ARCH_LEDs is enabled. +/* The SH1_LPEVB only a single LED controlled by either port A, pin 15, or + * port B, pin 15 (selectable via JP8). */ #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_IRQSENABLED 1 +#define LED_STACKCREATED 1 +#define LED_INIRQ 0 +#define LED_SIGNAL 0 +#define LED_ASSERTION 0 +#define LED_PANIC 1 /* Button definitions *******************************************************/ diff --git a/configs/us7032evb1/ostest/ld.script b/configs/us7032evb1/ostest/ld.script index 846fda4c6e..60436cff14 100644 --- a/configs/us7032evb1/ostest/ld.script +++ b/configs/us7032evb1/ostest/ld.script @@ -54,6 +54,7 @@ SECTIONS . = 0x0a002400; .text : { _stext = ABSOLUTE(.); + *(.reset) /* Reset/IRQ code */ *(.text) /* Code */ *(.fixup) *(.gnu.warning) diff --git a/configs/us7032evb1/src/up_leds.c b/configs/us7032evb1/src/up_leds.c index 2e711471a2..3212993097 100644 --- a/configs/us7032evb1/src/up_leds.c +++ b/configs/us7032evb1/src/up_leds.c @@ -48,6 +48,15 @@ * Definitions ****************************************************************************/ +/* The SH1_LPEVB only a single LED controlled by either port A, pin 15, or + * port B, pin 15 (selectable via JP8). In this file, we assume the portB + * setup. + */ + +#define SH1_PBDR_LED 0x8000 +#define SH1_PBIOR_LED 0x8000 +#define SH1_PBCR2_LED 0xc000 + /**************************************************************************** * Private Data ****************************************************************************/ @@ -67,9 +76,25 @@ #ifdef CONFIG_ARCH_LEDS void up_ledinit(void) { - /* The SH1_LPEVB has no user controllable LEDs. This is provided only - * in the event that CONFIG_ARCH_LEDs is enabled. - */ + uint16 reg16; + + /* Setup port B, pin 15 as an output */ + + reg16 = getreg(SH1_PFC_PBIOR); + reg16 |= SH1_PBIOR_LED; + putreg(reg16, SH1_PFC_PBIOR); + + /* Setup port B, pin 15 as a normal I/O register */ + + reg16 = getreg(SH1_PFC_PBCR1); + reg16 &= ~SH1_PBCR2_LED; + putreg(reg16, SH1_PFC_PBCR1); + + /* Turn the LED off */ + + reg16 = getreg(SH1_PORTB_DR); + reg16 &= ~SH1_PBDR_LED; + putreg(reg16, SH1_PORTB_DR); } /**************************************************************************** @@ -78,9 +103,16 @@ void up_ledinit(void) void up_ledon(int led) { - /* The SH1_LPEVB has no user controllable LEDs. This is provided only - * in the event that CONFIG_ARCH_LEDs is enabled. - */ + uint16 reg16; + + if (led) + { + /* Turn the LED on */ + + reg16 = getreg(SH1_PORTB_DR); + reg16 |= SH1_PBDR_LED; + putreg(reg16, SH1_PORTB_DR); + } } /**************************************************************************** @@ -89,8 +121,15 @@ void up_ledon(int led) void up_ledoff(int led) { - /* The SH1_LPEVB has no user controllable LEDs. This is provided only - * in the event that CONFIG_ARCH_LEDs is enabled. - */ + uint16 reg16; + + if (led) + { + /* Turn the LED off */ + + reg16 = getreg(SH1_PORTB_DR); + reg16 &= ~SH1_PBDR_LED; + putreg(reg16, SH1_PORTB_DR); + } } #endif /* CONFIG_ARCH_LEDS */