diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-01-04 22:27:35 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-01-04 22:27:35 +0000 |
commit | f91fd53c6b97f4bb94aa8422728a926bda6a28d1 (patch) | |
tree | 467be247548c74288dd1fca293c8459056633430 /nuttx/configs/lm3s6432-s2e/src | |
parent | 99a753f17a5f82ae34fbbbc564757bb99666afbd (diff) | |
download | px4-nuttx-f91fd53c6b97f4bb94aa8422728a926bda6a28d1.tar.gz px4-nuttx-f91fd53c6b97f4bb94aa8422728a926bda6a28d1.tar.bz2 px4-nuttx-f91fd53c6b97f4bb94aa8422728a926bda6a28d1.zip |
Add suport for the Stellaris LM3S6432S2E and the TI RDK-S2E
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4260 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/lm3s6432-s2e/src')
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/Makefile | 87 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/README.txt | 1 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/lm3s6432s2e_internal.h | 125 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/up_boot.c | 103 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/up_ethernet.c | 98 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/up_leds.c | 168 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/up_nsh.c | 87 | ||||
-rw-r--r-- | nuttx/configs/lm3s6432-s2e/src/up_ssi.c | 151 |
8 files changed, 820 insertions, 0 deletions
diff --git a/nuttx/configs/lm3s6432-s2e/src/Makefile b/nuttx/configs/lm3s6432-s2e/src/Makefile new file mode 100644 index 000000000..7a0b883f8 --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/Makefile @@ -0,0 +1,87 @@ +############################################################################ +# configs/lm3s6432-s2e/src/Makefile +# +# Copyright (C) 2010 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +CFLAGS += -I$(TOPDIR)/sched + +ASRCS = +AOBJS = $(ASRCS:.S=$(OBJEXT)) +CSRCS = up_boot.c up_leds.c up_ethernet.c up_ssi.c +ifeq ($(CONFIG_NSH_ARCHINIT),y) +CSRCS += up_nsh.c +endif + +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src +ifeq ($(WINTOOL),y) + CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}" +else + CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/armv7-m +endif + +all: libboard$(LIBEXT) + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +libboard$(LIBEXT): $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + +.depend: Makefile $(SRCS) + @$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f libboard$(LIBEXT) *~ .*.swp + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/nuttx/configs/lm3s6432-s2e/src/README.txt b/nuttx/configs/lm3s6432-s2e/src/README.txt new file mode 100644 index 000000000..63aa5561e --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/README.txt @@ -0,0 +1 @@ +This directory contains drivers unique to the Stellaris MDL-S2E Reference Design. diff --git a/nuttx/configs/lm3s6432-s2e/src/lm3s6432s2e_internal.h b/nuttx/configs/lm3s6432-s2e/src/lm3s6432s2e_internal.h new file mode 100644 index 000000000..cc474bd80 --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/lm3s6432s2e_internal.h @@ -0,0 +1,125 @@ +/************************************************************************************ + * configs/lm3s6432-s2e/src/lm3s6432s2e_internal.h + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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. + * + ************************************************************************************/ + +#ifndef __CONFIGS_LM3S6432_S2E_SRC_LM3S6432S2E_INTERNAL_H +#define __CONFIGS_LM3S6432_S2E_SRC_LM3S6432S2E_INTERNAL_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/compiler.h> + +#include "chip.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/* How many SSI modules does this chip support? The LM3S6432 supports 1 SSI + * module (others may support more than 2 -- in such case, the following must be + * expanded). + */ + +#if LM3S_NSSI == 0 +# undef CONFIG_SSI0_DISABLE +# define CONFIG_SSI0_DISABLE 1 +#endif +#undef CONFIG_SSI1_DISABLE +#define CONFIG_SSI1_DISABLE 1 + +/* LM3S6432 MDL-S2E *****************************************************************/ + +/* GPIO Usage + * + * PIN SIGNAL S2E Function + * --- ----------------- --------------------------------------- + * L3 PA0/U0RX Virtual COM port receive + * M3 PA1/U0TX Virtual COM port transmit + * E12 PB0/U0CTS Virtual COM port CTS + * D12 PB1/U0RTS Virtual COM port RTS + * L5 PA4/SPIRX SPI receive + * M5 PA5/SPITX SPI transmit + * H2 PD2/U1RX Virtual COM port receive + * H1 PD3/U1TX Virtual COM port transmit + * L4 PA3/U1CTS/SPICLK Virtual COM port CTS + * M4 PA2/U1RTS/SPISEL Virtual COM port RTS + * J11 PF0/LED1 Ethernet LED1 (green) + * J12 PF1/LED0 Ethernet LED0 (yellow) + * C11 PB2 Transciever #INVALID + * C12 PB3 Transciever #ENABLE + * A6 PB4 Transciever ON + * B7 PB5 Transciever #OFF + */ + +/* GPIO for LEDs: + * - PF0: User LED + */ + +#define LED1_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTF | 2) +#define LED0_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTF | 3) + +/* GPIO for SSI0 select + */ +#define SSICS_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTA | 3) + +/* GPIOs for the RS-232 transciever enable/disable. + * Default state for these enables the transciever. + */ +#define XCVR_INV_GPIO (GPIO_FUNC_INPUT | GPIO_PORTB | 2) +#define XCVR_ENA_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTB | 3) +#define XCVR_ON_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTB | 4) +#define XCVR_OFF_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTB | 5) + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +/************************************************************************************ + * Name: lm3s_ssiinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the MDL-S2E. + * + ************************************************************************************/ + +extern void weak_function lm3s_ssiinitialize(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIGS_LM3S6432_S2E_SRC_LM3S6432S2E_INTERNAL_H */ + diff --git a/nuttx/configs/lm3s6432-s2e/src/up_boot.c b/nuttx/configs/lm3s6432-s2e/src/up_boot.c new file mode 100644 index 000000000..4b8fc3fcf --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/up_boot.c @@ -0,0 +1,103 @@ +/************************************************************************************ + * configs/lm3s6432-s2e/src/up_boot.c + * arch/arm/src/board/up_boot.c + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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 <nuttx/config.h> + +#include <debug.h> + +#include <arch/board/board.h> + +#include "up_arch.h" +#include "chip.h" +#include "up_internal.h" +#include "lm3s_internal.h" +#include "lm3s6432s2e_internal.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +#if !defined(CONFIG_UART1_DISABLE) && !defined(CONFIG_SSI0_DISABLE) +# error Only one of UART1 and SSI0 can be enabled on this board. +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: lm3s_boardinitialize + * + * Description: + * All LM3S architectures must provide the following entry point. This entry point + * is called early in the intitialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + ************************************************************************************/ + +void lm3s_boardinitialize(void) +{ + /* Configure SPI chip selects if 1) SSI is not disabled, and 2) the weak function + * lm3s_ssiinitialize() has been brought into the link. + */ + +#if !defined(CONFIG_SSI0_DISABLE) + if (lm3s_ssiinitialize) + { + lm3s_ssiinitialize(); + } +#endif + + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + up_ledinit(); +#endif + + /* Configure serial transciever */ + + lm3s_configgpio(XCVR_INV_GPIO); + lm3s_configgpio(XCVR_ENA_GPIO); + lm3s_configgpio(XCVR_ON_GPIO); + lm3s_configgpio(XCVR_OFF_GPIO); +} diff --git a/nuttx/configs/lm3s6432-s2e/src/up_ethernet.c b/nuttx/configs/lm3s6432-s2e/src/up_ethernet.c new file mode 100644 index 000000000..6040c167c --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/up_ethernet.c @@ -0,0 +1,98 @@ +/************************************************************************************ + * configs/lm3s6432-s3e/src/up_ethernet.c + * arch/arm/src/board/up_ethernet.c + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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 <nuttx/config.h> + +#include <stdint.h> +#include <debug.h> +#include <assert.h> + +#include <arch/board/board.h> +#include <net/ethernet.h> + +#include "up_arch.h" +#include "chip.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: lm3s_ethernetmac + * + * Description: + * For the Ethernet Eval Kits, the MAC address will be stored in the non-volatile + * USER0 and USER1 registers. If CONFIG_LM3S_BOARDMAC is defined, this function + * will obtain the MAC address from these registers. + * + ************************************************************************************/ + +#ifdef CONFIG_LM3S_BOARDMAC +void lm3s_ethernetmac(struct ether_addr *ethaddr) +{ + uint32_t user0; + uint32_t user1; + + /* Get the current value of the user registers */ + + user0 = getreg32(LM3S_FLASH_USERREG0); + user1 = getreg32(LM3S_FLASH_USERREG1); + + nlldbg("user: %06x:%06x\n", user1 & 0x00ffffff, user0 & 0x00ffffff); + DEBUGASSERT(user0 != 0xffffffff && user1 != 0xffffffff); + + /* Re-format that MAC address the way that uIP expects to see it */ + + ethaddr->ether_addr_octet[0] = ((user0 >> 0) & 0xff); + ethaddr->ether_addr_octet[1] = ((user0 >> 8) & 0xff); + ethaddr->ether_addr_octet[2] = ((user0 >> 16) & 0xff); + ethaddr->ether_addr_octet[3] = ((user1 >> 0) & 0xff); + ethaddr->ether_addr_octet[4] = ((user1 >> 8) & 0xff); + ethaddr->ether_addr_octet[5] = ((user1 >> 16) & 0xff); +} +#endif diff --git a/nuttx/configs/lm3s6432-s2e/src/up_leds.c b/nuttx/configs/lm3s6432-s2e/src/up_leds.c new file mode 100644 index 000000000..9a3e33793 --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/up_leds.c @@ -0,0 +1,168 @@ +/**************************************************************************** + * configs/lm3s6432-s2e/src/up_leds.c + * arch/arm/src/board/up_leds.c + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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 <nuttx/config.h> + +#include <stdbool.h> +#include <debug.h> + +#include <arch/board/board.h> + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" +#include "lm3s_internal.h" +#include "lm3s6432s2e_internal.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Enables debug output from this file (needs CONFIG_DEBUG with + * CONFIG_DEBUG_VERBOSE too) + */ + +#undef LED_DEBUG /* Define to enable debug */ + +#ifdef LED_DEBUG +# define leddbg lldbg +# define ledvdbg llvdbg +#else +# define leddbg(x...) +# define ledvdbg(x...) +#endif + +/* Dump GPIO registers */ + +#ifdef LED_DEBUG +# define led_dumpgpio(m) lm3s_dumpgpio(LED_GPIO, m) +#else +# define led_dumpgpio(m) +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +static uint8_t g_nest; + +/**************************************************************************** + * Name: up_ledinit + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void up_ledinit(void) +{ + leddbg("Initializing\n"); + + /* Configure Port F, Bit 2 as an output, initial value=OFF */ + + led_dumpgpio("up_ledinit before lm3s_configgpio()"); + lm3s_configgpio(LED0_GPIO); + lm3s_configgpio(LED1_GPIO); + led_dumpgpio("up_ledinit after lm3s_configgpio()"); + g_nest = 0; +} + +/**************************************************************************** + * Name: up_ledon + ****************************************************************************/ + +void up_ledon(int led) +{ + switch (led) + { + case LED_STARTED: + case LED_HEAPALLOCATE: + default: + break; + + case LED_INIRQ: + case LED_SIGNAL: + case LED_ASSERTION: + case LED_PANIC: + g_nest++; + case LED_IRQSENABLED: + case LED_STACKCREATED: + led_dumpgpio("up_ledon: before lm3s_gpiowrite()"); + lm3s_gpiowrite(LED1_GPIO, false); + led_dumpgpio("up_ledon: after lm3s_gpiowrite()"); + break; + } +} + +/**************************************************************************** + * Name: up_ledoff + ****************************************************************************/ + +void up_ledoff(int led) +{ + switch (led) + { + case LED_IRQSENABLED: + case LED_STACKCREATED: + case LED_STARTED: + case LED_HEAPALLOCATE: + default: + break; + + case LED_INIRQ: + case LED_SIGNAL: + case LED_ASSERTION: + case LED_PANIC: + if (--g_nest <= 0) + { + led_dumpgpio("up_ledoff: before lm3s_gpiowrite()"); + lm3s_gpiowrite(LED1_GPIO, true); + led_dumpgpio("up_ledoff: after lm3s_gpiowrite()"); + } + break; + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/nuttx/configs/lm3s6432-s2e/src/up_nsh.c b/nuttx/configs/lm3s6432-s2e/src/up_nsh.c new file mode 100644 index 000000000..6b44eafaf --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/up_nsh.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * config/lm3s6432-s2e/src/up_nsh.c + * arch/arm/src/board/up_nsh.c + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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 <nuttx/config.h> + +#include <stdio.h> +#include <debug.h> +#include <errno.h> + +#include <nuttx/spi.h> +#include <nuttx/mmcsd.h> + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* Debug ********************************************************************/ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG +# define message(...) lib_lowprintf(__VA_ARGS__) +# else +# define message(...) printf(__VA_ARGS__) +# endif +#else +# ifdef CONFIG_DEBUG +# define message lib_lowprintf +# else +# define message printf +# endif +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nsh_archinitialize + * + * Description: + * Perform architecture specific initialization + * + ****************************************************************************/ + +int nsh_archinitialize(void) +{ + return OK; +} diff --git a/nuttx/configs/lm3s6432-s2e/src/up_ssi.c b/nuttx/configs/lm3s6432-s2e/src/up_ssi.c new file mode 100644 index 000000000..7ca33c8be --- /dev/null +++ b/nuttx/configs/lm3s6432-s2e/src/up_ssi.c @@ -0,0 +1,151 @@ +/************************************************************************************ + * configs/lm3s6432-s2e/src/up_ssi.c + * arch/arm/src/board/up_ssi.c + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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 <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <debug.h> + +#include <nuttx/spi.h> +#include <arch/board/board.h> + +#include "up_arch.h" +#include "chip.h" +#include "lm3s_internal.h" +#include "lm3s6432s2e_internal.h" + +#if !defined(CONFIG_SSI0_DISABLE) + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/* Enables debug output from this file (needs CONFIG_DEBUG too) */ + +#undef SSI_DEBUG /* Define to enable debug */ +#undef SSI_VERBOSE /* Define to enable verbose debug */ + +#ifdef SSI_DEBUG +# define ssidbg lldbg +# ifdef SSI_VERBOSE +# define ssivdbg lldbg +# else +# define ssivdbg(x...) +# endif +#else +# undef SSI_VERBOSE +# define ssidbg(x...) +# define ssivdbg(x...) +#endif + +/* Dump GPIO registers */ + +#ifdef SSI_VERBOSE +# define ssi_dumpgpio(m) lm3s_dumpgpio(SDCCS_GPIO, m) +#else +# define ssi_dumpgpio(m) +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: lm3s_ssiinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the MDL-S2E. + * + ************************************************************************************/ + +void weak_function lm3s_ssiinitialize(void) +{ + /* Configure the SPI CS GPIO */ + + ssi_dumpgpio("lm3s_ssiinitialize() Entry)"); + lm3s_configgpio(SSICS_GPIO); + ssi_dumpgpio("lm3s_ssiinitialize() Exit"); +} + +/**************************************************************************** + * The external functions, lm3s_spiselect and lm3s_spistatus must be provided + * by board-specific logic. The are implementations of the select and status + * methods SPI interface defined by struct spi_ops_s (see include/nuttx/spi.h). + * All othermethods (including up_spiinitialize()) are provided by common + * logic. To use this common SPI logic on your board: + * + * 1. Provide lm3s_spiselect() and lm3s_spistatus() functions in your + * board-specific logic. This function will perform chip selection and + * status operations using GPIOs in the way your board is configured. + * 2. Add a call to up_spiinitialize() in your low level initialization + * logic + * 3. The handle returned by up_spiinitialize() may then be used to bind the + * SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +void lm3s_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) +{ + ssidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); + ssi_dumpgpio("lm3s_spiselect() Entry"); + + if (devid == SPIDEV_MMCSD) + { + /* Assert the CS pin to the card */ + + lm3s_gpiowrite(SDCCS_GPIO, !selected); + } + ssi_dumpgpio("lm3s_spiselect() Exit"); +} + +uint8_t lm3s_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid) +{ + ssidbg("Returning SPI_STATUS_PRESENT\n"); + return SPI_STATUS_PRESENT; +} + +#endif /* !CONFIG_SSI0_DISABLE || !CONFIG_SSI1_DISABLE */ |