Resync new repository with old repo r5166

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-17 18:18:44 +00:00
commit 57623d42eb
5691 changed files with 1361853 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
############################################################################
# configs/nucleus2g/src/Makefile
#
# Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# 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 =
CSRCS = up_boot.c up_leds.c up_ssp.c up_outputs.c
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += up_nsh.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += up_usbmsc.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
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
@@ -0,0 +1,156 @@
/************************************************************************************
* configs/nucleus2g/src/nucleus2g_internal.h
* arch/arm/src/board/nucleus2g_internal.n
*
* Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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_NUCLEUS2G_SRC_NUCLEUS2G_INTERNAL_H
#define _CONFIGS_NUCLEUS2G_SRC_NUCLEUS2G_INTERNAL_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
/************************************************************************************
* Definitions
************************************************************************************/
/* NUCLEUS-2G GPIO Pin Definitions **************************************************/
/* Board GPIO Usage:
*
* P0[0]/RD1/TXD3/SDA1 P0[0]/CAN_RX1
* P0[1]/TD1/RXD3/SCL P0[1]/CAN_TX1
* P0[2]/TXD0/AD0[7] TX0
* P0[3]/RXD0/AD0[6] RX0
* P0[4] P0[4]/CAN1_STB
* P0[5] P0[5]/CAN2_STB
* P0[6]/I2SRX_SDA/SSEL1/MAT2[0] GPI/O_CS1
* P0[7]/I2STX_CLK/SCK1/MAT2[1] SCLK1
* P0[8]/I2STX_WS/MISO1/MAT2[2] MISO1
* P0[9]/I2STX_SDA/MOSI1/MAT2[3] MOSI1
* P0[10] P0[10]/CAN1_TERM
* P0[11] P0[11]/CAN2_TERM
* P0[15]/TXD1/SCK0/SCK MMC_CLK
* P0[16]/RXD1/SSEL0/SSEL MMC_CD
* P0[17]/CTS1/MISO0/MISO MMC_DATA0
* P0[18]/DCD1/MOSI0/MOSI MMC_MISO
* P0[19]/DSR1/SDA1 GPI/O_CS2
* P0[20]/DTR1/SCL1 GPI/O_CS3
* P0[21]/RI1/MCIPWR/RD1 P0[21]
* P0[22]/RTS1/TD1 P0[22]
* P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] AD0
* P0[24]/AD0[1]/I2SRX_WS/CAP3[1] AD1
* P0[25]/AD0[2]/I2SRX_SDA/TXD3 AD2
* P0[26]/AD0[3]/AOUT/RXD3 AD3
* P0[27]/SDA0/USB_SDA SDA
* P0[28]/SCL0 SCL
* P0[29]/USB_D+ USB+
* P0[30]/USB_D- USB-
*
* P1[0] - P1[17] Not connected
* P1[18]/USB_UP_LED/PWM1[1]/CAP1[0] USB_LINK
* P1[19]-P[29] P[19]-P[29]
* P1[30]/VBUS/AD0[4] USB_+5
* P1[31]/SCK1/AD0[5] AD5
*
* P2[0] P2[0]/LED1_A
* P2[1] P2[1]/LED1_B
* P2[2] P2[2]/LED2_A
* P2[3] P2[3]/LED2_B
* P2[4] P2[4]
* P2[5]/PWM1[6]/DTR1/TRACEDATA[0] 232_POWERAVE
* P2[6]/PCAP1[0]/RI1/TRACECLK 232_VALID
* P2[7]/RD2/RTS1 P2[7]/CAN_RX2
* P2[8]/TD2/TXD2 P2[8]/CAN_TX2
* P2[9]/USB_CONNECT/RXD2 USB_CONNECT
* P2[10]/EINT0/NMI BOOTLOADER
* 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]
*/
#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_ONE | 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)
#define NUCLEUS2G_MMCSD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN16)
#define NUCLEUS_BMS_RELAY1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN20)
#define NUCLEUS_BMS_RELAY2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN21)
#define NUCLEUS_BMS_RELAY3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN22)
#define NUCLEUS_BMS_RELAY4 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN23)
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public data
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lpc17_sspinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the NUCLEUS-2G board.
*
************************************************************************************/
extern void weak_function lpc17_sspinitialize(void);
extern void up_relayinit(void);
#endif /* __ASSEMBLY__ */
#endif /* _CONFIGS_NUCLEUS2G_SRC_NUCLEUS2G_INTERNAL_H */
+115
View File
@@ -0,0 +1,115 @@
/************************************************************************************
* configs/nucleus2g/src/up_boot.c
* arch/arm/src/board/up_boot.c
*
* Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 "up_internal.h"
#include "lpc17_internal.h"
#include "nucleus2g_internal.h"
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lpc17_boardinitialize
*
* Description:
* All LPC17xx architectures must provide the following entry point. This entry point
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
*
************************************************************************************/
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 SSP chip selects if 1) at least one SSP is enabled, and 2) the weak
* function lpc17_sspinitialize() has been brought into the link.
*/
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
if (lpc17_sspinitialize)
{
lpc17_sspinitialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
up_ledinit();
#endif
/* Configure the relay outptus for use on the BMS master board */
#ifdef CONFIG_ARCH_BOARD_NUCLEUS2G_BMS
up_relayinit();
#endif
}
+235
View File
@@ -0,0 +1,235 @@
/****************************************************************************
* configs/nucleus2g/src/up_leds.c
* arch/arm/src/board/up_leds.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
#include "lpc17_internal.h"
#include "nucleus2g_internal.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Definitions
****************************************************************************/
/* Enables debug output from this file (needs CONFIG_DEBUG with
* CONFIG_DEBUG_VERBOSE too)
*/
#undef LED_DEBUG /* Define to enable debug */
#undef LED_VERBOSE /* Define to enable verbose debug */
#ifdef LED_DEBUG
# define leddbg lldbg
# ifdef LED_VERBOSE
# define ledvdbg lldbg
# else
# define ledvdbg(x...)
# endif
#else
# undef LED_VERBOSE
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/* Dump GPIO registers */
#ifdef LED_VERBOSE
# define led_dumpgpio(m) lpc17_dumpgpio(NUCLEUS2G_LED1_A, m)
#else
# define led_dumpgpio(m)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/* 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
* +------- ------ -----------------------
* LED_STARTED | OFF OFF OFF
* LED_HEAPALLOCATE | GREEN OFF OFF
* LED_IRQSENABLED | OFF GREEN OFF
* LED_STACKCREATED | OFF OFF OFF
* LED_INIRQ | NC NC ON (momentary)
* LED_SIGNAL | NC NC ON (momentary)
* LED_ASSERTION | NC NC ON (momentary)
* LED_PANIC | NC NC ON (1Hz flashing)
*/
static bool g_initialized;
static int g_nestcount;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_ledinit
****************************************************************************/
void up_ledinit(void)
{
/* Configure all LED GPIO lines */
led_dumpgpio("up_ledinit() Entry)");
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);
led_dumpgpio("up_ledinit() Exit");
}
/****************************************************************************
* Name: up_ledon
****************************************************************************/
void up_ledon(int led)
{
/* We will control LED1 and LED2 not yet completed the boot sequence. */
if (!g_initialized)
{
enum lpc17_ledstate_e led1 = LPC17_LEDSTATE_OFF;
enum lpc17_ledstate_e led2 = LPC17_LEDSTATE_OFF;
switch (led)
{
case LED_STACKCREATED:
g_initialized = true;
case LED_STARTED:
default:
break;
case LED_HEAPALLOCATE:
led1 = LPC17_LEDSTATE_GREEN;
break;
case LED_IRQSENABLED:
led2 = LPC17_LEDSTATE_GREEN;
}
lpc17_led1(led1);
lpc17_led2(led2);
}
/* We will always control the HB LED */
switch (led)
{
default:
break;
case LED_INIRQ:
case LED_SIGNAL:
case LED_ASSERTION:
case LED_PANIC:
lpc17_gpiowrite(NUCLEUS2G_HEARTBEAT, false);
g_nestcount++;
}
}
/****************************************************************************
* Name: up_ledoff
****************************************************************************/
void up_ledoff(int led)
{
/* In all states, OFF can only mean turning off the HB LED */
if (g_nestcount <= 1)
{
lpc17_gpiowrite(NUCLEUS2G_HEARTBEAT, true);
g_nestcount = 0;
}
else
{
g_nestcount--;
}
}
/************************************************************************************
* Name: lpc17_led1 and 2
*
* Description:
* Once the system has booted, these functions can be used to control LEDs 1 and 2
*
************************************************************************************/
void lpc17_led1(enum lpc17_ledstate_e state)
{
bool red = (((unsigned int)state & LPC17_LEDSTATE_RED) != 0);
bool green = (((unsigned int)state & LPC17_LEDSTATE_GREEN) != 0);
lpc17_gpiowrite(NUCLEUS2G_LED1_A, red);
lpc17_gpiowrite(NUCLEUS2G_LED1_B, green);
}
void lpc17_led2(enum lpc17_ledstate_e state)
{
bool red = (((unsigned int)state & LPC17_LEDSTATE_RED) != 0);
bool green = (((unsigned int)state & LPC17_LEDSTATE_GREEN) != 0);
lpc17_gpiowrite(NUCLEUS2G_LED2_A, red);
lpc17_gpiowrite(NUCLEUS2G_LED2_B, green);
}
#endif /* CONFIG_ARCH_LEDS */
+164
View File
@@ -0,0 +1,164 @@
/****************************************************************************
* config/nucleus2g/src/up_nsh.c
* arch/arm/src/board/up_nsh.c
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 ************************************************************/
/* PORT and SLOT number probably depend on the board configuration */
#ifdef CONFIG_ARCH_BOARD_NUCLEUS2G
# define NSH_HAVEUSBDEV 1
# define NSH_HAVEMMCSD 1
# if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 0
# error "The Nucleus-2G MMC/SD is on SSP0"
# undef CONFIG_NSH_MMCSDSPIPORTNO
# define CONFIG_NSH_MMCSDSPIPORTNO 0
# endif
# if !defined(CONFIG_NSH_MMCSDSLOTNO) || CONFIG_NSH_MMCSDSLOTNO != 0
# error "The Nucleus-2G MMC/SD is only one slot (0)"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO 0
# endif
# ifndef CONFIG_LPC17_SSP0
# warning "CONFIG_LPC17_SSP0 is not enabled"
# endif
#else
# error "Unrecognized board"
# undef NSH_HAVEUSBDEV
# undef NSH_HAVEMMCSD
#endif
/* Can't support USB device features if USB device is not enabled */
#ifndef CONFIG_USBDEV
# undef NSH_HAVEUSBDEV
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef NSH_HAVEMMCSD
#endif
#ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
#endif
/* 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
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
FAR struct spi_dev_s *ssp;
int ret;
/* Get the SSP port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp)
{
message("nsh_archinitialize: Failed to initialize SSP port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
return -ENODEV;
}
message("Successfully initialized SSP port %d\n",
CONFIG_NSH_MMCSDSPIPORTNO);
/* Bind the SSP port to the slot */
ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, ssp);
if (ret < 0)
{
message("nsh_archinitialize: Failed to bind SSP port %d to MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO, ret);
return ret;
}
message("Successfuly bound SSP port %d to MMC/SD slot %d\n",
CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO);
return OK;
}
+129
View File
@@ -0,0 +1,129 @@
/****************************************************************************
* configs/nucleus2g/src/up_outputs.c
* arch/arm/src/board/up_outputs.c
*
* Copyright (C) 2012 Hal Glenn. All rights reserved.
* Author: Hal Glenn <hglenn@2g-eng.com>
*
* This file is part of NuttX:
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
*
* 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 <arch/board/board.h>
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
#include "lpc17_internal.h"
#include "nucleus2g_internal.h"
#ifdef CONFIG_ARCH_BOARD_NUCLEUS2G_BMS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nucleus_bms_relay 1-4
*
* Description:
* Once booted these functions control the 4 isolated FET outputs from the
* master BMS controller
*
***************************************************************************/
void nucleus_bms_relay1(enum output_state state)
{
bool value = (state == (enum output_state)RELAY_OPEN);
lpc17_gpiowrite(NUCLEUS_BMS_RELAY1, value);
}
void nucleus_bms_relay2(enum output_state state)
{
bool value = (state == (enum output_state)RELAY_OPEN);
lpc17_gpiowrite(NUCLEUS_BMS_RELAY2, value);
}
void nucleus_bms_relay3(enum output_state state)
{
bool value = (state == (enum output_state)RELAY_OPEN);
lpc17_gpiowrite(NUCLEUS_BMS_RELAY3, value);
}
void nucleus_bms_relay4(enum output_state state)
{
bool value = (state == (enum output_state)RELAY_OPEN);
lpc17_gpiowrite(NUCLEUS_BMS_RELAY4, value);
}
/***************************************************************************
* Name: up_relayinit
*
* Description:
* This function is called on boot to init the GPIO for relay control
*
***************************************************************************/
void up_relayinit(void)
{
lpc17_configgpio(NUCLEUS_BMS_RELAY1);
lpc17_configgpio(NUCLEUS_BMS_RELAY2);
lpc17_configgpio(NUCLEUS_BMS_RELAY3);
lpc17_configgpio(NUCLEUS_BMS_RELAY4);
}
#endif /* CONFIG_ARCH_BOARD_NUCLEUS2G_BMS */
+185
View File
@@ -0,0 +1,185 @@
/************************************************************************************
* configs/nucleus2g/src/up_ssp.c
* arch/arm/src/board/up_ssp.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 "lpc17_internal.h"
#include "nucleus2g_internal.h"
/* The LM3S6965 Eval Kit microSD CS is on SSI0 */
#if defined(CONFIG_LPC17_SSP0) || defined(CONFIG_LPC17_SSP1)
/************************************************************************************
* Definitions
************************************************************************************/
/* Enables debug output from this file (needs CONFIG_DEBUG too) */
#undef SSP_DEBUG /* Define to enable debug */
#undef SSP_VERBOSE /* Define to enable verbose debug */
#ifdef SSP_DEBUG
# define sspdbg lldbg
# ifdef SSP_VERBOSE
# define sspvdbg lldbg
# else
# define sspvdbg(x...)
# endif
#else
# undef SSP_VERBOSE
# define sspdbg(x...)
# define sspvdbg(x...)
#endif
/* Dump GPIO registers */
#ifdef SSP_VERBOSE
# define ssp_dumpgpio(m) lpc17_dumpgpio(SDCCS_GPIO, m)
#else
# define ssp_dumpgpio(m)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lpc17_sspinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the LM3S6965 Eval Kit.
*
************************************************************************************/
void weak_function lpc17_sspinitialize(void)
{
/* Configure the SPI-based microSD CS GPIO */
ssp_dumpgpio("lpc17_sspinitialize() Entry)");
/* SSP0 connects only to the MMC/SD slot on the Nucleus 1G board.
* P0[15]/TXD1/SCK0/SCK MMC_CLK
* P0[16]/RXD1/SSEL0/SSEL MMC_CD
* P0[17]/CTS1/MISO0/MISO MMC_DATA0
* P0[18]/DCD1/MOSI0/MOSI MMC_MISO
*
* In SPI mode the MMC/SD DATA3/CD functions as the SPI chip select.
*/
#ifdef CONFIG_LPC17_SSP0
lpc17_configgpio(NUCLEUS2G_MMCSD_CS);
#endif
/* SSP1 goes off the Nucleus 2G board to the Babel CAN board along with 3 chip
* select pins. However, it is currently not used on that board.
*/
#ifdef CONFIG_LPC17_SSP1
# warning "SSP1 chip selects not known"
#endif
ssp_dumpgpio("lpc17_sspinitialize() Exit");
}
/************************************************************************************
* Name: lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
*
* Description:
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi.h). All other methods (including up_spiinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your
* board:
*
* 1. Provide logic in lpc17_boardinitialize() to configure SPI/SSP chip select
* pins.
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application
* initialization logic
* 4. 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).
*
************************************************************************************/
#ifdef CONFIG_LPC17_SSP0
void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
ssp_dumpgpio("lpc17_spiselect() Entry");
if (devid == SPIDEV_MMCSD)
{
/* Assert the CS pin to the card */
lpc17_gpiowrite(NUCLEUS2G_MMCSD_CS, !selected);
}
ssp_dumpgpio("lpc17_spiselect() Exit");
}
uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_LPC17_SSP1
# warning "SSP1 chip selects not known"
#endif
#endif /* CONFIG_LPC17_SSP0 || CONFIG_LPC17_SSP1 */
+143
View File
@@ -0,0 +1,143 @@
/****************************************************************************
* configs/nucleus2g/src/up_usbmsc.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Configure and register the LPC17xx MMC/SD SPI block driver.
*
* 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 ************************************************************/
#ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR1
# define CONFIG_EXAMPLES_USBMSC_DEVMINOR1 0
#endif
/* PORT and SLOT number probably depend on the board configuration */
#ifdef CONFIG_ARCH_BOARD_NUCLEUS2G
# undef LPC17XX_MMCSDSPIPORTNO
# define LPC17XX_MMCSDSPIPORTNO 1
# undef LPC17XX_MMCSDSLOTNO
# define LPC17XX_MMCSDSLOTNO 0
#else
/* Add configuration for new LPC17xx boards here */
# error "Unrecognized LPC17xx board"
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# define msgflush()
# else
# define message(...) printf(__VA_ARGS__)
# define msgflush() fflush(stdout)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# define msgflush()
# else
# define message printf
# define msgflush() fflush(stdout)
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: usbmsc_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int usbmsc_archinitialize(void)
{
FAR struct spi_dev_s *spi;
int ret;
/* Get the SPI port */
message("usbmsc_archinitialize: Initializing SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO);
spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi)
{
message("usbmsc_archinitialize: Failed to initialize SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO);
return -ENODEV;
}
message("usbmsc_archinitialize: Successfully initialized SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO);
/* Bind the SPI port to the slot */
message("usbmsc_archinitialize: Binding SPI port %d to MMC/SD slot %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO);
ret = mmcsd_spislotinitialize(CONFIG_EXAMPLES_USBMSC_DEVMINOR1, LPC17XX_MMCSDSLOTNO, spi);
if (ret < 0)
{
message("usbmsc_archinitialize: Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO, ret);
return ret;
}
message("usbmsc_archinitialize: Successfuly bound SPI port %d to MMC/SD slot %d\n",
LPC17XX_MMCSDSPIPORTNO, LPC17XX_MMCSDSLOTNO);
return OK;
}