From 0e24b0de612ad596103e4e01d250f0be12278783 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 14 Mar 2011 20:50:46 +0000 Subject: Add apps/poweroff lpc17 hardware handshake git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3380 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 9 +- apps/Make.defs | 41 ++++++++ apps/Makefile | 38 ++++++-- apps/hello/Makefile | 4 +- apps/hello/README.txt | 5 + apps/poweroff/Makefile | 103 +++++++++++++++++++++ apps/poweroff/README.txt | 5 + apps/poweroff/poweroff.c | 42 +++++++++ nuttx/ChangeLog | 13 ++- nuttx/Documentation/NuttX.html | 24 ++++- nuttx/TODO | 6 +- nuttx/arch/arm/src/lpc17xx/lpc17_serial.c | 16 +++- nuttx/arch/arm/src/lpc17xx/lpc17_serial.h | 9 ++ nuttx/configs/olimex-lpc1766stk/README.txt | 9 ++ .../configs/olimex-lpc1766stk/slip-httpd/defconfig | 2 + 15 files changed, 305 insertions(+), 21 deletions(-) create mode 100755 apps/Make.defs create mode 100644 apps/hello/README.txt create mode 100644 apps/poweroff/Makefile create mode 100644 apps/poweroff/README.txt create mode 100644 apps/poweroff/poweroff.c diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 399e4c852..9d64b5c74 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -5,6 +5,9 @@ 5.20 2011-xx-xx Gregory Nutt - * README cosmetics - * hello world minor changes - * Makefile cosmetics (I am slowly adding the Darjeeling JVM) \ No newline at end of file + * README.txt -- README cosmetics + * hello/ -- hello world minor changes + * Makefile -- Makefile cosmetics (I am slowly adding the Darjeeling JVM) + * Make.defs -- New file adds common make definitions for applications. + * hello/Makefile -- Now uses new Make.defs definitions. Added README.txt. + * apps/poweroff -- New application to turn off board power. \ No newline at end of file diff --git a/apps/Make.defs b/apps/Make.defs new file mode 100755 index 000000000..bc71c98a0 --- /dev/null +++ b/apps/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# apps/Make.defs +# Common make definitions provided to all applications +# +# Copyright (C) 2011 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. +# +############################################################################ + +define REGISTER + @echo "Register: $1" + @echo "{ .name = $1, .priority = $2, .stacksize = $3, .main = $4 }," >> ../exec_nuttapp_list.h + @echo "EXTERN int $4(int argc, char *argv[]);" >> ../exec_nuttapp_proto.h +endef diff --git a/apps/Makefile b/apps/Makefile index 40cae5a40..6622932a0 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -49,23 +49,44 @@ BUILTIN_APPS_DIR = ifeq ($(CONFIG_BUILTIN_APPS_NUTTX),y) -# Individual application: HELLO +# BUILTIN_APPS is the list of all configured built-in directories/built action + +BUILTIN_APPS = ifeq ($(CONFIG_BUILTIN_APPS_HELLO),y) -BUILTIN_APPS_DIR += hello -BUILTIN_APPS_BUILT += hello/.built_always +BUILTIN_APPS += hello/.built_always endif ifeq ($(CONFIG_BUILTIN_APPS_POWEROFF),y) -BUILTIN_APPS_DIR += poweroff -BUILTIN_APPS_BUILT += poweroff/.built_always +BUILTIN_APPS += poweroff/.built_always endif ifeq ($(CONFIG_BUILTIN_APPS_JVM),y) -BUILTIN_APPS_DIR += jvm -BUILTIN_APPS_BUILT += jvm/.built_always +BUILTIN_APPS += jvm/.built_always endif +# AVAILABLE_APPS is the list of currently available application directories + +AVAILABLE_APPS = + +define ADD_AVAILABLE +AVAILABLE_APPS += ${shell DIR=`echo $1 | cut -d'/' -f1`; if [ -r $$DIR/Makefile ]; then echo "$1"; fi} +endef + +define BUILTIN_ADD_APP +BUILTIN_APPS_DIR += ${shell echo $1 | cut -d'/' -f1} +endef + +define BUILTIN_ADD_BUILT +BUILTIN_APPS_BUILT += ${shell echo $1 | cut -d'/' -f2} +endef + +# Create the list of applications to build + +$(foreach BUILTIN, $(BUILTIN_APPS), $(eval $(call ADD_AVAILABLE,$(BUILTIN)))) +$(foreach APP, $(AVAILABLE_APPS), $(eval $(call BUILTIN_ADD_APP,$(APP)))) +$(foreach BUILT, $(AVAILABLE_APPS), $(eval $(call BUILTIN_ADD_BUILT,$(BUILT)))) + # end of application list endif @@ -122,5 +143,8 @@ clean: distclean: clean @rm -f Make.dep .depend + @rm -f exec_nuttapp_list.h + @rm -f exec_nuttapp_proto.h -include Make.dep + diff --git a/apps/hello/Makefile b/apps/hello/Makefile index f4267cd4d..b1e13fc71 100644 --- a/apps/hello/Makefile +++ b/apps/hello/Makefile @@ -38,6 +38,7 @@ # sourcing the Make.defs! -include $(TOPDIR)/Make.defs +include ../Make.defs ifeq ($(WINTOOL),y) INCDIROPT = -w @@ -86,9 +87,8 @@ $(BIN): $(OBJS) .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) \ $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + $(call REGISTER, $(APPNAME), $(PRIORITY), $(STACKSIZE), $(APPNAME)_main) @touch $@ - echo "{ .name = \""$(APPNAME)"\", .priority = "$(PRIORITY)", .stacksize = "$(STACKSIZE)", .main = "$(APPNAME)"_main }," >> ../exec_nuttapp_list.h - echo "EXTERN int "$(APPNAME)"_main(int argc, char *argv[]);" >> ../exec_nuttapp_proto.h # Register application depend: .depend diff --git a/apps/hello/README.txt b/apps/hello/README.txt new file mode 100644 index 000000000..531c4d193 --- /dev/null +++ b/apps/hello/README.txt @@ -0,0 +1,5 @@ + +This application provides Hello Builtin Application skeleton + + Source: NuttX + Date: 13. March 2011 diff --git a/apps/poweroff/Makefile b/apps/poweroff/Makefile new file mode 100644 index 000000000..ceecadcd4 --- /dev/null +++ b/apps/poweroff/Makefile @@ -0,0 +1,103 @@ +############################################################################ +# Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/Make.defs +include ../Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = poweroff +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 768 + +ASRCS = +CSRCS = poweroff.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +BIN = ../libapps$(LIBEXT) + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +$(BIN): $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + @touch .built + +.built: $(BIN) + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) \ + $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + $(call REGISTER, $(APPNAME), $(PRIORITY), $(STACKSIZE), $(APPNAME)_main) + @touch $@ + +# Register application +depend: .depend + +clean: + @rm -f $(BIN) *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/poweroff/README.txt b/apps/poweroff/README.txt new file mode 100644 index 000000000..e02180e5a --- /dev/null +++ b/apps/poweroff/README.txt @@ -0,0 +1,5 @@ + +This application provides poweroff command + + Source: NuttX + Date: 13. March 2011 diff --git a/apps/poweroff/poweroff.c b/apps/poweroff/poweroff.c new file mode 100644 index 000000000..f8b56e0d8 --- /dev/null +++ b/apps/poweroff/poweroff.c @@ -0,0 +1,42 @@ +/**************************************************************************** + * poweroff/poweroff.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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 + +int poweroff_main(int argc, char *argv[]) +{ + board_power_off(); + return 0; +} diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 39556df91..63cb6efe5 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1562,8 +1562,11 @@ packet buffers. This capability was needed by the SLIP driver. * drivers/net/slip.c -- Several corrections and some re-design of of the driver. - * configs/vsn: - - IDLE LED blinking fix - - Added board power off function - * arch/arm/src/stm32/stm32_gpio.c and stm32_internal.h -- Fixe - PullUp/Down Input Configuration. \ No newline at end of file + * apps/ChangeLog.txt -- the apps/ directory now has its own ChangeLog. + * configs/vsn: + - IDLE LED blinking fix + - Added board power off function + * arch/arm/src/stm32/stm32_gpio.c and stm32_internal.h -- Fixed + PullUp/Down Input Configuration. + * arch/arm/src/lpc17xx/lpc17_serial.h -- Now supports Auto-RTS and + Auto-CTS modes. This is needed to support SLIP. \ No newline at end of file diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 4af5e5c9d..020cec2cd 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: March 13, 2011

+

Last Updated: March 14, 2011

@@ -2146,6 +2146,11 @@ nuttx-5.19 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * configs/olimex-lpc1766stk/slip-httpd - An example that uses SLIP to provide a serial-port based THTTPD web server. +apps-5.19 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + + * Initial version of the apps/ directory was released as contributed by + Uros Platise. + pascal-2.0 2009-12-21 Gregory Nutt <spudmonkey@racsa.co.cr> * Updated to use standard C99 types in stdint.h and @@ -2184,6 +2189,23 @@ nuttx-5.20 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> packet buffers. This capability was needed by the SLIP driver. * drivers/net/slip.c -- Several corrections and some re-design of of the driver. + * apps/ChangeLog.txt -- the apps/ directory now has its own ChangeLog. + * configs/vsn: + - IDLE LED blinking fix + - Added board power off function + * arch/arm/src/stm32/stm32_gpio.c and stm32_internal.h -- Fixed + PullUp/Down Input Configuration. + * arch/arm/src/lpc17xx/lpc17_serial.h -- Now supports Auto-RTS and + Auto-CTS modes. This is needed to support SLIP. + +apps-5.20 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> + + * README.txt -- README cosmetics + * hello/ -- hello world minor changes + * Makefile -- Makefile cosmetics (I am slowly adding the Darjeeling JVM) + * Make.defs -- New file adds common make definitions for applications. + * hello/Makefile -- Now uses new Make.defs definitions. Added README.txt. + * apps/poweroff -- New application to turn off board power. pascal-2.1 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/TODO b/nuttx/TODO index bddb6e0f5..d9c4cf48b 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -311,7 +311,11 @@ o Network (net/, drivers/net) Description: The SLIP driver (drivers/net/slip.c) has had only the most superficial testing. The main issue is the I haven't yet gotten a dual UART Linux configuration that supports SLIP (I need one UART for SLIP and one for - the serial debug console). + the serial debug console). A second issue is that SLIP requires + hardware handshake and that has not been implemented in the UART + drivers on most platforms. It might be possible to use a special + cable to bypass the handshaking (but which may also result in data + overrun errors). Status: Open Priority: Medium diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c index d58ce7c03..63687038f 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c @@ -664,13 +664,15 @@ static inline void lpc17_uart1config(uint32_t clkdiv) lpc17_configgpio(GPIO_UART1_TXD); lpc17_configgpio(GPIO_UART1_RXD); -#ifdef CONFIG_UART0_FLOWCONTROL +#ifdef CONFIG_UART1_FLOWCONTROL lpc17_configgpio(GPIO_UART1_CTS); + lpc17_configgpio(GPIO_UART1_RTS); lpc17_configgpio(GPIO_UART1_DCD); lpc17_configgpio(GPIO_UART1_DSR); lpc17_configgpio(GPIO_UART1_DTR); +#ifdef CONFIG_UART1_RINGINDICATOR lpc17_configgpio(GPIO_UART1_RI); - lpc17_configgpio(GPIO_UART1_RTS); +#endif #endif irqrestore(flags); }; @@ -849,6 +851,16 @@ static int up_setup(struct uart_dev_s *dev) up_serialout(priv, LPC17_UART_FCR_OFFSET, (UART_FCR_RXTRIGGER_8|UART_FCR_TXRST|UART_FCR_RXRST|UART_FCR_FIFOEN)); + + /* Enable Auto-RTS and Auto-CS Flow Control in the Modem Control Register */ + +#ifdef CONFIG_UART1_FLOWCONTROL + if (priv->uartbase == LPC17_UART1_BASE) + { + up_serialout(priv, LPC17_UART_MCR_OFFSET, (UART_MCR_RTSEN|UART_MCR_CTSEN)); + } +#endif + #endif return OK; } diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.h b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.h index 3446c4997..9fca96219 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.h +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.h @@ -92,6 +92,15 @@ # undef HAVE_CONSOLE #endif +/* Check UART flow control (Only supported by UART1) */ + +# undef CONFIG_UART0_FLOWCONTROL +# undef CONFIG_UART2_FLOWCONTROL +# undef CONFIG_UART3_FLOWCONTROL +#ifndef CONFIG_LPC17_UART1 +# undef CONFIG_UART1_FLOWCONTROL +#endif + /* We cannot allow the DLM/DLL divisor to become to small or will will lose too * much accuracy. This following is a "fudge factor" that represents the minimum * value of the divisor that we will permit. diff --git a/nuttx/configs/olimex-lpc1766stk/README.txt b/nuttx/configs/olimex-lpc1766stk/README.txt index b7cc8683d..86e50949b 100755 --- a/nuttx/configs/olimex-lpc1766stk/README.txt +++ b/nuttx/configs/olimex-lpc1766stk/README.txt @@ -824,8 +824,17 @@ Where is one of the following: $ ifconfig sl0 10.0.0.2/24 up + Or maybe, + + $ ifconfig sl0 10.0.0.1 pointopoint 10.0.0.2 up + $ route add 10.0.0.2 dev sl0 + Assuming the SLIP is attached to device sl0. + 5. For monitoring/debugging traffic: + + $ tcpdump -n -nn -i sl0 -x -X -s 1500 + thttpd: This builds the THTTPD web server example using the THTTPD and the examples/thttpd application. diff --git a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig index f61039535..9fb6ac45e 100755 --- a/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/slip-httpd/defconfig @@ -152,6 +152,8 @@ CONFIG_UART1_SERIAL_CONSOLE=n CONFIG_UART2_SERIAL_CONSOLE=n CONFIG_UART3_SERIAL_CONSOLE=n +CONFIG_UART1_FLOWCONTROL=y + CONFIG_UART0_TXBUFSIZE=256 CONFIG_UART1_TXBUFSIZE=256 CONFIG_UART2_TXBUFSIZE=256 -- cgit v1.2.3