From 6bd4075951c584e7d486299e3e5b5d2a5055e755 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 25 Dec 2015 15:19:09 -0600 Subject: [PATCH] LaunchXL-TMS57004: Add support for on-board LEDs and buttons --- configs/Kconfig | 3 + configs/launchxl-tms57004/README.txt | 47 +++++ configs/launchxl-tms57004/include/board.h | 65 ++++++ configs/launchxl-tms57004/nsh/defconfig | 15 +- configs/launchxl-tms57004/src/Makefile | 9 + .../launchxl-tms57004/src/launchxl-tms57004.h | 32 +++ .../launchxl-tms57004/src/tms570_autoleds.c | 139 ++++++++++++ .../launchxl-tms57004/src/tms570_bringup.c | 2 +- .../launchxl-tms57004/src/tms570_buttons.c | 199 ++++++++++++++++++ .../launchxl-tms57004/src/tms570_userleds.c | 87 ++++++++ configs/same70-xplained/README.txt | 8 +- 11 files changed, 600 insertions(+), 6 deletions(-) create mode 100644 configs/launchxl-tms57004/src/tms570_autoleds.c create mode 100644 configs/launchxl-tms57004/src/tms570_buttons.c create mode 100644 configs/launchxl-tms57004/src/tms570_userleds.c diff --git a/configs/Kconfig b/configs/Kconfig index 7811068bf5..b944743fb8 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -242,6 +242,9 @@ config ARCH_BOARD_KWIKSTIK_K40 config ARCH_BOARD_LAUNCHXL_TMS57004 bool "TI LaunchXL-TMS57004" depends on ARCH_CHIP_TMS570LS0432PZ + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS ---help--- TI Hercules TMS570LS04x/03x LaunchPad Evaluation Kit (LAUNCHXL- TMS57004) featuring the Hercules TMS570LS0432PZ chip. diff --git a/configs/launchxl-tms57004/README.txt b/configs/launchxl-tms57004/README.txt index a0e109b2e5..587f25f256 100644 --- a/configs/launchxl-tms57004/README.txt +++ b/configs/launchxl-tms57004/README.txt @@ -8,8 +8,55 @@ README Contents ^^^^^^^^ + LEDs and Buttons Serial Console +LEDs and Buttons +================ + + LEDs + ---- + The launchpad has a four LEDs two power LEDs labeled D1 (red) that + connects to the TMS570's NERROR pin and D7 (blue) that indicates the + XDS200 POWER_EN signal, and two white, user LEDs labeled D12 that + connects to the NHET08 pin and D11 that connects to GIOA2. + + NHET08 is one of 32 N2HET pins than can be available to the user if + not used by N2HET. This implementation, however, uses only the single + LED driven by GIOA2. That LED is tied to ground and illuminated + with a high level output value. + + This LED is not used by the board port unless CONFIG_ARCH_LEDS is + defined. In that case, the usage by the board port is defined in + include/board.h and src/tms570_autoleds.c. The LED is used to encode + OS-related events as follows: + + ------------------- ----------------------- ------ + SYMBOL Meaning LED + ------------------- ----------------------- ------ + 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_INIRQ In an interrupt N/C + LED_SIGNAL In a signal handler N/C + LED_ASSERTION An assertion failed N/C + LED_PANIC The system has crashed FLASH + + Thus if the LED is statically on, NuttX has successfully booted and is, + apparently, running normally. If the LED is flashing at approximately + 2Hz, then a fatal error has been detected and the system has halted. + + Buttons + ------- + The launchpad has three mechanical buttons. Two of these are reset buttons: + One button is labeled PORRST performs a power-on reset and one labeled RST + performs an MCU reset. Only one button is available for general software + usage. That button is labeled GIOA7 and is, obviously, sensed on GIOA7. + + GIOA7 is tied to ground, but will be pulled high if the GIOA7 button is + depressed. + Serial Console ^^^^^^^^^^^^^^ diff --git a/configs/launchxl-tms57004/include/board.h b/configs/launchxl-tms57004/include/board.h index fb78ca8748..456fd16522 100644 --- a/configs/launchxl-tms57004/include/board.h +++ b/configs/launchxl-tms57004/include/board.h @@ -179,8 +179,73 @@ PINMUX_MIBSPI1NCS1_PIN /* LED definitions ******************************************************************/ +/* LEDs + * + * The launchpad has a four LEDs two power LEDs labeled D1 (red) that connects to + * the TMS570's NERROR pin and D7 (blue) that indicates the XDS200 POWER_EN signal, + * and two white, user LEDs labeled D12 that connects to the NHET08 pin and D11 + * that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if not used by + * N2HET. This implementation, however, uses only the single LED driven by GIOA2. + * That LED is tied to ground and illuminated with a high level output value. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_D11 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_D11_BIT (1 << BOARD_LED_D11) + +/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/tms570_autoleds.c. The LED is used to encode + * OS-related events as follows: + */ + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/sam_autoleds.c. The LEDs are used to encode + * OS-related events as follows: + * + * ---------------------- ---------------------------- ------ + * SYMBOL Meaning LED + * ---------------------- ---------------------------- ------ */ + +#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 1 /* Idle stack created ON */ +#define LED_INIRQ 2 /* In an interrupt N/C */ +#define LED_SIGNAL 2 /* In a signal handler N/C */ +#define LED_ASSERTION 2 /* An assertion failed N/C */ +#define LED_PANIC 3 /* The system has crashed FLASH */ +#undef LED_IDLE /* MCU is is sleep mode Not used */ + +/* Thus if the LED is statically on, NuttX has successfully booted and is, + * apparently, running normally. If the LED is flashing at approximately + * 2Hz, then a fatal error has been detected and the system has halted. + */ /* Button definitions ***************************************************************/ +/* Buttons + * + * The launchpad has three mechanical buttons. Two of these are reset buttons: One + * button is labeled PORRST performs a power-on reset and one labeled RST performs + * an MCU reset. Only one button is available for general software usage. That + * button is labeled GIOA7 and is, obviously, sensed on GIOA7. + * + * GIOA7 is tied to ground, but will be pulled high if the GIOA7 button is + * depressed. + */ + +#define BUTTON_GIOA7 0 +#define NUM_BUTTONS 1 + +#define BUTTON_GIOA7_BIT (1 << BUTTON_GIOA7) /************************************************************************************ * Public Data diff --git a/configs/launchxl-tms57004/nsh/defconfig b/configs/launchxl-tms57004/nsh/defconfig index 588b4cd58b..d879faf59c 100644 --- a/configs/launchxl-tms57004/nsh/defconfig +++ b/configs/launchxl-tms57004/nsh/defconfig @@ -136,11 +136,14 @@ CONFIG_ARMV7R_MEMINIT=y # CONFIG_ARMV7R_TOOLCHAIN_GNU_EABIL is not set CONFIG_ARMV7R_TOOLCHAIN_GNU_EABIW=y # CONFIG_ARMV7R_TOOLCHAIN_GNU_OABI is not set +CONFIG_ARMV7R_HAVE_DECODEFIQ=y # CONFIG_ARMV7R_DECODEFIQ is not set +# CONFIG_SERIAL_TERMIOS is not set # # TMS570 Configuration Options # +# CONFIG_TMS570_HAVE_SCI2 is not set # CONFIG_ARCH_CHIP_TMS570LS0232PZ is not set # CONFIG_ARCH_CHIP_TMS570LS0332PZ is not set CONFIG_ARCH_CHIP_TMS570LS0432PZ=y @@ -159,6 +162,8 @@ CONFIG_ARCH_CHIP_TMS570LS0432PZ=y # CONFIG_TMS570_N2HET is not set # CONFIG_TMS570_MIBASPI1 is not set CONFIG_TMS570_SCI1=y +CONFIG_TMS570_GIO_IRQ=y +# CONFIG_TMS570_SELFTEST is not set # # Architecture Options @@ -226,6 +231,12 @@ CONFIG_ARCH_BOARD="launchxl-tms57004" # # Common Board Options # +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +CONFIG_ARCH_IRQBUTTONS=y CONFIG_NSH_MMCSDMINOR=0 # @@ -397,6 +408,7 @@ CONFIG_SPI_EXCHANGE=y # # LED Support # +# CONFIG_USERLED is not set # CONFIG_PCA9635PW is not set # CONFIG_MMCSD is not set # CONFIG_MTD is not set @@ -440,7 +452,7 @@ CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_IFLOWCONTROL is not set # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set -# CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y CONFIG_SCI1_SERIAL_CONSOLE=y # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set @@ -617,6 +629,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # # Examples # +# CONFIG_EXAMPLES_BUTTONS is not set # CONFIG_EXAMPLES_CONFIGDATA is not set # CONFIG_EXAMPLES_CPUHOG is not set # CONFIG_EXAMPLES_DHCPD is not set diff --git a/configs/launchxl-tms57004/src/Makefile b/configs/launchxl-tms57004/src/Makefile index 87c3012bdc..6b4d9ad28c 100644 --- a/configs/launchxl-tms57004/src/Makefile +++ b/configs/launchxl-tms57004/src/Makefile @@ -42,5 +42,14 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += tms570_appinit.c endif +ifeq ($(CONFIG_ARCH_LEDS),y) + CSRCS += tms570_autoleds.c +else + CSRCS += tms570_userleds.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) + CSRCS += tms570_buttons.c +endif include $(TOPDIR)/configs/Board.mk diff --git a/configs/launchxl-tms57004/src/launchxl-tms57004.h b/configs/launchxl-tms57004/src/launchxl-tms57004.h index d268a11073..3eb4f42d6a 100644 --- a/configs/launchxl-tms57004/src/launchxl-tms57004.h +++ b/configs/launchxl-tms57004/src/launchxl-tms57004.h @@ -46,6 +46,38 @@ * Pre-processor Definitions ****************************************************************************/ +/* LEDs + * + * The launchpad has a four LEDs two power LEDs labeled D1 (red) that + * connects to the TMS570's NERROR pin and D7 (blue) that indicates the + * XDS200 POWER_EN signal, and two white, user LEDs labeled D12 that + * connects to the NHET08 pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if not + * used by N2HET. This implementation, however, uses only the single LED + * driven by GIOA2. That LED is tied to ground and illuminated with a high + * level output value. + */ + +#define GIO_LED_D11 (GIO_OUTPUT | GIO_CFG_DEFAULT | GIO_OUTPUT_SET | \ + GIO_PORT_GIOA | GIO_PIN2) + +/* Buttons + * + * The launchpad has three mechanical buttons. Two of these are reset + * buttons: One button is labeled PORRST performs a power-on reset and one + * labeled RST performs an MCU reset. Only one button is available for + * general software usage. That button is labeled GIOA7 and is, obviously, + * sensed on GIOA7. + * + * GIOA7 is tied to ground, but will be pulled high if the GIOA7 button is + * depressed. + */ + +#define GIO_BUTTON (GIO_INPUT | GIO_CFG_PULLUP | GIO_INT_BOTHEDGES | \ + GIO_PORT_GIOA | GIO_PIN7) +#define IRQ_BUTTON TMS570_IRQ_GIOA7 + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/configs/launchxl-tms57004/src/tms570_autoleds.c b/configs/launchxl-tms57004/src/tms570_autoleds.c new file mode 100644 index 0000000000..35c2302a10 --- /dev/null +++ b/configs/launchxl-tms57004/src/tms570_autoleds.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * configs/launchxl-tms57004/include/tms570_autoleds.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* LEDs + * + * The launchpad has a four LEDs two power LEDs labeled D1 (red) that + * connects to the TMS570's NERROR pin and D7 (blue) that indicates the + * XDS200 POWER_EN signal, and two white, user LEDs labeled D12 that + * connects to the NHET08 pin and D11 that connects to GIOA2. + * + * NHET08 is one of 32 N2HET pins than can be available to the user if + * not used by N2HET. This implementation, however, uses only the single + * LED driven by GIOA2. That LED is tied to ground and illuminated + * with a high level output value. + * + * This LED is not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/tms570_autoleds.c. The LED is used to encode + * OS-related events as follows: + * + * ------------------- ----------------------- ------ + * SYMBOL Meaning LED + * ------------------- ----------------------- ------ + * 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_INIRQ In an interrupt N/C + * LED_SIGNAL In a signal handler N/C + * LED_ASSERTION An assertion failed N/C + * LED_PANIC The system has crashed FLASH + * + * Thus if the LED is statically on, NuttX has successfully booted and is, + * apparently, running normally. If the LED is flashing at approximately + * 2Hz, then a fatal error has been detected and the system has halted. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "tms570_gio.h" +#include "launchxl-tms57004.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG + * with CONFIG_DEBUG_VERBOSE too) + */ + +#ifdef CONFIG_DEBUG_LEDS +# define leddbg lldbg +# define ledvdbg llvdbg +#else +# define leddbg(x...) +# define ledvdbg(x...) +#endif + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure LED GIOs for output */ + + tms570_configgio(GIO_LED_D11); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if (led == 1 || led == 3) + { + tms570_giowrite(GIO_LED_D11, true); /* High illuminates */ + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if (led == 3) + { + tms570_giowrite(GIO_LED_D11, false); /* Low extinguishes */ + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/configs/launchxl-tms57004/src/tms570_bringup.c b/configs/launchxl-tms57004/src/tms570_bringup.c index 5ca348df0e..58b2773bf9 100644 --- a/configs/launchxl-tms57004/src/tms570_bringup.c +++ b/configs/launchxl-tms57004/src/tms570_bringup.c @@ -52,7 +52,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: sam_bringup + * Name: tms570_bringup * * Description: * Bring up simulated board features diff --git a/configs/launchxl-tms57004/src/tms570_buttons.c b/configs/launchxl-tms57004/src/tms570_buttons.c new file mode 100644 index 0000000000..2ac5c091fc --- /dev/null +++ b/configs/launchxl-tms57004/src/tms570_buttons.c @@ -0,0 +1,199 @@ +/**************************************************************************** + * configs/sam4e-ek/src/tms570_buttons.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include + +#include +#include + +#include "up_arch.h" +#include "tms570_gio.h" +#include "launchxl-tms57004.h" + +#ifdef CONFIG_ARCH_BUTTONS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef HAVE_IRQBUTTONS +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TMS570_GIO_IRQ) +# define HAVE_IRQBUTTONS 1 +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef HAVE_IRQBUTTONS +static xcpt_t g_irq_button; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_irqx + * + * Description: + * This function implements the core of the board_button_irq() logic. + * + ****************************************************************************/ + +#ifdef HAVE_IRQBUTTONS +static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq, + xcpt_t irqhandler, xcpt_t *store) +{ + xcpt_t oldhandler; + irqstate_t flags; + + /* Disable interrupts until we are done. This guarantees that the following + * operations are atomic. + */ + + flags = irqsave(); + + /* Get the old button interrupt handler and save the new one */ + + oldhandler = *store; + *store = irqhandler; + + /* Are we attaching or detaching? */ + + if (irqhandler != NULL) + { + /* Configure the interrupt */ + + tms570_gioirq(pinset); + (void)irq_attach(irq, irqhandler); + tms570_gioirqenable(irq); + } + else + { + /* Detach and disable the interrupt */ + + (void)irq_detach(irq); + tms570_gioirqdisable(irq); + } + + irqrestore(flags); + + /* Return the old button handler (so that it can be restored) */ + + return oldhandler; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + ****************************************************************************/ + +void board_button_initialize(void) +{ + /* Configure button GIOs */ + + (void)tms570_configgio(GIO_BUTTON); +} + +/**************************************************************************** + * Name: board_buttons + * + * Description: + * After board_button_initialize() has been called, board_buttons() may be + * called to collect the state of all buttons. board_buttons() returns an + * 8-bit bit set with each bit associated with a button. See the BUTTON* + * definitions above for the meaning of each bit in the returned value. + * + ****************************************************************************/ + +uint8_t board_buttons(void) +{ + return tms570_gioread(GIO_BUTTON) ? BUTTON_GIOA7_BIT : 0; +} + +/**************************************************************************** + * Name: board_button_irq + * + * Description: + * This function may be called to register an interrupt handler that will + * be called when a button is depressed or released. The ID value is one + * of the BUTTON* definitions provided above. The previous interrupt + * handler address is returned (so that it may restored, if so desired). + * + * Configuration Notes: + * Configuration CONFIG_AVR32_GIOIRQ must be selected to enable the + * overall GIO IRQ feature and CONFIG_AVR32_GIOIRQSETA and/or + * CONFIG_AVR32_GIOIRQSETB must be enabled to select GIOs to support + * interrupts on. For button support, bits 2 and 3 must be set in + * CONFIG_AVR32_GIOIRQSETB (PB2 and PB3). + * + ****************************************************************************/ + +xcpt_t board_button_irq(int id, xcpt_t irqhandler) +{ +#ifdef HAVE_IRQBUTTONS + if (id == BUTTON_GIOA7) + { + return board_button_irqx(GIO_BUTTON, IRQ_BUTTON, irqhandler, &g_irq_button); + } +#endif + + return NULL; + +} + +#endif /* CONFIG_ARCH_BUTTONS */ diff --git a/configs/launchxl-tms57004/src/tms570_userleds.c b/configs/launchxl-tms57004/src/tms570_userleds.c new file mode 100644 index 0000000000..2249c1278f --- /dev/null +++ b/configs/launchxl-tms57004/src/tms570_userleds.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * configs/launchxl-tms57004/src/tms570_userleds.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "tms570_gio.h" +#include "launchxl-tms57004.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + /* Configure LED PIOs for output */ + + tms570_configgio(GIO_LED_D11); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if (led == BOARD_LED_D11) + { + tms570_giowrite(GIO_LED_D11, !ledon); /* Low illuminates */ + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + /* Low illuminates */ + + tms570_giowrite(GIO_LED_D11, (ledset & BOARD_LED_D11_BIT) == 0)); +} diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 0b05f12d94..6348b7f77d 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -255,9 +255,9 @@ LEDs ---- A single LED is available driven by PC8. -These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is +This LED is not used by the board port unless CONFIG_ARCH_LEDS is defined. In that case, the usage by the board port is defined in -include/board.h and src/sam_autoleds.c. The LEDs are used to encode +include/board.h and src/sam_autoleds.c. The LED is used to encode OS-related events as follows: ------------------- ----------------------- ------ @@ -272,8 +272,8 @@ OS-related events as follows: LED_ASSERTION An assertion failed N/C LED_PANIC The system has crashed FLASH -Thus is LED is statically on, NuttX has successfully booted and is, -apparently, running normally. If LED is flashing at approximately +Thus if the LED is statically on, NuttX has successfully booted and is, +apparently, running normally. If the LED is flashing at approximately 2Hz, then a fatal error has been detected and the system has halted. Buttons