From add995c32e86f9de8fa8fc05172435332c25a895 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 19 Dec 2011 19:24:09 +0000 Subject: Completes coding of the PWM module git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4200 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/configs/pjrc-8051/Make.defs | 97 ++++++++ nuttx/configs/pjrc-8051/README.txt | 37 +++ nuttx/configs/pjrc-8051/appconfig | 39 +++ nuttx/configs/pjrc-8051/defconfig | 385 +++++++++++++++++++++++++++++ nuttx/configs/pjrc-8051/include/README.txt | 1 + nuttx/configs/pjrc-8051/include/board.h | 51 ++++ nuttx/configs/pjrc-8051/include/pjrc.h | 215 ++++++++++++++++ nuttx/configs/pjrc-8051/sdcc-2.6.0.patch | 28 +++ nuttx/configs/pjrc-8051/setenv.sh | 45 ++++ nuttx/configs/pjrc-8051/src/Makefile | 76 ++++++ nuttx/configs/pjrc-8051/src/README.txt | 1 + nuttx/configs/pjrc-8051/src/up_leds.c | 207 ++++++++++++++++ 12 files changed, 1182 insertions(+) create mode 100644 nuttx/configs/pjrc-8051/Make.defs create mode 100644 nuttx/configs/pjrc-8051/README.txt create mode 100644 nuttx/configs/pjrc-8051/appconfig create mode 100644 nuttx/configs/pjrc-8051/defconfig create mode 100644 nuttx/configs/pjrc-8051/include/README.txt create mode 100644 nuttx/configs/pjrc-8051/include/board.h create mode 100644 nuttx/configs/pjrc-8051/include/pjrc.h create mode 100644 nuttx/configs/pjrc-8051/sdcc-2.6.0.patch create mode 100755 nuttx/configs/pjrc-8051/setenv.sh create mode 100644 nuttx/configs/pjrc-8051/src/Makefile create mode 100644 nuttx/configs/pjrc-8051/src/README.txt create mode 100644 nuttx/configs/pjrc-8051/src/up_leds.c (limited to 'nuttx/configs/pjrc-8051') diff --git a/nuttx/configs/pjrc-8051/Make.defs b/nuttx/configs/pjrc-8051/Make.defs new file mode 100644 index 000000000..68de71650 --- /dev/null +++ b/nuttx/configs/pjrc-8051/Make.defs @@ -0,0 +1,97 @@ +############################################################################ +# configs/pjrc-8051/Make.defs +# +# Copyright (C) 2007, 2008 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. +# +############################################################################ + +include ${TOPDIR}/.config + +ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") + ARCHOPTIMIZATION = --debug +else + ARCHOPTIMIZATION = +endif + +ARCHCPUFLAGS = -mmcs51 --stack-auto --model-large --int-long-reent --float-reent +ARCHPICFLAGS = +ARCHWARNINGS = +ARCHDEFINES = +ARCHINCLUDES = -I. -I$(TOPDIR)/include + +CROSSDEV = +CC = sdcc +CPP = sdcpp +LD = aslink +AS = asx8051 +AR = sdcclib -a + +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) + +ASMEXT = .asm +OBJEXT = .rel +LIBEXT = .lib +EXEEXT = .hex + +define PREPROCESS + @echo "CPP: $1->$2" + @$(CPP) $(CPPFLAGS) $1 -o $2 +endef + +define COMPILE + @echo "CC: $1" + @$(CC) -c $(CFLAGS) $1 -o $2 +endef + +define ASSEMBLE + @echo "AS: $1" + @$(AS) $(ASFLAGS) $1 +endef + +define ARCHIVE + echo "AR: $2"; \ + $(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; } +endef + +define CLEAN + @rm -f *.asm *.rel *.lst *.rst *.sym *.adb *.lnk *.map *.mem *.ihx *.hex +endef + +MKDEP = $(TOPDIR)/tools/mkdeps.sh + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -wstrict-prototypes -Wshadow -g -pipe +HOSTLDFLAGS = + + diff --git a/nuttx/configs/pjrc-8051/README.txt b/nuttx/configs/pjrc-8051/README.txt new file mode 100644 index 000000000..dae92b59b --- /dev/null +++ b/nuttx/configs/pjrc-8051/README.txt @@ -0,0 +1,37 @@ +pjrc-8051 README +^^^^^^^^^^^^^^^^ + +This port uses the PJRC 87C52 development system and the SDCC toolchain. + +The PJRC 87C52 development system can be obtained from http://www.pjrc.com/. + +The SDCC toolchain is available from http://sdcc.sourceforge.net/. All +testing has been performed using verison 2.6.0 of the SDDC toolchain. + +Building the SDCC toolchain +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The SDCC toolchain is built with the standard configure/make/make install +sequence. However, some special actions are required to generate libraries +compatible with this build. First start with the usual steps + + download + unpack + cd sdcc + ./configure + make + +But before installing, we need to apply a patch to the SDCC 2.6.0 source. +WARNING: This patch is specific to the particular combination of CFLAGS +that are used in the compilation. If you change Make.defs, then you will +likely have to change the patch as well. + + Apply sdcc-2.6.0.patch + cd sdcc/device/lib + make model-mcs51-stack-auto + +Then + + cd sdcc + make install + diff --git a/nuttx/configs/pjrc-8051/appconfig b/nuttx/configs/pjrc-8051/appconfig new file mode 100644 index 000000000..d88edca75 --- /dev/null +++ b/nuttx/configs/pjrc-8051/appconfig @@ -0,0 +1,39 @@ +############################################################################ +# configs/pjrc-8051/appconfig +# +# 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. +# +############################################################################ + +# Path to example in apps/examples containing the user_start entry point + +CONFIGURED_APPS += examples/ostest + diff --git a/nuttx/configs/pjrc-8051/defconfig b/nuttx/configs/pjrc-8051/defconfig new file mode 100644 index 000000000..32341becb --- /dev/null +++ b/nuttx/configs/pjrc-8051/defconfig @@ -0,0 +1,385 @@ +############################################################################ +# configs/pjrc-8051/defconfig +# +# Copyright (C) 2007-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. +# +############################################################################ +# +# Architecture selection +# +# CONFIG_ARCH - identifies the arch subdirectory and, hence, the +# processor architecture. +# CONFIG_ARCH_8051 - Set if processor is 8051 family +# CONFIG_ARCH_8052 = Set if processor is 8052 family +# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence, +# the board that supports the particular chip or SoC. +# CONFIG_ARCH_BOARD_name - for use in C code +# CONFIG_ENDIAN_BIG - define if big endian (default is little endian) +# +CONFIG_ARCH=8051 +CONFIG_ARCH_8051=n +CONFIG_ARCH_8052=y +CONFIG_ARCH_BOARD=pjrc-8051 +CONFIG_ARCH_BOARD_PJRC_87C52=y + +# +# Architecture-specific settings. These may mean nothing to +# other architectures. +# +# CONFIG-ARCH_PJRC - Set if using the PJRC 87C52 board +# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to 8051. +# CONFIG_8052_TIMER2 - Use timer2 for the 100Hz system timer. +# (default is timer0 at 112.5Hz). +# +# These features are only supported when CONFIG_ARCH_BRINGUP +# is set: +# +# CONFIG_ARCH_BRINGUP - Enables some bringup features +# CONFIG_FRAME_DUMP - Enable stack/frame dumping logic +# CONFIG_FRAME_DUMP_SHORT - Terse frame dump output +# CONFIG_SUPPRESS_INTERRUPTS - Do not enable interrupts +# CONFIG_SWITCH_FRAME_DUMP - Dump frames from normal switches +# CONFIG_INTERRUPT_FRAME_DUMP - Dump frames from interrupt switches +# CONFIG_LED_DEBUG - Enable debug output from LED logic +# +CONFIG_ARCH_PJRC=y +CONFIG_ARCH_LEDS=y +CONFIG_8052_TIMER2=y + +CONFIG_ARCH_BRINGUP=y +CONFIG_FRAME_DUMP=n +CONFIG_FRAME_DUMP_SHORT=n +CONFIG_SUPPRESS_INTERRUPTS=y +CONFIG_SWITCH_FRAME_DUMP=n +CONFIG_INTERRUPT_FRAME_DUMP=n +CONFIG_LED_DEBUG=n + +# +# General build options +# +# CONFIG_RRLOAD_BINARY - make the rrload binary format used with +# BSPs from www.ridgerun.com using the tools/mkimage.sh script +# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format +# used with many different loaders using the GNU objcopy program +# Should not be selected if you are not using the GNU toolchain. +# CONFIG_RAW_BINARY - make a raw binary format file used with many +# different loaders using the GNU objcopy program. This option +# should not be selected if you are not using the GNU toolchain. +# CONFIG_HAVE_LIBM - toolchain supports libm.a +# +CONFIG_RRLOAD_BINARY=n +CONFIG_INTELHEX_BINARY=n +CONFIG_RAW_BINARY=n +CONFIG_HAVE_LIBM=n + +# +# General OS setup +# +# CONFIG_APPS_DIR - Identifies the relative path to the directory +# that builds the application to link with NuttX. Default: ../apps +# CONFIG_DEBUG - enables built-in debug options +# CONFIG_DEBUG_VERBOSE - enables verbose debug output +# CONFIG_DEBUG_SYMBOLS - build without optimization and with +# debug symbols (needed for use with a debugger). +# CONFIG_MM_REGIONS - If the architecture includes multiple +# regions of memory to allocate from, this specifies the +# number of memory regions that the memory manager must +# handle and enables the API mm_addregion(start, end); +# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot +# time console output +# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz +# or MSEC_PER_TICK=10. This setting may be defined to +# inform NuttX that the processor hardware is providing +# system timer interrupts at some interrupt interval other +# than 10 msec. +# CONFIG_RR_INTERVAL - The round robin timeslice will be set +# this number of milliseconds; Round robin scheduling can +# be disabled by setting this value to zero. +# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in +# scheduler to monitor system performance +# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a +# task name to save in the TCB. Useful if scheduler +# instrumentation is selected. Set to zero to disable. +# CONFIG_JULIAN_TIME - Enables Julian time conversions +# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY - +# Used to initialize the internal time logic. +# CONFIG_DEV_CONSOLE - Set if architecture-specific logic +# provides /dev/console. Enables stdout, stderr, stdin. +# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console +# driver (minimul support) +# CONFIG_MUTEX_TYPES: Set to enable support for recursive and +# errorcheck mutexes. Enables pthread_mutexattr_settype(). +# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority +# inheritance on mutexes and semaphores. +# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority +# inheritance is enabled. It defines the maximum number of +# different threads (minus one) that can take counts on a +# semaphore with priority inheritance support. This may be +# set to zero if priority inheritance is disabled OR if you +# are only using semaphores as mutexes (only one holder) OR +# if no more than two threads participate using a counting +# semaphore. +# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled, +# then this setting is the maximum number of higher priority +# threads (minus 1) than can be waiting for another thread +# to release a count on a semaphore. This value may be set +# to zero if no more than one thread is expected to wait for +# a semaphore. +# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors +# by task_create() when a new task is started. If set, all +# files/drivers will appear to be closed in the new task. +# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first +# three file descriptors (stdin, stdout, stderr) by task_create() +# when a new task is started. If set, all files/drivers will +# appear to be closed in the new task except for stdin, stdout, +# and stderr. +# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket +# desciptors by task_create() when a new task is started. If +# set, all sockets will appear to be closed in the new task. +# +#CONFIG_APPS_DIR= +CONFIG_DEBUG=n +CONFIG_DEBUG_VERBOSE=n +CONFIG_DEBUG_SYMBOLS=n +CONFIG_MM_REGIONS=2 +CONFIG_ARCH_LOWPUTC=y +CONFIG_RR_INTERVAL=0 +CONFIG_SCHED_INSTRUMENTATION=n +CONFIG_TASK_NAME_SIZE=0 +CONFIG_START_YEAR=2007 +CONFIG_START_MONTH=2 +CONFIG_START_DAY=21 +CONFIG_JULIAN_TIME=n +CONFIG_DEV_CONSOLE=n +CONFIG_DEV_LOWCONSOLE=n +CONFIG_MUTEX_TYPES=n +CONFIG_PRIORITY_INHERITANCE=n +CONFIG_SEM_PREALLOCHOLDERS=0 +CONFIG_SEM_NNESTPRIO=0 +CONFIG_FDCLONE_DISABLE=n +CONFIG_FDCLONE_STDIO=n +CONFIG_SDCLONE_DISABLE=y + +# +# The following can be used to disable categories of +# APIs supported by the OS. If the compiler supports +# weak functions, then it should not be necessary to +# disable functions unless you want to restrict usage +# of those APIs. +# +# There are certain dependency relationships in these +# features. +# +# o mq_notify logic depends on signals to awaken tasks +# waiting for queues to become full or empty. +# o pthread_condtimedwait() depends on signals to wake +# up waiting tasks. +# +CONFIG_DISABLE_CLOCK=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DISABLE_PTHREAD=y +CONFIG_DISABLE_SIGNALS=y +CONFIG_DISABLE_MQUEUE=y +CONFIG_DISABLE_MOUNTPOINT=y +CONFIG_DISABLE_ENVIRON=y +CONFIG_DISABLE_POLL=y + +# +# Misc libc settings +# +# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a +# little smaller if we do not support fieldwidthes +# +CONFIG_NOPRINTF_FIELDWIDTH=y + +# +# Allow for architecture optimized implementations +# +# The architecture can provide optimized versions of the +# following to improve sysem performance +# +CONFIG_ARCH_MEMCPY=n +CONFIG_ARCH_MEMCMP=n +CONFIG_ARCH_MEMMOVE=n +CONFIG_ARCH_MEMSET=n +CONFIG_ARCH_STRCMP=n +CONFIG_ARCH_STRCPY=n +CONFIG_ARCH_STRNCPY=n +CONFIG_ARCH_STRLEN=n +CONFIG_ARCH_STRNLEN=n +CONFIG_ARCH_BZERO=n + +# +# Sizes of configurable things (0 disables) +# +# CONFIG_MAX_TASKS - The maximum number of simultaneously +# actived tasks. This value must be a power of two. +# CONFIG_MAX_TASK_ARGS - This controls the maximum number of +# of parameters that a task may receive (i.e., maxmum value +# of 'argc') +# CONFIG_NPTHREAD_KEYS - The number of items of thread- +# specific data that can be retained +# CONFIG_NFILE_DESCRIPTORS - The maximum number of file +# descriptors (one for each open) +# CONFIG_NFILE_STREAMS - The maximum number of streams that +# can be fopen'ed +# CONFIG_NAME_MAX - The maximum size of a file name. +# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate +# on fopen. (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_NUNGET_CHARS - Number of characters that can be +# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message +# structures. The system manages a pool of preallocated +# message structures to minimize dynamic allocations +# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with +# a fixed payload size given by this settin (does not include +# other message structure overhead. +# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that +# can be passed to a watchdog handler +# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog +# structures. The system manages a pool of preallocated +# watchdog structures to minimize dynamic allocations +# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX +# timer structures. The system manages a pool of preallocated +# timer structures to minimize dynamic allocations. Set to +# zero for all dynamic allocations. +# +CONFIG_MAX_TASKS=8 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=0 +CONFIG_NFILE_DESCRIPTORS=0 +CONFIG_NFILE_STREAMS=0 +CONFIG_NAME_MAX=32 +CONFIG_STDIO_BUFFER_SIZE=0 +CONFIG_NUNGET_CHARS=0 +CONFIG_PREALLOC_MQ_MSGS=0 +CONFIG_MQ_MAXMSGSIZE=0 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=0 + +# +# TCP/IP and UDP support via uIP +# CONFIG_NET - Enable or disable all network features +# CONFIG_NET_IPv6 - Build in support for IPv6 +# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread. +# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options +# CONFIG_NET_BUFSIZE - uIP buffer size +# CONFIG_NET_TCP - TCP support on or off +# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks) +# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers +# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero) +# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until +# accept() is called. The size of the backlog is selected when listen() is called. +# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks) +# CONFIG_NET_UDP - UDP support on or off +# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off +# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections +# CONFIG_NET_ICMP - ICMP ping response support on or off +# CONFIG_NET_ICMP_PING - ICMP ping request support on or off +# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address +# CONFIG_NET_STATISTICS - uIP statistics on or off +# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window +# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table +# CONFIG_NET_BROADCAST - Broadcast support +# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates +# +CONFIG_NET=n +CONFIG_NET_IPv6=n +CONFIG_NSOCKET_DESCRIPTORS=0 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_BUFSIZE=420 +CONFIG_NET_TCP=n +CONFIG_NET_TCP_CONNS=40 +CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_UDP=n +CONFIG_NET_UDP_CHECKSUMS=y +#CONFIG_NET_UDP_CONNS=10 +CONFIG_NET_ICMP=n +CONFIG_NET_ICMP_PING=n +#CONFIG_NET_PINGADDRCONF=0 +CONFIG_NET_STATISTICS=y +#CONFIG_NET_RECEIVE_WINDOW= +#CONFIG_NET_ARPTAB_SIZE=8 +CONFIG_NET_BROADCAST=n +#CONFIG_NET_FWCACHE_SIZE=2 + +# +# UIP Network Utilities +# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP +# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries +CONFIG_NET_DHCP_LIGHT=n +CONFIG_NET_RESOLV_ENTRIES=4 + +# +# Settings for examples/nsh +CONFIG_NSH_CONSOLE=y +CONFIG_NSH_TELNET=n +CONFIG_NSH_IOBUFFER_SIZE=512 +CONFIG_NSH_CMD_SIZE=40 +CONFIG_NSH_STACKSIZE=4096 +CONFIG_NSH_DHCPC=n +CONFIG_NSH_NOMAC=n +CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0) + +# +# Stack and heap information +# +# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP +# operation from FLASH but must copy initialized .data sections to RAM. +# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH +# but copy themselves entirely into RAM for better performance. +# CONFIG_CUSTOM_STACK - The up_ implementation will handle +# all stack operations outside of the nuttx model. +# CONFIG_STACK_POINTER - The initial stack pointer +# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack. +# This is the thread that (1) performs the inital boot of the system up +# to the point where user_start() is spawned, and (2) there after is the +# IDLE thread that executes only when there is no other thread ready to +# run. +# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate +# for the main user thread that begins at the user_start() entry point. +# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size +# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size +# CONFIG_HEAP_BASE - The beginning of the heap +# CONFIG_HEAP_SIZE - The size of the heap +# +CONFIG_BOOT_RUNFROMFLASH=n +CONFIG_BOOT_COPYTORAM=n +CONFIG_CUSTOM_STACK=y +CONFIG_IDLETHREAD_STACKSIZE= +CONFIG_USERMAIN_STACKSIZE= +CONFIG_PTHREAD_STACK_MIN= +CONFIG_PTHREAD_STACK_DEFAULT= +CONFIG_HEAP_BASE= +CONFIG_HEAP_SIZE= diff --git a/nuttx/configs/pjrc-8051/include/README.txt b/nuttx/configs/pjrc-8051/include/README.txt new file mode 100644 index 000000000..073c155f0 --- /dev/null +++ b/nuttx/configs/pjrc-8051/include/README.txt @@ -0,0 +1 @@ +This directory contains header files unique to the PJRC 87C52 development board. diff --git a/nuttx/configs/pjrc-8051/include/board.h b/nuttx/configs/pjrc-8051/include/board.h new file mode 100644 index 000000000..fe036da8c --- /dev/null +++ b/nuttx/configs/pjrc-8051/include/board.h @@ -0,0 +1,51 @@ +/************************************************************ + * board/board.h + * + * Copyright (C) 2007-2009 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. + * + ************************************************************/ + +#ifndef __ARCH_BOARD_BOARD_H +#define __ARCH_BOARD_BOARD_H + +/************************************************************ + * Included Files + ************************************************************/ + +/************************************************************ + * Definitions + ************************************************************/ + +/************************************************************ + * Inline Functions + ************************************************************/ + +#endif /* __ARCH_BOARD_BOARD_H */ diff --git a/nuttx/configs/pjrc-8051/include/pjrc.h b/nuttx/configs/pjrc-8051/include/pjrc.h new file mode 100644 index 000000000..50dfe01f2 --- /dev/null +++ b/nuttx/configs/pjrc-8051/include/pjrc.h @@ -0,0 +1,215 @@ +/************************************************************************** + * pjrc.h + * + * Copyright (C) 2007, 2009 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 Gregory Nutt 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 __PJRC_H +#define __PJRC_H + +/************************************************************************** + * Included Files + **************************************************************************/ + +#include + +/************************************************************************** + * Public Definitions + **************************************************************************/ + +/************************************************************************** + * Public Types + **************************************************************************/ + +/************************************************************************** + * Public Variables + **************************************************************************/ + +/* Memory Map + * + * BEGIN END DESCRIPTION + * 0x0000 0x1fff CODE: ROM containg PAULMON2 + * DATA: RAM for program variables + * 0x2000 0x7fff COMMON: RAM for program code or + * variables + * 0x8000 0xf7ff COMMON: FLASH for program code + * 0xf800 0xfeff COMMON: Peripherals + * 0xff00 0xffff COMMON: unused + * + * Program code may be loaded at the RAM location 0x2000-0x7fff + * for testing. If loaded into the FLASH location at + * 0x8000-0xf7ff, PAULMON2 will automatically write the program + * into flash. The program is configured in the RAM-based test + * configuration: + */ + +#define RAM_BLOCK_START IRAM_SIZE +#define RAM_BLOCK_END 0x1fff + +#define PROGRAM_BASE 0x2000 +#define PROGRAM_END 0x7fff + +#define FLASH_BASE 0x8000 +#define FLASH_END 0xf7ff + +/* Well-known entry points to access PAULMON2's built-in functions */ + +#define PM2_ENTRY_PHEX1 0x002e +#define PM2_ENTRY_COUT 0x0030 +#define PM2_ENTRY_CIN 0x0032 +#define PM2_ENTRY_PHEX 0x0034 +#define PM2_ENTRY_PHEX16 0x0036 +#define PM2_ENTRY_PSTR 0x0038 +#define PM2_ENTRY_ESC 0x003e +#define PM2_ENTRY_UPPER 0x0040 +#define PM2_ENTRY_PINT8U 0x004D +#define PM2_ENTRY_PINT8 0x0050 +#define PM2_ENTRY_PINT16U 0x0053 +#define PM2_ENTRY_NEWLINE 0x0048 +#define PM2_ENTRY_PRGM 0x0059 +#define PM2_ENTRY_ERBLOCK 0x0067 + +/* PAULMON2 captures all interrupt vectors in ROM but relays them + * through the following RAM addresses: + */ + +#define PM2_VECTOR_BASE PROGRAM_BASE +#define PM2_VECTOR_EXTINT0 (PM2_VECTOR_BASE + 3) +#define PM2_VECTOR_TIMER0 (PM2_VECTOR_BASE + 11) +#define PM2_VECTOR_EXTINT1 (PM2_VECTOR_BASE + 19) +#define PM2_VECTOR_TIMER1 (PM2_VECTOR_BASE + 27) +#define PM2_VECTOR_UART (PM2_VECTOR_BASE + 35) +#define PM2_VECTOR_TIMER2 (PM2_VECTOR_BASE + 43) + +/* Peripheral Mapping + * + * Begin End Peripheral Addr Acc Function + * F800 F8FF 82C55 (A, B, C) F800 R/W Port A + * F801 R/W Port B + * F802 R/W Port C + * F803 W Config A,B,C + * F900 F9FF 82C55 (D, E, F) F900 R/W Port D + * F901 R/W Port E (LEDs) + * F902 R/W Port F + * F903 W Config D,E,F + * FA00 FAFF User Expansion + * FB00 FBFF User Expansion + * FC00 FCFF User Expansion + * FD00 FDFF User Expansion + * FE00 FEFF LCD Port FE00 W Command Register + * FE01 R Status Register + * FE02 W Display or CGRAM Buffer + * FE03 R " " "" " " " " + * + * These are the memory-mapped locations used to access the two 82C55 + * chips + */ + +#ifndef __ASSEMBLY__ +xdata at 0xF800 uint8_t p82c55_port_a; +xdata at 0xF801 uint8_t p82c55_port_b; +xdata at 0xF802 uint8_t p82c55_port_c; +xdata at 0xF803 uint8_t p82c55_abc_config; +xdata at 0xF900 uint8_t p82c55_port_d; +xdata at 0xF901 uint8_t p82c55_port_e; +xdata at 0xF902 uint8_t p82c55_port_f; +xdata at 0xF903 uint8_t p82c55_def_config; +#endif + +/* LED (Port E) bit definitions */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 1 +#define LED_IRQSENABLED 2 +#define LED_IDLE 3 +#define LED_UNUSED2 4 +#define LED_INIRQ 5 +#define LED_ASSERTION 6 +#define LED_PANIC 7 + +/* Registers. 8052 regiser definitions are provided in the SDCC header + * file 8052.h. However, a few SFR registers are missing from that + * file (they can be found in mcs51reg.h, but that file is too much + * when the following simple addtions do the job). + */ + +#ifndef __ASSEMBLY__ +sfr at 0xc9 T2MOD ; +#endif + +/* Timing information. + * + * The PJRC board is based on a standard 87C52 CPU clocked at 22.1184 MHz. + * The CPU clock is divided by 12 to yield a clock frequency of 1.8432 MHz. + */ + +#define CPU_CLOCK_HZ 22118400L +#define TIMER_CLOCK_HZ 1843200L + +/* The 87C52 has three timers, timer 0, timer 1, and timer 2. On the PJRC + * board, timer 1 and 2 have dedicated functions. They provide baud support + * support for the boards two serial ports. Unfortunately, only timer 2 + * can generate the accurate 100Hz timer desired by the OS. + * + * Timer 0 provides only a 8-bit auto-reload mode. + */ + +#ifdef CONFIG_8052_TIMER2 + +/* To use timer 2 as the 100Hz system timer, we need to calculate a 16-bit + * reload value that results in 100Hz overflow interrupts. That value + * is given by: + * + * Timer ticks = TIMER_CLOCK_HZ / (desired ticks-per-second) + * = 18432 + * Capture value = 0xffff - (Timer ticks) + * = 47103 = 0x67ff + */ + +# define TIMER2_CAPTURE_LOW 0xff +# define TIMER2_CAPTURE_HIGH 0x67 + +#else + +/* Timer 0, mode 0 can be used as a system timer. In that mode, the + * 1.8432 is further divided by 32. A single 8-bit value is incremented + * at 57600 Hz, which results in 225 Timer 0 overflow interrupts per + * second. + */ + +#endif + +/************************************************************************** + * Public Function Prototypes + **************************************************************************/ + +#endif /* __PJRC_H */ diff --git a/nuttx/configs/pjrc-8051/sdcc-2.6.0.patch b/nuttx/configs/pjrc-8051/sdcc-2.6.0.patch new file mode 100644 index 000000000..beb8bf2ea --- /dev/null +++ b/nuttx/configs/pjrc-8051/sdcc-2.6.0.patch @@ -0,0 +1,28 @@ +diff -u sdcc/device/lib/Makefile.orig sdcc/device/lib/Makefile +--- sdcc/device/lib/Makefile.orig 2007-03-06 09:55:01.000000000 -0600 ++++ sdcc/device/lib/Makefile 2007-03-06 09:58:32.000000000 -0600 +@@ -242,7 +242,7 @@ + model-mcs51-stack-auto: + if [ "`grep mcs51 $(top_builddir)ports.build`" = mcs51 ]; then \ + for model in $(MODELS); do \ +- $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \ ++ $(MAKE) MODELFLAGS="--model-$$model --stack-auto --int-long-reent --float-reent" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \ + done \ + fi + +diff -u sdcc/device/include/stdarg.h.orig sdcc/device/include/stdarg.h +--- sdcc/device/include/stdarg.h.orig 2007-03-11 13:21:15.000000000 -0600 ++++ sdcc/device/include/stdarg.h 2007-03-11 13:26:59.000000000 -0600 +@@ -25,9 +25,9 @@ + + #else + +-typedef unsigned char __data * va_list ; +-#define va_arg(marker,type) *((type __data * )(marker -= sizeof(type))) +-#define va_start(marker,first) { marker = (va_list) ((char __data * )&first); } ++typedef unsigned char * va_list ; ++#define va_arg(marker,type) *((type * )(marker -= sizeof(type))) ++#define va_start(marker,first) { marker = (va_list) ((char * )&first); } + + #endif + diff --git a/nuttx/configs/pjrc-8051/setenv.sh b/nuttx/configs/pjrc-8051/setenv.sh new file mode 100755 index 000000000..35f5fffed --- /dev/null +++ b/nuttx/configs/pjrc-8051/setenv.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# pjrc-8051/setenv.sh +# +# Copyright (C) 2007, 2008 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. +# + +if [ "$(basename $0)" = "setenv.sh" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi + +export SDCC_BIN=/usr/local/bin +export PATH=${SDCC_BIN}:/sbin:/usr/sbin:${PATH_ORIG} + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/pjrc-8051/src/Makefile b/nuttx/configs/pjrc-8051/src/Makefile new file mode 100644 index 000000000..d6af2a6fe --- /dev/null +++ b/nuttx/configs/pjrc-8051/src/Makefile @@ -0,0 +1,76 @@ +############################################################################ +# configs/pjrc-8051/src/Makefile +# +# Copyright (C) 2007, 2008 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +CFLAGS += -I$(TOPDIR)/sched + +ASRCS = +AOBJS = $(ASRCS:.S=$(OBJEXT)) +CSRCS = up_leds.c +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +CFLAGS += -I $(TOPDIR)/arch/$(CONFIG_ARCH)/src + +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/pjrc-8051/src/README.txt b/nuttx/configs/pjrc-8051/src/README.txt new file mode 100644 index 000000000..74f820427 --- /dev/null +++ b/nuttx/configs/pjrc-8051/src/README.txt @@ -0,0 +1 @@ +This directory contains drivers unique to the PJRC 87C52 board. diff --git a/nuttx/configs/pjrc-8051/src/up_leds.c b/nuttx/configs/pjrc-8051/src/up_leds.c new file mode 100644 index 000000000..5ac842d1e --- /dev/null +++ b/nuttx/configs/pjrc-8051/src/up_leds.c @@ -0,0 +1,207 @@ +/************************************************************************ + * up_leds.c + * + * Copyright (C) 2007, 2009 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 Gregory Nutt nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************/ + +/************************************************************************ + * Included Files + ************************************************************************/ + +#include +#include +#include "up_internal.h" + +/************************************************************************ + * Definitions + ************************************************************************/ + +#define RESET_KLUDGE_NEEDED 1 + +/************************************************************************ + * Private Data + ************************************************************************/ + +static uint8_t g_ledstate; + +/************************************************************************ + * Private Functions + ************************************************************************/ + +#if defined(CONFIG_LED_DEBUG) && defined(CONFIG_ARCH_LEDS) +static void _up_puthex(uint8_t hex) __naked +{ + hex; /* To avoid unreferenced argument warning */ + _asm + mov a, dpl + ljmp PM2_ENTRY_PHEX + _endasm; +} + +static void _up_putch(uint8_t ch) __naked +{ + _asm + mov a, dpl + ljmp PM2_ENTRY_COUT + _endasm; +} + +static void _up_putnl(void) __naked +{ + _asm + ljmp PM2_ENTRY_NEWLINE + _endasm; +} + +# define _up_showledinit() \ + _up_putch('I'); \ + _up_puthex(g_ledstate); _up_putch(':'); \ + _up_puthex(p82c55_port_e); _up_putnl(); + +# define _up_showledreset() \ + _up_putch('R'); \ + _up_puthex(led); _up_putch(':'); \ + _up_puthex(g_ledstate); _up_putch(':'); \ + _up_puthex(p82c55_port_e); _up_putnl(); + +# define _up_showledon() \ + _up_putch('+'); \ + _up_puthex(led); _up_putch(':'); \ + _up_puthex(g_ledstate); _up_putch(':'); \ + _up_puthex(p82c55_port_e); _up_putnl(); + +# define _up_showledoff() \ + _up_putch('-'); \ + _up_puthex(led); _up_putch(':'); \ + _up_puthex(g_ledstate); _up_putch(':'); \ + _up_puthex(p82c55_port_e); _up_putnl(); + +#else + +# define _up_showledinit() +# define _up_showledreset() +# define _up_showledon() +# define _up_showledoff() + +#endif + +/************************************************************************ + * Public Funtions + ************************************************************************/ + +/************************************************************************ + * Name: up_ledinit + ************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void up_ledinit(void) +{ + /* Set all ports as outputs */ + + p82c55_def_config = 128; + + /* Turn LED 1-7 off; turn LED 0 on */ + + g_ledstate = 0xfe; + p82c55_port_e = g_ledstate; + + _up_showledinit(); +} + +/************************************************************************ + * Name: up_ledon + ************************************************************************/ + +void up_ledon(uint8_t led) +{ + /* This may be called from an interrupt handler */ + + irqstate_t flags = irqsave(); + +#ifdef RESET_KLUDGE_NEEDED + /* I don't understand why this happens yet, but sometimes + * it is necessary to reconfigure port E. + */ + + if (g_ledstate != p82c55_port_e) + { + _up_showledreset(); + p82c55_def_config = 128; + } +#endif + + /* Clear the bit in port E corresponding to LED to turn it on */ + + if (led < 8) + { + g_ledstate &= ~(g_ntobit[led]); + p82c55_port_e = g_ledstate; + } + + _up_showledon(); + irqrestore(flags); +} + +/************************************************************************ + * Name: up_ledoff + ************************************************************************/ + +void up_ledoff(uint8_t led) +{ + /* This may be called from an interrupt handler */ + + irqstate_t flags = irqsave(); + +#ifdef RESET_KLUDGE_NEEDED + /* I don't understand why this happens yet, but sometimes + * it is necessary to reconfigure port E. + */ + + if (g_ledstate != p82c55_port_e) + { + _up_showledreset(); + p82c55_def_config = 128; + } +#endif + + /* Set the bit in port E corresponding to LED to turn it off */ + + if (led < 8) + { + g_ledstate |= g_ntobit[led]; + p82c55_port_e = g_ledstate; + } + + _up_showledoff(); + irqrestore(flags); +} +#endif /* CONFIG_ARCH_LEDS */ -- cgit v1.2.3