mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 11:23:06 +08:00
Merge branch 'master' of https://github.com/PX4/Firmware into fmuv2_bringup
This commit is contained in:
@@ -24,3 +24,4 @@ Firmware.sublime-workspace
|
||||
Images/*.bin
|
||||
Images/*.px4
|
||||
mavlink/include/mavlink/v0.9/
|
||||
NuttX
|
||||
@@ -145,9 +145,9 @@ ifneq ($(filter archives,$(MAKECMDGOALS)),)
|
||||
endif
|
||||
|
||||
$(ARCHIVE_DIR)%.export: board = $(notdir $(basename $@))
|
||||
$(ARCHIVE_DIR)%.export: configuration = $(if $(filter px4io px4iov2,$(board)),io,nsh)
|
||||
$(ARCHIVE_DIR)%.export: configuration = nsh
|
||||
$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
||||
@echo %% Configuring NuttX for $(board)/$(configuration)
|
||||
@echo %% Configuring NuttX for $(board)
|
||||
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
||||
$(Q) make -r -j1 -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||
$(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(board)/$(configuration))
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#!nsh
|
||||
#
|
||||
# Flight startup script for PX4FMU on PX4IOAR carrier board.
|
||||
#
|
||||
|
||||
# Disable the USB interface
|
||||
set USB no
|
||||
|
||||
# Disable autostarting other apps
|
||||
set MODE ardrone
|
||||
|
||||
echo "[init] doing PX4IOAR startup..."
|
||||
|
||||
#
|
||||
# Start the ORB
|
||||
#
|
||||
uorb start
|
||||
|
||||
#
|
||||
# Load microSD params
|
||||
#
|
||||
echo "[init] loading microSD params"
|
||||
param select /fs/microsd/params
|
||||
if [ -f /fs/microsd/params ]
|
||||
then
|
||||
param load /fs/microsd/params
|
||||
fi
|
||||
|
||||
#
|
||||
# Force some key parameters to sane values
|
||||
# MAV_TYPE 1 = fixed wing, 2 = quadrotor, 13 = hexarotor
|
||||
# see https://pixhawk.ethz.ch/mavlink/
|
||||
#
|
||||
param set MAV_TYPE 2
|
||||
|
||||
#
|
||||
# Configure PX4FMU for operation with PX4IOAR
|
||||
#
|
||||
fmu mode_gpio_serial
|
||||
|
||||
#
|
||||
# Start the sensors.
|
||||
#
|
||||
sh /etc/init.d/rc.sensors
|
||||
|
||||
#
|
||||
# Start MAVLink and MAVLink Onboard (Flow Sensor)
|
||||
#
|
||||
mavlink start -d /dev/ttyS0 -b 57600
|
||||
mavlink_onboard start -d /dev/ttyS3 -b 115200
|
||||
usleep 5000
|
||||
|
||||
#
|
||||
# Start the commander.
|
||||
#
|
||||
commander start
|
||||
|
||||
#
|
||||
# Start the attitude estimator
|
||||
#
|
||||
attitude_estimator_ekf start
|
||||
|
||||
#
|
||||
# Start the position estimator
|
||||
#
|
||||
flow_position_estimator start
|
||||
|
||||
#
|
||||
# Fire up the multi rotor attitude controller
|
||||
#
|
||||
multirotor_att_control start
|
||||
|
||||
#
|
||||
# Fire up the flow position controller
|
||||
#
|
||||
flow_position_control start
|
||||
|
||||
#
|
||||
# Fire up the flow speed controller
|
||||
#
|
||||
flow_speed_control start
|
||||
|
||||
#
|
||||
# Fire up the AR.Drone interface.
|
||||
#
|
||||
ardrone_interface start -d /dev/ttyS1
|
||||
|
||||
#
|
||||
# startup is done; we don't want the shell because we
|
||||
# use the same UART for telemetry
|
||||
#
|
||||
echo "[init] startup done"
|
||||
|
||||
exit
|
||||
@@ -54,13 +54,13 @@ sh /etc/init.d/rc.sensors
|
||||
#
|
||||
# Start the attitude estimator (depends on orb)
|
||||
#
|
||||
kalman_demo start
|
||||
att_pos_estimator_ekf start
|
||||
|
||||
#
|
||||
# Load mixer and start controllers (depends on px4io)
|
||||
#
|
||||
mixer load /dev/pwm_output /etc/mixers/FMU_AET.mix
|
||||
control_demo start
|
||||
fixedwing_backside start
|
||||
|
||||
echo "[HIL] setup done, running"
|
||||
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
#!nsh
|
||||
#
|
||||
# PX4FMU startup script.
|
||||
#
|
||||
# This script is responsible for:
|
||||
#
|
||||
# - mounting the microSD card (if present)
|
||||
# - running the user startup script from the microSD card (if present)
|
||||
# - detecting the configuration of the system and picking a suitable
|
||||
# startup script to continue with
|
||||
#
|
||||
# Note: DO NOT add configuration-specific commands to this script;
|
||||
# add them to the per-configuration scripts instead.
|
||||
#
|
||||
|
||||
#
|
||||
# Default to auto-start mode. An init script on the microSD card
|
||||
@@ -20,11 +9,6 @@
|
||||
set MODE autostart
|
||||
set USB autoconnect
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Try to mount the microSD card.
|
||||
#
|
||||
@@ -69,7 +53,12 @@ else
|
||||
then
|
||||
echo "[init] USB interface connected"
|
||||
else
|
||||
echo "[init] No USB connected"
|
||||
if [ -f /dev/ttyACM0 ]
|
||||
echo "[init] NSH via USB"
|
||||
then
|
||||
else
|
||||
echo "[init] No USB connected"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
*.a
|
||||
*.bdat
|
||||
*.pdat
|
||||
.built
|
||||
.config
|
||||
.depend
|
||||
.updated
|
||||
builtin/builtin_list.h
|
||||
builtin/builtin_proto.h
|
||||
Make.dep
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
menu "Built-In Applications"
|
||||
source "$APPSDIR/builtin/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Examples"
|
||||
source "$APPSDIR/examples/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Interpreters"
|
||||
source "$APPSDIR/interpreters/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Network Utilities"
|
||||
source "$APPSDIR/netutils/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "ModBus"
|
||||
source "$APPSDIR/modbus/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "NSH Library"
|
||||
source "$APPSDIR/nshlib/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "NxWidgets/NxWM"
|
||||
source "$APPSDIR/NxWidgets/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "System NSH Add-Ons"
|
||||
source "$APPSDIR/system/Kconfig"
|
||||
endmenu
|
||||
@@ -1,50 +0,0 @@
|
||||
############################################################################
|
||||
# apps/Make.defs
|
||||
# Common make definitions provided to all applications
|
||||
#
|
||||
# Copyright (C) 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_NEWCONFIG),y)
|
||||
DEPCONFIG = $(TOPDIR)$(DELIM).config
|
||||
else
|
||||
DEPCONFIG = $(TOPDIR)$(DELIM).config $(APPDIR)$(DELIM).config
|
||||
endif
|
||||
|
||||
define REGISTER
|
||||
$(Q) echo "Register: $1"
|
||||
$(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$4.bdat"
|
||||
$(Q) echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$4.pdat"
|
||||
$(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated"
|
||||
endef
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
############################################################################
|
||||
# apps/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-2012 Uros Platise. All rights reserved.
|
||||
# Authors: Uros Platise <uros.platise@isotel.eu>
|
||||
# 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
|
||||
-include $(TOPDIR)/.config
|
||||
|
||||
APPDIR = ${shell pwd}
|
||||
|
||||
# Application Directories
|
||||
|
||||
# CONFIGURED_APPS is the list of all configured built-in directories/built
|
||||
# action. It is created by the configured appconfig file (a copy of which
|
||||
# appears in this directory as .config)
|
||||
# SUBDIRS is the list of all directories containing Makefiles. It is used
|
||||
# only for cleaning. builtin must always be the first in the list. This
|
||||
# list can be extended by the .config file as well.
|
||||
|
||||
CONFIGURED_APPS =
|
||||
|
||||
SUBDIRS = examples interpreters builtin nshlib system
|
||||
|
||||
#SUBDIRS = examples graphics interpreters modbus builtin nshlib netutils system
|
||||
|
||||
# There are two different mechanisms for obtaining the list of configured
|
||||
# directories:
|
||||
#
|
||||
# (1) In the legacy method, these paths are all provided in the appconfig
|
||||
# file that is copied to the top-level apps/ directory as .config
|
||||
# (2) With the development of the NuttX configuration tool, however, the
|
||||
# selected applications are now enabled by the configuration tool.
|
||||
# The apps/.config file is no longer used. Instead, the set of
|
||||
# configured build directories can be found by including a Make.defs
|
||||
# file contained in each of the apps/subdirectories.
|
||||
#
|
||||
# When the NuttX configuration tools executes, it will always define the
|
||||
# configure CONFIG_NUTTX_NEWCONFIG to select between these two cases. Then
|
||||
# legacy appconfig files will still work but newly configuration files will
|
||||
# also work. Eventually the CONFIG_NUTTX_NEWCONFIG option will be phased
|
||||
# out.
|
||||
|
||||
ifeq ($(CONFIG_NUTTX_NEWCONFIG),y)
|
||||
|
||||
# builtin/Make.defs must be included first
|
||||
|
||||
include builtin/Make.defs
|
||||
include examples/Make.defs
|
||||
include graphics/Make.defs
|
||||
include interpreters/Make.defs
|
||||
include modbus/Make.defs
|
||||
include netutils/Make.defs
|
||||
include nshlib/Make.defs
|
||||
include system/Make.defs
|
||||
|
||||
# INSTALLED_APPS is the list of currently available application directories. It
|
||||
# is the same as CONFIGURED_APPS, but filtered to exclude any non-existent
|
||||
# application directory. builtin is always in the list of applications to be
|
||||
# built.
|
||||
|
||||
INSTALLED_APPS =
|
||||
|
||||
# The legacy case:
|
||||
|
||||
else
|
||||
-include .config
|
||||
|
||||
# INSTALLED_APPS is the list of currently available application directories. It
|
||||
# is the same as CONFIGURED_APPS, but filtered to exclude any non-existent
|
||||
# application directory. builtin is always in the list of applications to be
|
||||
# built.
|
||||
|
||||
INSTALLED_APPS = builtin
|
||||
endif
|
||||
|
||||
# Create the list of available applications (INSTALLED_APPS)
|
||||
|
||||
define ADD_BUILTIN
|
||||
INSTALLED_APPS += $(if $(wildcard $1$(DELIM)Makefile),$1,)
|
||||
endef
|
||||
|
||||
$(foreach BUILTIN, $(CONFIGURED_APPS), $(eval $(call ADD_BUILTIN,$(BUILTIN))))
|
||||
|
||||
# EXTERNAL_APPS is used to add out of tree apps to the build
|
||||
INSTALLED_APPS += $(EXTERNAL_APPS)
|
||||
|
||||
# The external/ directory may also be added to the INSTALLED_APPS. But there
|
||||
# is no external/ directory in the repository. Rather, this directory may be
|
||||
# provided by the user (possibly as a symbolic link) to add libraries and
|
||||
# applications to the standard build from the repository.
|
||||
|
||||
EXTERNAL_DIR := $(dir $(wildcard external$(DELIM)Makefile))
|
||||
|
||||
INSTALLED_APPS += $(EXTERNAL_DIR)
|
||||
SUBDIRS += $(EXTERNAL_DIR)
|
||||
|
||||
# The final build target
|
||||
|
||||
BIN = libapps$(LIBEXT)
|
||||
|
||||
# Build targets
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: $(INSTALLED_APPS) context depend clean distclean
|
||||
|
||||
$(INSTALLED_APPS):
|
||||
$(Q) $(MAKE) -C $@ TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
|
||||
$(BIN): $(INSTALLED_APPS)
|
||||
|
||||
context:
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for %%G in ($(INSTALLED_APPS)) do ( \
|
||||
$(MAKE) -C %%G TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context \
|
||||
)
|
||||
else
|
||||
$(Q) for dir in $(INSTALLED_APPS) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" context ; \
|
||||
done
|
||||
endif
|
||||
|
||||
.depend: context Makefile $(SRCS)
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for %%G in ($(INSTALLED_APPS)) do ( \
|
||||
if exist %%G\.depend del /f /q %%G\.depend \
|
||||
$(MAKE) -C %%G TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" depend \
|
||||
)
|
||||
else
|
||||
$(Q) for dir in $(INSTALLED_APPS) ; do \
|
||||
rm -f $$dir/.depend ; \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" depend ; \
|
||||
done
|
||||
endif
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for %%G in ($(SUBDIRS)) do ( \
|
||||
$(MAKE) -C %%G clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \
|
||||
)
|
||||
else
|
||||
$(Q) for dir in $(SUBDIRS) ; do \
|
||||
$(MAKE) -C $$dir clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \
|
||||
done
|
||||
endif
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call CLEAN)
|
||||
|
||||
distclean:
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for %%G in ($(SUBDIRS)) do ( \
|
||||
$(MAKE) -C %%G distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" \
|
||||
)
|
||||
$(call DELFILE, .config)
|
||||
$(call DELFILE, .depend)
|
||||
$(Q) ( if exist external ( \
|
||||
echo ********************************************************" \
|
||||
echo * The external directory/link must be removed manually *" \
|
||||
echo ********************************************************" \
|
||||
)
|
||||
else
|
||||
$(Q) for dir in $(SUBDIRS) ; do \
|
||||
$(MAKE) -C $$dir distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \
|
||||
done
|
||||
$(call DELFILE, .config)
|
||||
$(call DELFILE, .depend)
|
||||
$(Q) ( if [ -e external ]; then \
|
||||
echo "********************************************************"; \
|
||||
echo "* The external directory/link must be removed manually *"; \
|
||||
echo "********************************************************"; \
|
||||
fi; \
|
||||
)
|
||||
endif
|
||||
|
||||
|
||||
-273
@@ -1,273 +0,0 @@
|
||||
Application Folder
|
||||
==================
|
||||
|
||||
Contents
|
||||
--------
|
||||
|
||||
General
|
||||
Directory Location
|
||||
Built-In Applications
|
||||
NuttShell (NSH) Built-In Commands
|
||||
Synchronous Built-In Commands
|
||||
Application Configuration File
|
||||
Example Built-In Application
|
||||
Building NuttX with Board-Specific Pieces Outside the Source Tree
|
||||
|
||||
General
|
||||
-------
|
||||
This folder provides various applications found in sub-directories. These
|
||||
applications are not inherently a part of NuttX but are provided to help
|
||||
you develop your own applications. The apps/ directory is a "break away"
|
||||
part of the configuration that you may choose to use or not.
|
||||
|
||||
Directory Location
|
||||
------------------
|
||||
The default application directory used by the NuttX build should be named
|
||||
apps/ (or apps-x.y/ where x.y is the NuttX version number). This apps/
|
||||
directory should appear in the directory tree at the same level as the
|
||||
NuttX directory. Like:
|
||||
|
||||
.
|
||||
|- nuttx
|
||||
|
|
||||
`- apps
|
||||
|
||||
If all of the above conditions are TRUE, then NuttX will be able to
|
||||
find the application directory. If your application directory has a
|
||||
different name or is location at a different position, then you will
|
||||
have to inform the NuttX build system of that location. There are several
|
||||
ways to do that:
|
||||
|
||||
1) You can define CONFIG_APPS_DIR to be the full path to your application
|
||||
directory in the NuttX configuration file.
|
||||
2) You can provide the path to the application directory on the command line
|
||||
like: make APPDIR=<path> or make CONFIG_APPS_DIR=<path>
|
||||
3) When you configure NuttX using tools/configure.sh, you can provide that
|
||||
path to the application directory on the configuration command line
|
||||
like: ./configure.sh -a <app-dir> <board-name>/<config-name>
|
||||
|
||||
Built-In Applications
|
||||
---------------------
|
||||
NuttX also supports applications that can be started using a name string.
|
||||
In this case, application entry points with their requirements are gathered
|
||||
together in two files:
|
||||
|
||||
- builtin/builtin_proto.h Entry points, prototype function
|
||||
- builtin/builtin_list.h Application specific information and requirements
|
||||
|
||||
The build occurs in several phases as different build targets are executed:
|
||||
(1) context, (2) depend, and (3) default (all). Application information is
|
||||
collected during the make context build phase.
|
||||
|
||||
To execute an application function:
|
||||
|
||||
exec_builtin() is defined in the nuttx/include/apps/builtin.h
|
||||
|
||||
NuttShell (NSH) Built-In Commands
|
||||
---------------------------------
|
||||
One use of builtin applications is to provide a way of invoking your custom
|
||||
application through the NuttShell (NSH) command line. NSH will support
|
||||
a seamless method invoking the applications, when the following option is
|
||||
enabled in the NuttX configuration file:
|
||||
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
|
||||
Applications registered in the apps/builtin/builtin_list.h file will then
|
||||
be accessible from the NSH command line. If you type 'help' at the NSH
|
||||
prompt, you will see a list of the registered commands.
|
||||
|
||||
Synchronous Built-In Commands
|
||||
-----------------------------
|
||||
By default, built-in commands started from the NSH command line will run
|
||||
asynchronously with NSH. If you want to force NSH to execute commands
|
||||
then wait for the command to execute, you can enable that feature by
|
||||
adding the following to the NuttX configuration file:
|
||||
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
|
||||
The configuration option enables support for the waitpid() RTOS interface.
|
||||
When that interface is enabled, NSH will use it to wait, sleeping until
|
||||
the built-in command executes to completion.
|
||||
|
||||
Of course, even with CONFIG_SCHED_WAITPID=y defined, specific commands
|
||||
can still be forced to run asynchronously by adding the ampersand (&)
|
||||
after the NSH command.
|
||||
|
||||
Application Configuration File
|
||||
------------------------------
|
||||
The old-style NuttX configuration uses a special configuration file is
|
||||
used to configure which applications are to be included in the build.
|
||||
The source for this file is configs/<board>/<configuration>/appconfig.
|
||||
The existence of the appconfig file in the board configuration directory\
|
||||
is sufficient to enable building of applications.
|
||||
|
||||
The appconfig file is copied into the apps/ directory as .config when
|
||||
NuttX is configured. .config is included in the toplevel apps/Makefile.
|
||||
As a minimum, this configuration file must define files to add to the
|
||||
CONFIGURED_APPS list like:
|
||||
|
||||
CONFIGURED_APPS += examples/hello system/poweroff
|
||||
|
||||
The new NuttX configuration uses kconfig-frontends tools and only the
|
||||
NuttX .config file. The new configuration is indicated by the existence
|
||||
of the definition CONFIG_NUTTX_NEWCONFIG=y in the NuttX .config file.
|
||||
If CONFIG_NUTTX_NEWCONFIG is defined, then the Makefile will:
|
||||
|
||||
- Assume that there is no apps/.config file and will instead
|
||||
- Include Make.defs files from each of the subdirectories.
|
||||
|
||||
When an application is enabled using the kconfig-frontends tool, then
|
||||
a new definition is added to the NuttX .config file. For example, if
|
||||
you want to enable apps/examples/hello then the old apps/.config would
|
||||
have had:
|
||||
|
||||
CONFIGURED_APPS += examples/hello
|
||||
|
||||
But in the new configuration there will be no apps/.config file and,
|
||||
instead, the NuttX .config will have:
|
||||
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
|
||||
This will select the apps/examples/hello in the following way:
|
||||
|
||||
- The top-level make will include examples/Make.defs
|
||||
- examples/Make.defs will set CONFIGURED_APPS += examples/hello
|
||||
like this:
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLO),y)
|
||||
CONFIGURED_APPS += examples/hello
|
||||
endif
|
||||
|
||||
Thus accomplishing the same thing with no apps/.config file.
|
||||
|
||||
Example Built-In Application
|
||||
----------------------------
|
||||
An example application skeleton can be found under the examples/hello
|
||||
sub-directory. This example shows how a builtin application can be added
|
||||
to the project. One must define:
|
||||
|
||||
Old configuration method:
|
||||
|
||||
1. Create sub-directory as: appname
|
||||
|
||||
2. In this directory there should be:
|
||||
|
||||
- A Makefile, and
|
||||
- The application source code.
|
||||
|
||||
3. The application source code should provide the entry point:
|
||||
appname_main()
|
||||
|
||||
4. Set the requirements in the file: Makefile, specially the lines:
|
||||
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
|
||||
Look at some of the other Makefiles for examples. Note the
|
||||
special registration logic needed for the context: target
|
||||
|
||||
5. Add the to the application to the CONFIGIURED_APPS in the
|
||||
apps/.config file:
|
||||
|
||||
CONFIGURED_APPS += appname
|
||||
|
||||
New Configuration Method:
|
||||
|
||||
1. Create sub-directory as: appname
|
||||
|
||||
2. In this directory there should be:
|
||||
|
||||
- A Make.defs file that would be included by the apps/Makefile
|
||||
- A Kconfig file that would be used by the configuration tool (see
|
||||
misc/tools/kconfig-language.txt). This Kconfig file should be
|
||||
included by the apps/Kconfig file
|
||||
- A Makefile, and
|
||||
- The application source code.
|
||||
|
||||
3. The application source code should provide the entry point:
|
||||
appname_main()
|
||||
|
||||
4. Set the requirements in the file: Makefile, specially the lines:
|
||||
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
|
||||
4b. The Make.defs file should include a line like:
|
||||
|
||||
ifeq ($(CONFIG_APPNAME),y)
|
||||
CONFIGURED_APPS += appname
|
||||
endif
|
||||
|
||||
Building NuttX with Board-Specific Pieces Outside the Source Tree
|
||||
-----------------------------------------------------------------
|
||||
|
||||
Q: Has anyone come up with a tidy way to build NuttX with board-
|
||||
specific pieces outside the source tree?
|
||||
A: Here are four:
|
||||
|
||||
1) There is a make target called 'make export'. It will build
|
||||
NuttX, then bundle all of the header files, libaries, startup
|
||||
objects, and other build components into a .zip file. You
|
||||
can can move that .zip file into any build environment you
|
||||
want. You even build NuttX under a DOS CMD window.
|
||||
|
||||
This make target is documented in the top level nuttx/README.txt.
|
||||
|
||||
2) You can replace the entire apps/ directory. If there is
|
||||
nothing in the apps/ directory that you need, you can define
|
||||
CONFIG_APPS_DIR in your .config file so that it points to a
|
||||
different, custom application directory.
|
||||
|
||||
You can copy any pieces that you like from the old apps/directory
|
||||
to your custom apps directory as necessary.
|
||||
|
||||
This is documented in NuttX/configs/README.txt and
|
||||
nuttx/Documentation/NuttxPortingGuide.html (Online at
|
||||
http://nuttx.sourceforge.net/NuttxPortingGuide.html#apndxconfigs
|
||||
under Build options). And in the apps/README.txt file.
|
||||
|
||||
3) If you like the random collection of stuff in the apps/ directory
|
||||
but just want to expand the existing components with your own,
|
||||
external sub-directory then there is an easy way to that too:
|
||||
You just create the sympolic link at apps/external that
|
||||
redirects to your application sub-directory. The apps/Makefile
|
||||
will always automatically check for the existence of an
|
||||
apps/external directory and if it exists, it will automatically
|
||||
incorporate it into the build.
|
||||
|
||||
This feature of the apps/Makefile is documented only here.
|
||||
|
||||
You can, for example, create a script called install.sh that
|
||||
installs a custom application, configuration, and board specific
|
||||
directory:
|
||||
|
||||
a) Copy 'MyBoard' directory to configs/MyBoard.
|
||||
b) Add a symbolic link to MyApplication at apps/external
|
||||
c) Configure NuttX (usually by:
|
||||
|
||||
tools/configure.sh MyBoard/MyConfiguration
|
||||
|
||||
or simply by copying defconfig->nutt/.config,
|
||||
setenv.sh->nuttx/setenv.sh, Make.defs->nuttx/Make.defs,
|
||||
appconfig->apps/.config
|
||||
|
||||
Using the 'external' link makes it especially easy to add a
|
||||
'built-in' application an existing configuration.
|
||||
|
||||
4) Add any link to apps/
|
||||
|
||||
a) Add symbolic links apps/ to as many other directories as you
|
||||
want.
|
||||
b) Then just add the (relative) paths to the links in your
|
||||
appconfig file (that becomes the apps/.config file).
|
||||
|
||||
That is basically the same as my option #3 but doesn't use the
|
||||
magic 'external' link. The toplevel apps/Makefile will always
|
||||
to build whatever in finds in the apps/.config file (plus the
|
||||
external link if present).
|
||||
@@ -1,17 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
if BUILTIN
|
||||
|
||||
config BUILTIN_PROXY_STACKSIZE
|
||||
int "Builtin Proxy Stack Size"
|
||||
default 1024
|
||||
---help---
|
||||
If exec_builtin uses I/O redirection options, then it will require
|
||||
an intermediary/proxy task to muck with the file descriptors. This
|
||||
configuration item specifies the stack size used for the proxy. Default:
|
||||
1024 bytes.
|
||||
|
||||
endif
|
||||
@@ -1,40 +0,0 @@
|
||||
############################################################################
|
||||
# apps/builtin/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_BUILTIN),y)
|
||||
CONFIGURED_APPS += builtin
|
||||
endif
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
############################################################################
|
||||
# apps/builtin/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Source and object files
|
||||
|
||||
ASRCS =
|
||||
CSRCS = builtin.c builtin_list.c exec_builtin.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
VPATH =
|
||||
|
||||
# Build Targets
|
||||
|
||||
all: .built
|
||||
.PHONY: context depend clean distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
registry$(DELIM).updated:
|
||||
$(V) $(MAKE) -C registry .updated TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
|
||||
builtin_list.h: registry$(DELIM).updated
|
||||
$(call DELFILE, builtin_list.h)
|
||||
$(Q) touch builtin_list.h
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for /f %%G in ('dir /b registry\*.bdat`) do ( type registry\%%G >> builtin_list.h )
|
||||
else
|
||||
$(Q) ( \
|
||||
filelist=`ls registry/*.bdat 2>/dev/null || echo ""`; \
|
||||
for file in $$filelist; \
|
||||
do cat $$file >> builtin_list.h; \
|
||||
done; \
|
||||
)
|
||||
endif
|
||||
|
||||
builtin_proto.h: registry$(DELIM).updated
|
||||
$(call DELFILE, builtin_proto.h)
|
||||
$(Q) touch builtin_proto.h
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
$(Q) for /f %%G in ('dir /b registry\*.pdat`) do ( type registry\%%G >> builtin_proto.h )
|
||||
else
|
||||
$(Q) ( \
|
||||
filelist=`ls registry/*.pdat 2>/dev/null || echo ""`; \
|
||||
for file in $$filelist; \
|
||||
do cat $$file >> builtin_proto.h; \
|
||||
done; \
|
||||
)
|
||||
endif
|
||||
|
||||
.built: builtin_list.h builtin_proto.h $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
$(Q) touch .built
|
||||
|
||||
context:
|
||||
$(Q) $(MAKE) -C registry context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
|
||||
.depend: Makefile $(SRCS) builtin_list.h builtin_proto.h
|
||||
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
$(Q) touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(Q) $(MAKE) -C registry clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(Q) $(MAKE) -C registry distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
$(call DELFILE, builtin_list.h)
|
||||
$(call DELFILE, builtin_proto.h)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
* apps/builtin/builtin.c
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Authors: Uros Platise <uros.platise@isotel.eu>
|
||||
* 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 <nuttx/binfmt/builtin.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern const struct builtin_s g_builtins[];
|
||||
extern const int g_builtin_count;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
FAR const struct builtin_s *builtin_for_index(int index)
|
||||
{
|
||||
if (index < g_builtin_count)
|
||||
{
|
||||
return &g_builtins[index];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
* apps/builtin/builtin_list.c
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Authors: Uros Platise <uros.platise@isotel.eu>
|
||||
* 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 <nuttx/binfmt/builtin.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#include "builtin_proto.h"
|
||||
|
||||
const struct builtin_s g_builtins[] =
|
||||
{
|
||||
# include "builtin_list.h"
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
const int g_builtin_count = sizeof(g_builtins) / sizeof(g_builtins[0]);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1,467 +0,0 @@
|
||||
/****************************************************************************
|
||||
* apps/builtin/exec_builtin.c
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* With subsequent updates, modifications, and general maintenance by:
|
||||
*
|
||||
* Copyright (C) 2012-2013 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 <sys/wait.h>
|
||||
#include <sched.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <apps/builtin.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_BUILTIN_PROXY_STACKSIZE
|
||||
# define CONFIG_BUILTIN_PROXY_STACKSIZE 1024
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct builtin_parms_s
|
||||
{
|
||||
/* Input values */
|
||||
|
||||
FAR const char *redirfile;
|
||||
FAR const char **argv;
|
||||
int oflags;
|
||||
int index;
|
||||
|
||||
/* Returned values */
|
||||
|
||||
pid_t result;
|
||||
int errcode;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static sem_t g_builtin_parmsem = SEM_INITIALIZER(1);
|
||||
#ifndef CONFIG_SCHED_WAITPID
|
||||
static sem_t g_builtin_execsem = SEM_INITIALIZER(0);
|
||||
#endif
|
||||
static struct builtin_parms_s g_builtin_parms;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bultin_semtake and builtin_semgive
|
||||
*
|
||||
* Description:
|
||||
* Give and take semaphores
|
||||
*
|
||||
* Input Parameters:
|
||||
*
|
||||
* sem - The semaphore to act on.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void bultin_semtake(FAR sem_t *sem)
|
||||
{
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
ret = sem_wait(sem);
|
||||
ASSERT(ret == 0 || get_errno() == EINTR);
|
||||
}
|
||||
while (ret != 0);
|
||||
}
|
||||
|
||||
#define builtin_semgive(sem) sem_post(sem)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_taskcreate
|
||||
*
|
||||
* Description:
|
||||
* Execute the builtin task
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the task ID of the builtin task is returned; On failure, -1
|
||||
* (ERROR) is returned and the errno is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int builtin_taskcreate(int index, FAR const char **argv)
|
||||
{
|
||||
FAR const struct builtin_s *b;
|
||||
int ret;
|
||||
|
||||
b = builtin_for_index(index);
|
||||
|
||||
if (b == NULL)
|
||||
{
|
||||
set_errno(ENOENT);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Disable pre-emption. This means that although we start the builtin
|
||||
* application here, it will not actually run until pre-emption is
|
||||
* re-enabled below.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
|
||||
/* Start the builtin application task */
|
||||
|
||||
ret = TASK_CREATE(b->name, b->priority, b->stacksize, b->main,
|
||||
(argv) ? &argv[1] : (FAR const char **)NULL);
|
||||
|
||||
/* If robin robin scheduling is enabled, then set the scheduling policy
|
||||
* of the new task to SCHED_RR before it has a chance to run.
|
||||
*/
|
||||
|
||||
#if CONFIG_RR_INTERVAL > 0
|
||||
if (ret > 0)
|
||||
{
|
||||
struct sched_param param;
|
||||
|
||||
/* Pre-emption is disabled so the task creation and the
|
||||
* following operation will be atomic. The priority of the
|
||||
* new task cannot yet have changed from its initial value.
|
||||
*/
|
||||
|
||||
param.sched_priority = b->priority;
|
||||
(void)sched_setscheduler(ret, SCHED_RR, ¶m);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now let the builtin application run */
|
||||
|
||||
sched_unlock();
|
||||
|
||||
/* Return the task ID of the new task if the task was sucessfully
|
||||
* started. Otherwise, ret will be ERROR (and the errno value will
|
||||
* be set appropriately).
|
||||
*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_proxy
|
||||
*
|
||||
* Description:
|
||||
* Perform output redirection, then execute the builtin task.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Standard task start-up parameters
|
||||
*
|
||||
* Returned Value:
|
||||
* Standard task return value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int builtin_proxy(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Open the output file for redirection */
|
||||
|
||||
svdbg("Open'ing redirfile=%s oflags=%04x mode=0644\n",
|
||||
g_builtin_parms.redirfile, g_builtin_parms.oflags);
|
||||
|
||||
fd = open(g_builtin_parms.redirfile, g_builtin_parms.oflags, 0644);
|
||||
if (fd < 0)
|
||||
{
|
||||
/* Remember the errno value. ret is already set to ERROR */
|
||||
|
||||
g_builtin_parms.errcode = get_errno();
|
||||
sdbg("ERROR: open of %s failed: %d\n",
|
||||
g_builtin_parms.redirfile, g_builtin_parms.errcode);
|
||||
}
|
||||
|
||||
/* Does the return file descriptor happen to match the required file
|
||||
* desciptor number?
|
||||
*/
|
||||
|
||||
else if (fd != 1)
|
||||
{
|
||||
/* No.. dup2 to get the correct file number */
|
||||
|
||||
svdbg("Dup'ing %d->1\n", fd);
|
||||
|
||||
ret = dup2(fd, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
g_builtin_parms.errcode = get_errno();
|
||||
sdbg("ERROR: dup2 failed: %d\n", g_builtin_parms.errcode);
|
||||
}
|
||||
|
||||
svdbg("Closing fd=%d\n", fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* Was the setup successful? */
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Yes.. Start the task. On success, the task ID of the builtin task
|
||||
* is returned; On failure, -1 (ERROR) is returned and the errno
|
||||
* is set appropriately.
|
||||
*/
|
||||
|
||||
ret = builtin_taskcreate(g_builtin_parms.index, g_builtin_parms.argv);
|
||||
if (ret < 0)
|
||||
{
|
||||
g_builtin_parms.errcode = get_errno();
|
||||
sdbg("ERROR: builtin_taskcreate failed: %d\n",
|
||||
g_builtin_parms.errcode);
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: There is a logical error here if CONFIG_SCHED_HAVE_PARENT is
|
||||
* defined: The new task is the child of this proxy task, not the
|
||||
* original caller. As a consequence, operations like waitpid() will
|
||||
* fail on the caller's thread.
|
||||
*/
|
||||
|
||||
/* Post the semaphore to inform the parent task that we have completed
|
||||
* what we need to do.
|
||||
*/
|
||||
|
||||
g_builtin_parms.result = ret;
|
||||
#ifndef CONFIG_SCHED_WAITPID
|
||||
builtin_semgive(&g_builtin_execsem);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_startproxy
|
||||
*
|
||||
* Description:
|
||||
* Perform output redirection, then execute the builtin task.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Standard task start-up parameters
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the task ID of the builtin task is returned; On failure, -1
|
||||
* (ERROR) is returned and the errno is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int builtin_startproxy(int index, FAR const char **argv,
|
||||
FAR const char *redirfile, int oflags)
|
||||
{
|
||||
struct sched_param param;
|
||||
pid_t proxy;
|
||||
int errcode = OK;
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
int status;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
svdbg("index=%d argv=%p redirfile=%s oflags=%04x\n",
|
||||
index, argv, redirfile, oflags);
|
||||
|
||||
/* We will have to go through an intermediary/proxy task in order to
|
||||
* perform the I/O redirection. This would be a natural place to fork().
|
||||
* However, true fork() behavior requires an MMU and most implementations
|
||||
* of vfork() are not capable of these operations.
|
||||
*
|
||||
* Even without fork(), we can still do the job, but parameter passing is
|
||||
* messier. Unfortunately, there is no (clean) way to pass binary values
|
||||
* as a task parameter, so we will use a semaphore-protected global
|
||||
* structure.
|
||||
*/
|
||||
|
||||
/* Get exclusive access to the global parameter structure */
|
||||
|
||||
bultin_semtake(&g_builtin_parmsem);
|
||||
|
||||
/* Populate the parameter structure */
|
||||
|
||||
g_builtin_parms.redirfile = redirfile;
|
||||
g_builtin_parms.argv = argv;
|
||||
g_builtin_parms.result = ERROR;
|
||||
g_builtin_parms.oflags = oflags;
|
||||
g_builtin_parms.index = index;
|
||||
|
||||
/* Get the priority of this (parent) task */
|
||||
|
||||
ret = sched_getparam(0, ¶m);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = get_errno();
|
||||
sdbg("ERROR: sched_getparam failed: %d\n", errcode);
|
||||
goto errout_with_sem;
|
||||
}
|
||||
|
||||
/* Disable pre-emption so that the proxy does not run until we waitpid
|
||||
* is called. This is probably unnecessary since the builtin_proxy has
|
||||
* the same priority as this thread; it should be schedule behind this
|
||||
* task in the ready-to-run list.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
sched_lock();
|
||||
#endif
|
||||
|
||||
/* Start the intermediary/proxy task at the same priority as the parent task. */
|
||||
|
||||
proxy = TASK_CREATE("builtin_proxy", param.sched_priority,
|
||||
CONFIG_BUILTIN_PROXY_STACKSIZE, (main_t)builtin_proxy,
|
||||
(FAR const char **)NULL);
|
||||
if (proxy < 0)
|
||||
{
|
||||
errcode = get_errno();
|
||||
sdbg("ERROR: Failed to start builtin_proxy: %d\n", errcode);
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Wait for the proxy to complete its job. We could use waitpid()
|
||||
* for this.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
ret = waitpid(proxy, &status, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
sdbg("ERROR: waitpid() failed: %d\n", get_errno());
|
||||
goto errout_with_lock;
|
||||
}
|
||||
#else
|
||||
bultin_semtake(&g_builtin_execsem);
|
||||
#endif
|
||||
|
||||
/* Get the result and relinquish our access to the parameter structure */
|
||||
|
||||
set_errno(g_builtin_parms.errcode);
|
||||
builtin_semgive(&g_builtin_parmsem);
|
||||
return g_builtin_parms.result;
|
||||
|
||||
errout_with_lock:
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
sched_unlock();
|
||||
#endif
|
||||
|
||||
errout_with_sem:
|
||||
set_errno(errcode);
|
||||
builtin_semgive(&g_builtin_parmsem);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_builtin
|
||||
*
|
||||
* Description:
|
||||
* Executes builtin applications registered during 'make context' time.
|
||||
* New application is run in a separate task context (and thread).
|
||||
*
|
||||
* Input Parameter:
|
||||
* filename - Name of the linked-in binary to be started.
|
||||
* argv - Argument list
|
||||
* redirfile - If output if redirected, this parameter will be non-NULL
|
||||
* and will provide the full path to the file.
|
||||
* oflags - If output is redirected, this parameter will provide the
|
||||
* open flags to use. This will support file replacement
|
||||
* of appending to an existing file.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is an end-user function, so it follows the normal convention:
|
||||
* Returns the PID of the exec'ed module. On failure, it.returns
|
||||
* -1 (ERROR) and sets errno appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int exec_builtin(FAR const char *appname, FAR const char **argv,
|
||||
FAR const char *redirfile, int oflags)
|
||||
{
|
||||
int index;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Verify that an application with this name exists */
|
||||
|
||||
index = builtin_isavail(appname);
|
||||
if (index >= 0)
|
||||
{
|
||||
/* Is output being redirected? */
|
||||
|
||||
if (redirfile)
|
||||
{
|
||||
ret = builtin_startproxy(index, argv, redirfile, oflags);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start the builtin application task */
|
||||
|
||||
ret = builtin_taskcreate(index, argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Return the task ID of the new task if the task was sucessfully
|
||||
* started. Otherwise, ret will be ERROR (and the errno value will
|
||||
* be set appropriately).
|
||||
*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
############################################################################
|
||||
# apps/builtin/registry/Makefile
|
||||
#
|
||||
# Copyright (C) 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# NSH Library
|
||||
|
||||
all:
|
||||
.PHONY: context depend clean distclean
|
||||
|
||||
.updated: $(DEPCONFIG)
|
||||
$(call DELFILE, *.bdat)
|
||||
$(call DELFILE, *.pdat)
|
||||
$(Q) touch .updated
|
||||
|
||||
# This must run before any other context target
|
||||
|
||||
context: .updated
|
||||
|
||||
depend:
|
||||
|
||||
clean:
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, *.bdat)
|
||||
$(call DELFILE, *.pdat)
|
||||
$(call DELFILE, .updated)
|
||||
@@ -1,49 +0,0 @@
|
||||
/** @mainpage PX4 Codebase Overview
|
||||
|
||||
PX4 is an open-source, open-hardware project aiming at providing a high-end autopilot to the academic, hobby and industrial communities (BSD licensed). For full documentation, refer to the official project website:
|
||||
|
||||
https://pixhawk.ethz.ch/px4/
|
||||
|
||||
Please follow the toolchain installation instructions at https://pixhawk.ethz.ch/px4/dev/px4_quickstart.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup topics uORB Topics
|
||||
|
||||
Small and efficient object request broker.
|
||||
|
||||
The micro object request broker (uORB) is a very efficient implementation of an object
|
||||
request broker following the publisher/subscriber design pattern.
|
||||
|
||||
It is in detail described here:
|
||||
https://pixhawk.ethz.ch/px4/dev/shared_object_communication
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup apps Onboard Applications
|
||||
|
||||
This is the list of the main functions of all onboard applications. The use of these
|
||||
applications is documented here:
|
||||
https://pixhawk.ethz.ch/px4/users/apps/start
|
||||
|
||||
Developer documentation of individual applications and the uORB data sharing mechanisms
|
||||
are described here:
|
||||
https://pixhawk.ethz.ch/px4/dev/apps/start
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup attitude_estimation Attitude Estimation
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup position_estimation Position Estimation
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup topics
|
||||
* @{
|
||||
*/
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
source "$APPSDIR/examples/adc/Kconfig"
|
||||
source "$APPSDIR/examples/buttons/Kconfig"
|
||||
source "$APPSDIR/examples/can/Kconfig"
|
||||
source "$APPSDIR/examples/cdcacm/Kconfig"
|
||||
source "$APPSDIR/examples/composite/Kconfig"
|
||||
source "$APPSDIR/examples/cxxtest/Kconfig"
|
||||
source "$APPSDIR/examples/dhcpd/Kconfig"
|
||||
source "$APPSDIR/examples/elf/Kconfig"
|
||||
source "$APPSDIR/examples/ftpc/Kconfig"
|
||||
source "$APPSDIR/examples/ftpd/Kconfig"
|
||||
source "$APPSDIR/examples/hello/Kconfig"
|
||||
source "$APPSDIR/examples/helloxx/Kconfig"
|
||||
source "$APPSDIR/examples/json/Kconfig"
|
||||
source "$APPSDIR/examples/hidkbd/Kconfig"
|
||||
source "$APPSDIR/examples/keypadtest/Kconfig"
|
||||
source "$APPSDIR/examples/igmp/Kconfig"
|
||||
source "$APPSDIR/examples/lcdrw/Kconfig"
|
||||
source "$APPSDIR/examples/mm/Kconfig"
|
||||
source "$APPSDIR/examples/mount/Kconfig"
|
||||
source "$APPSDIR/examples/modbus/Kconfig"
|
||||
source "$APPSDIR/examples/nettest/Kconfig"
|
||||
source "$APPSDIR/examples/nsh/Kconfig"
|
||||
source "$APPSDIR/examples/null/Kconfig"
|
||||
source "$APPSDIR/examples/nx/Kconfig"
|
||||
source "$APPSDIR/examples/nxconsole/Kconfig"
|
||||
source "$APPSDIR/examples/nxffs/Kconfig"
|
||||
source "$APPSDIR/examples/nxflat/Kconfig"
|
||||
source "$APPSDIR/examples/nxhello/Kconfig"
|
||||
source "$APPSDIR/examples/nximage/Kconfig"
|
||||
source "$APPSDIR/examples/nxlines/Kconfig"
|
||||
source "$APPSDIR/examples/nxtext/Kconfig"
|
||||
source "$APPSDIR/examples/ostest/Kconfig"
|
||||
source "$APPSDIR/examples/pashello/Kconfig"
|
||||
source "$APPSDIR/examples/pipe/Kconfig"
|
||||
source "$APPSDIR/examples/poll/Kconfig"
|
||||
source "$APPSDIR/examples/pwm/Kconfig"
|
||||
source "$APPSDIR/examples/posix_spawn/Kconfig"
|
||||
source "$APPSDIR/examples/qencoder/Kconfig"
|
||||
source "$APPSDIR/examples/relays/Kconfig"
|
||||
source "$APPSDIR/examples/rgmp/Kconfig"
|
||||
source "$APPSDIR/examples/romfs/Kconfig"
|
||||
source "$APPSDIR/examples/sendmail/Kconfig"
|
||||
source "$APPSDIR/examples/serloop/Kconfig"
|
||||
source "$APPSDIR/examples/telnetd/Kconfig"
|
||||
source "$APPSDIR/examples/thttpd/Kconfig"
|
||||
source "$APPSDIR/examples/tiff/Kconfig"
|
||||
source "$APPSDIR/examples/touchscreen/Kconfig"
|
||||
source "$APPSDIR/examples/udp/Kconfig"
|
||||
source "$APPSDIR/examples/discover/Kconfig"
|
||||
source "$APPSDIR/examples/uip/Kconfig"
|
||||
source "$APPSDIR/examples/usbserial/Kconfig"
|
||||
source "$APPSDIR/examples/usbstorage/Kconfig"
|
||||
source "$APPSDIR/examples/usbterm/Kconfig"
|
||||
source "$APPSDIR/examples/watchdog/Kconfig"
|
||||
source "$APPSDIR/examples/wget/Kconfig"
|
||||
source "$APPSDIR/examples/wgetjson/Kconfig"
|
||||
source "$APPSDIR/examples/xmlrpc/Kconfig"
|
||||
@@ -1,263 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_ADC),y)
|
||||
CONFIGURED_APPS += examples/adc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_BUTTONS),y)
|
||||
CONFIGURED_APPS += examples/buttons
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_CAN),y)
|
||||
CONFIGURED_APPS += examples/can
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_CDCACM),y)
|
||||
CONFIGURED_APPS += examples/cdcacm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_COMPOSITE),y)
|
||||
CONFIGURED_APPS += examples/composite
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_CXXTEST),y)
|
||||
CONFIGURED_APPS += examples/cxxtest
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_DHCPD),y)
|
||||
CONFIGURED_APPS += examples/dhcpd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_DISCOVER),y)
|
||||
CONFIGURED_APPS += examples/discover
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_ELF),y)
|
||||
CONFIGURED_APPS += examples/elf
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_FTPC),y)
|
||||
CONFIGURED_APPS += examples/ftpc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_FTPD),y)
|
||||
CONFIGURED_APPS += examples/ftpd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLO),y)
|
||||
CONFIGURED_APPS += examples/hello
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLOXX),y)
|
||||
CONFIGURED_APPS += examples/helloxx
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HIDKBD),y)
|
||||
CONFIGURED_APPS += examples/hidkbd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_IGMP),y)
|
||||
CONFIGURED_APPS += examples/igmp
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_JSON),y)
|
||||
CONFIGURED_APPS += examples/json
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_KEYPADTEST),y)
|
||||
CONFIGURED_APPS += examples/keypadtest
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_LCDRW),y)
|
||||
CONFIGURED_APPS += examples/lcdrw
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_MM),y)
|
||||
CONFIGURED_APPS += examples/mm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_MODBUS),y)
|
||||
CONFIGURED_APPS += examples/modbus
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_MOUNT),y)
|
||||
CONFIGURED_APPS += examples/mount
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST),y)
|
||||
CONFIGURED_APPS += examples/nettest
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NSH),y)
|
||||
CONFIGURED_APPS += examples/nsh
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NULL),y)
|
||||
CONFIGURED_APPS += examples/null
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NX),y)
|
||||
CONFIGURED_APPS += examples/nx
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXCONSOLE),y)
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXFFS),y)
|
||||
CONFIGURED_APPS += examples/nxffs
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXFLAT),y)
|
||||
CONFIGURED_APPS += examples/nxflat
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXHELLO),y)
|
||||
CONFIGURED_APPS += examples/nxhello
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXIMAGE),y)
|
||||
CONFIGURED_APPS += examples/nximage
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXLINES),y)
|
||||
CONFIGURED_APPS += examples/nxlines
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NXTEXT),y)
|
||||
CONFIGURED_APPS += examples/nxtext
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_OSTEST),y)
|
||||
CONFIGURED_APPS += examples/ostest
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_PASHELLO),y)
|
||||
CONFIGURED_APPS += examples/pashello
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_PIPE),y)
|
||||
CONFIGURED_APPS += examples/pipe
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_POLL),y)
|
||||
CONFIGURED_APPS += examples/poll
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_PWM),y)
|
||||
CONFIGURED_APPS += examples/pwm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_POSIXSPAWN),y)
|
||||
CONFIGURED_APPS += examples/posix_spawn
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_QENCODER),y)
|
||||
CONFIGURED_APPS += examples/qencoder
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_RELAYS),y)
|
||||
CONFIGURED_APPS += examples/relays
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_RGMP),y)
|
||||
CONFIGURED_APPS += examples/rgmp
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_ROMFS),y)
|
||||
CONFIGURED_APPS += examples/romfs
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_SENDMAIL),y)
|
||||
CONFIGURED_APPS += examples/sendmail
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_SERLOOP),y)
|
||||
CONFIGURED_APPS += examples/serloop
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_TELNETD),y)
|
||||
CONFIGURED_APPS += examples/telnetd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_THTTPD),y)
|
||||
CONFIGURED_APPS += examples/thttpd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_TIFF),y)
|
||||
CONFIGURED_APPS += examples/tiff
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN),y)
|
||||
CONFIGURED_APPS += examples/touchscreen
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP),y)
|
||||
CONFIGURED_APPS += examples/udp
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_UIP),y)
|
||||
CONFIGURED_APPS += examples/uip
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_USBSERIAL),y)
|
||||
CONFIGURED_APPS += examples/usbserial
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_USBMSC),y)
|
||||
CONFIGURED_APPS += examples/usbmsc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_USBTERM),y)
|
||||
CONFIGURED_APPS += examples/usbterm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_WATCHDOG),y)
|
||||
CONFIGURED_APPS += examples/watchdog
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_WGET),y)
|
||||
CONFIGURED_APPS += examples/wget
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_WGETJSON),y)
|
||||
CONFIGURED_APPS += examples/wgetjson
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_XMLRPC),y)
|
||||
CONFIGURED_APPS += examples/xmlrpc
|
||||
endif
|
||||
@@ -1,129 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config # Current configuration
|
||||
|
||||
# Sub-directories
|
||||
|
||||
SUBDIRS = adc can cdcacm nsh
|
||||
|
||||
#SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf ftpc
|
||||
#SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount
|
||||
#SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage
|
||||
#SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm posix_spawn qencoder
|
||||
#SUBDIRS += relays rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip
|
||||
#SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson
|
||||
|
||||
# Sub-directories that might need context setup. Directories may need
|
||||
# context setup for a variety of reasons, but the most common is because
|
||||
# the example may be built as an NSH built-in function.
|
||||
#
|
||||
# Directories that may be built as NSH built-in functions may have their
|
||||
# own configuration setting (like CONFIG_EXAMPLES_HELLOXX_BUILTIN), but
|
||||
# many only depend on the generic CONFIG_NSH_BUILTIN_APPS setting. And
|
||||
# there a few which an ONLY be built as NSH built-in applications; these
|
||||
# are included in the list unconditionally.
|
||||
|
||||
CNTXTDIRS = pwm
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
|
||||
CNTXTDIRS += adc can cdcacm
|
||||
|
||||
#CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd hello json
|
||||
#CNTXTDIRS += keypadtestmodbus nettest nxlines relays qencoder telnetd watchdog
|
||||
#CNTXTDIRS += wgetjson
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y)
|
||||
CNTXTDIRS += helloxx
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_LCDRW_BUILTIN),y)
|
||||
CNTXTDIRS += lcdrw
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_NX_BUILTIN),y)
|
||||
CNTXTDIRS += nx
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_NXHELLO_BUILTIN),y)
|
||||
CNTXTDIRS += nxhello
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y)
|
||||
CNTXTDIRS += nximage
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y)
|
||||
CNTXTDIRS += nxtext
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_OSTEST_BUILTIN),y)
|
||||
CNTXTDIRS += ostest
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_TIFF_BUILTIN),y)
|
||||
CNTXTDIRS += tiff
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN),y)
|
||||
CNTXTDIRS += touchscreen
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_USBMSC_BUILTIN),y)
|
||||
CNTXTDIRS += usbstorage
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_USBTERM_BUILTIN),y)
|
||||
CNTXTDIRS += usbterm
|
||||
endif
|
||||
|
||||
all: nothing
|
||||
|
||||
.PHONY: nothing context depend clean distclean
|
||||
|
||||
define SDIR_template
|
||||
$(1)_$(2):
|
||||
$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
|
||||
endef
|
||||
|
||||
$(foreach SDIR, $(CNTXTDIRS), $(eval $(call SDIR_template,$(SDIR),context)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),depend)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
|
||||
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
|
||||
|
||||
nothing:
|
||||
|
||||
context: $(foreach SDIR, $(CNTXTDIRS), $(SDIR)_context)
|
||||
|
||||
depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend)
|
||||
|
||||
clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
|
||||
|
||||
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_ADC
|
||||
bool "ADC example"
|
||||
default n
|
||||
depends on ADC
|
||||
---help---
|
||||
Enable the ADC example
|
||||
|
||||
if EXAMPLES_ADC
|
||||
|
||||
config EXAMPLES_ADC_DEVPATH
|
||||
string "ADC device path"
|
||||
default "/dev/adc0"
|
||||
---help---
|
||||
The default path to the ADC device. Default: /dev/adc0
|
||||
|
||||
config EXAMPLES_ADC_NSAMPLES
|
||||
int "Number of Sample Groups"
|
||||
default 0
|
||||
depends on !NSH_BUILTIN_APPS
|
||||
---help---
|
||||
If NSH_BUILTIN_APPS is defined, then the number of samples is provided
|
||||
on the command line and this value is ignored. Otherwise, this number
|
||||
of samples is collected and the program terminates. Default: 0 (samples
|
||||
are collected indefinitely).
|
||||
|
||||
config EXAMPLES_ADC_GROUPSIZE
|
||||
int "Number of Samples per Group"
|
||||
default 4
|
||||
---help---
|
||||
The number of samples to read at once. Default: 4
|
||||
|
||||
endif
|
||||
@@ -1,109 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/adc/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# NuttX NX Graphics Example.
|
||||
|
||||
ASRCS =
|
||||
CSRCS = adc_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Touchscreen built-in application info
|
||||
|
||||
APPNAME = adc
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: context clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,125 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/examples/adc/adc.h
|
||||
*
|
||||
* Copyright (C) 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_ADC_ADC_H
|
||||
#define __APPS_EXAMPLES_ADC_ADC_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_NSH_BUILTIN_APPS - Build the ADC test as an NSH built-in function.
|
||||
* Default: Built as a standalone problem
|
||||
* CONFIG_EXAMPLES_ADC_DEVPATH - The default path to the ADC device. Default: /dev/adc0
|
||||
* CONFIG_EXAMPLES_ADC_NSAMPLES - If CONFIG_NSH_BUILTIN_APPS
|
||||
* is defined, then the number of samples is provided on the command line
|
||||
* and this value is ignored. Otherwise, this number of samples is
|
||||
* collected and the program terminates. Default: Samples are collected
|
||||
* indefinitely.
|
||||
* CONFIG_EXAMPLES_ADC_GROUPSIZE - The number of samples to read at once.
|
||||
* Default: 4
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_ADC
|
||||
# error "ADC device support is not enabled (CONFIG_ADC)"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_ADC_DEVPATH
|
||||
# define CONFIG_EXAMPLES_ADC_DEVPATH "/dev/adc0"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_ADC_GROUPSIZE
|
||||
# define CONFIG_EXAMPLES_ADC_GROUPSIZE 4
|
||||
#endif
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) syslog(__VA_ARGS__)
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message syslog
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message printf
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct adc_state_s
|
||||
{
|
||||
bool initialized;
|
||||
FAR char *devpath;
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
|
||||
int count;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc_devinit()
|
||||
*
|
||||
* Description:
|
||||
* Perform architecuture-specific initialization of the ADC hardware. This
|
||||
* interface must be provided by all configurations using apps/examples/adc
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int adc_devinit(void);
|
||||
|
||||
#endif /* __APPS_EXAMPLES_ADC_ADC_H */
|
||||
@@ -1,372 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/adc/adc_main.c
|
||||
*
|
||||
* Copyright (C) 2011-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 <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/analog/adc.h>
|
||||
|
||||
#include "adc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Use CONFIG_EXAMPLES_ADC_NSAMPLES == 0 to mean to collect samples
|
||||
* indefinitely.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_ADC_NSAMPLES
|
||||
# define CONFIG_EXAMPLES_ADC_NSAMPLES 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct adc_state_s g_adcstate;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc_devpath
|
||||
****************************************************************************/
|
||||
|
||||
static void adc_devpath(FAR struct adc_state_s *adc, FAR const char *devpath)
|
||||
{
|
||||
/* Get rid of any old device path */
|
||||
|
||||
if (adc->devpath)
|
||||
{
|
||||
free(adc->devpath);
|
||||
}
|
||||
|
||||
/* Then set-up the new device path by copying the string */
|
||||
|
||||
adc->devpath = strdup(devpath);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc_help
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
static void adc_help(FAR struct adc_state_s *adc)
|
||||
{
|
||||
message("Usage: adc [OPTIONS]\n");
|
||||
message("\nArguments are \"sticky\". For example, once the ADC device is\n");
|
||||
message("specified, that device will be re-used until it is changed.\n");
|
||||
message("\n\"sticky\" OPTIONS include:\n");
|
||||
message(" [-p devpath] selects the ADC device. "
|
||||
"Default: %s Current: %s\n",
|
||||
CONFIG_EXAMPLES_ADC_DEVPATH, g_adcstate.devpath ? g_adcstate.devpath : "NONE");
|
||||
message(" [-n count] selects the samples to collect. "
|
||||
"Default: 1 Current: %d\n", adc->count);
|
||||
message(" [-h] shows this message and exits\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_string
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
static int arg_string(FAR char **arg, FAR char **value)
|
||||
{
|
||||
FAR char *ptr = *arg;
|
||||
|
||||
if (ptr[2] == '\0')
|
||||
{
|
||||
*value = arg[1];
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = &ptr[2];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_decimal
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
static int arg_decimal(FAR char **arg, FAR long *value)
|
||||
{
|
||||
FAR char *string;
|
||||
int ret;
|
||||
|
||||
ret = arg_string(arg, &string);
|
||||
*value = strtol(string, NULL, 10);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: parse_args
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv)
|
||||
{
|
||||
FAR char *ptr;
|
||||
FAR char *str;
|
||||
long value;
|
||||
int index;
|
||||
int nargs;
|
||||
|
||||
for (index = 1; index < argc; )
|
||||
{
|
||||
ptr = argv[index];
|
||||
if (ptr[0] != '-')
|
||||
{
|
||||
message("Invalid options format: %s\n", ptr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
switch (ptr[1])
|
||||
{
|
||||
case 'n':
|
||||
nargs = arg_decimal(&argv[index], &value);
|
||||
if (value < 0)
|
||||
{
|
||||
message("Count must be non-negative: %ld\n", value);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
adc->count = (uint32_t)value;
|
||||
index += nargs;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
nargs = arg_string(&argv[index], &str);
|
||||
adc_devpath(adc, str);
|
||||
index += nargs;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
adc_help(adc);
|
||||
exit(0);
|
||||
|
||||
default:
|
||||
message("Unsupported option: %s\n", ptr);
|
||||
adc_help(adc);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc_main
|
||||
****************************************************************************/
|
||||
|
||||
int adc_main(int argc, char *argv[])
|
||||
{
|
||||
struct adc_msg_s sample[CONFIG_EXAMPLES_ADC_GROUPSIZE];
|
||||
size_t readsize;
|
||||
ssize_t nbytes;
|
||||
int fd;
|
||||
int errval = 0;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Check if we have initialized */
|
||||
|
||||
if (!g_adcstate.initialized)
|
||||
{
|
||||
/* Initialization of the ADC hardware is performed by logic external to
|
||||
* this test.
|
||||
*/
|
||||
|
||||
message("adc_main: Initializing external ADC device\n");
|
||||
ret = adc_devinit();
|
||||
if (ret != OK)
|
||||
{
|
||||
message("adc_main: adc_devinit failed: %d\n", ret);
|
||||
errval = 1;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Set the default values */
|
||||
|
||||
adc_devpath(&g_adcstate, CONFIG_EXAMPLES_ADC_DEVPATH);
|
||||
|
||||
#if CONFIG_EXAMPLES_ADC_NSAMPLES > 0
|
||||
g_adcstate.count = CONFIG_EXAMPLES_ADC_NSAMPLES;
|
||||
#else
|
||||
g_adcstate.count = 1;
|
||||
#endif
|
||||
g_adcstate.initialized = true;
|
||||
}
|
||||
|
||||
/* Parse the command line */
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
parse_args(&g_adcstate, argc, argv);
|
||||
#endif
|
||||
|
||||
/* If this example is configured as an NX add-on, then limit the number of
|
||||
* samples that we collect before returning. Otherwise, we never return
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS) || CONFIG_EXAMPLES_ADC_NSAMPLES > 0
|
||||
message("adc_main: g_adcstate.count: %d\n", g_adcstate.count);
|
||||
#endif
|
||||
|
||||
/* Open the ADC device for reading */
|
||||
|
||||
message("adc_main: Hardware initialized. Opening the ADC device: %s\n",
|
||||
g_adcstate.devpath);
|
||||
|
||||
fd = open(g_adcstate.devpath, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
message("adc_main: open %s failed: %d\n", g_adcstate.devpath, errno);
|
||||
errval = 2;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now loop the appropriate number of times, displaying the collected
|
||||
* ADC samples.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS)
|
||||
for (; g_adcstate.count > 0; g_adcstate.count--)
|
||||
#elif CONFIG_EXAMPLES_ADC_NSAMPLES > 0
|
||||
for (g_adcstate.count = 0; g_adcstate.count < CONFIG_EXAMPLES_ADC_NSAMPLES; g_adcstate.count++)
|
||||
#else
|
||||
for (;;)
|
||||
#endif
|
||||
{
|
||||
/* Flush any output before the loop entered or from the previous pass
|
||||
* through the loop.
|
||||
*/
|
||||
|
||||
msgflush();
|
||||
|
||||
/* Read CONFIG_EXAMPLES_ADC_GROUPSIZE samples */
|
||||
|
||||
readsize = CONFIG_EXAMPLES_ADC_GROUPSIZE * sizeof(struct adc_msg_s);
|
||||
nbytes = read(fd, sample, readsize);
|
||||
|
||||
/* Handle unexpected return values */
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
message("adc_main: read %s failed: %d\n",
|
||||
g_adcstate.devpath, errval);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
message("adc_main: Interrupted read...\n");
|
||||
}
|
||||
else if (nbytes == 0)
|
||||
{
|
||||
message("adc_main: No data read, Ignoring\n");
|
||||
}
|
||||
|
||||
/* Print the sample data on successful return */
|
||||
|
||||
else
|
||||
{
|
||||
int nsamples = nbytes / sizeof(struct adc_msg_s);
|
||||
if (nsamples * sizeof(struct adc_msg_s) != nbytes)
|
||||
{
|
||||
message("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n",
|
||||
nbytes, sizeof(struct adc_msg_s));
|
||||
}
|
||||
else
|
||||
{
|
||||
message("Sample:\n");
|
||||
for (i = 0; i < nsamples ; i++)
|
||||
{
|
||||
message("%d: channel: %d value: %d\n",
|
||||
i, sample[i].am_channel, sample[i].am_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return OK;
|
||||
|
||||
/* Error exits */
|
||||
|
||||
errout_with_dev:
|
||||
close(fd);
|
||||
|
||||
errout:
|
||||
message("Terminating!\n");
|
||||
msgflush();
|
||||
return errval;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_BUTTONS
|
||||
bool "Buttons example"
|
||||
default n
|
||||
---help---
|
||||
Enable the buttons example. May require ARCH_BUTTONS on some boards.
|
||||
|
||||
if EXAMPLES_BUTTONS
|
||||
config EXAMPLES_BUTTONS_MIN
|
||||
int "Lowest Button Number"
|
||||
default 0
|
||||
|
||||
config EXAMPLES_BUTTONS_MAX
|
||||
int "Highest Button Number"
|
||||
default 7
|
||||
|
||||
if ARCH_IRQBUTTONS
|
||||
config EXAMPLES_IRQBUTTONS_MIN
|
||||
int "Lowest Interrupting Button Number"
|
||||
default 0
|
||||
|
||||
config EXAMPLES_IRQBUTTONS_MAX
|
||||
int "Highest Interrupting Button Number"
|
||||
default 7
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME0
|
||||
string "Button 0 Name"
|
||||
default "Button 0"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME1
|
||||
string "Button 1 Name"
|
||||
default "Button 1"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME2
|
||||
string "Button 2 Name"
|
||||
default "Button 2"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME3
|
||||
string "Button 3 Name"
|
||||
default "Button 3"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME4
|
||||
string "Button 4 Name"
|
||||
default "Button 4"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME5
|
||||
string "Button 5 Name"
|
||||
default "Button 5"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME6
|
||||
string "Button 6 Name"
|
||||
default "Button 6"
|
||||
|
||||
config EXAMPLES_BUTTONS_NAME7
|
||||
string "Button 7 Name"
|
||||
default "Button 7"
|
||||
|
||||
endif
|
||||
endif
|
||||
@@ -1,109 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/buttons/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Hello, World! Example
|
||||
|
||||
ASRCS =
|
||||
CSRCS = buttons_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Buttons built-in application info
|
||||
|
||||
APPNAME = buttons
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: context clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,499 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/buttons/buttons_main.c
|
||||
*
|
||||
* Copyright (C) 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* NOTE: This test exercises internal button driver interfaces. As such, it
|
||||
* it relies on internal OS interfaces that are not normally available to a
|
||||
* user-space program. As a result, this example cannot be used if a
|
||||
* NuttX is built as a protected, supervisor kernel (CONFIG_NUTTX_KERNEL).
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <debug.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_BUTTONS
|
||||
# error "CONFIG_ARCH_BUTTONS is not defined in the configuration"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME0
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME0 "BUTTON0"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME1
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME1 "BUTTON1"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME2
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME2 "BUTTON2"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME3
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME3 "BUTTON3"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME4
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME4 "BUTTON4"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME5
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME5 "BUTTON5"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME6
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME6 "BUTTON6"
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME7
|
||||
# define CONFIG_EXAMPLES_BUTTONS_NAME7 "BUTTON7"
|
||||
#endif
|
||||
|
||||
#define BUTTON_MIN 0
|
||||
#define BUTTON_MAX 7
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_MIN
|
||||
# define CONFIG_EXAMPLES_BUTTONS_MIN BUTTON_MIN
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_BUTTONS_MAX
|
||||
# define CONFIG_EXAMPLES_BUTTONS_MAX BUTTON_MAX
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLES_BUTTONS_MIN > CONFIG_EXAMPLES_BUTTONS_MAX
|
||||
# error "CONFIG_EXAMPLES_BUTTONS_MIN > CONFIG_EXAMPLES_BUTTONS_MAX"
|
||||
#endif
|
||||
#if CONFIG_EXAMPLES_BUTTONS_MAX > 7
|
||||
# error "CONFIG_EXAMPLES_BUTTONS_MAX > 7"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_IRQBUTTONS_MIN
|
||||
# define CONFIG_EXAMPLES_IRQBUTTONS_MIN CONFIG_EXAMPLES_BUTTONS_MIN
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_IRQBUTTONS_MAX
|
||||
# define CONFIG_EXAMPLES_IRQBUTTONS_MAX CONFIG_EXAMPLES_BUTTONS_MAX
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLES_IRQBUTTONS_MIN > CONFIG_EXAMPLES_IRQBUTTONS_MAX
|
||||
# error "CONFIG_EXAMPLES_IRQBUTTONS_MIN > CONFIG_EXAMPLES_IRQBUTTONS_MAX"
|
||||
#endif
|
||||
#if CONFIG_EXAMPLES_IRQBUTTONS_MAX > 7
|
||||
# error "CONFIG_EXAMPLES_IRQBUTTONS_MAX > 7"
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (a < b ? a : b)
|
||||
#endif
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) (a > b ? a : b)
|
||||
#endif
|
||||
|
||||
#define MIN_BUTTON MIN(CONFIG_EXAMPLES_BUTTONS_MIN, CONFIG_EXAMPLES_IRQBUTTONS_MIN)
|
||||
#define MAX_BUTTON MAX(CONFIG_EXAMPLES_BUTTONS_MAX, CONFIG_EXAMPLES_IRQBUTTONS_MAX)
|
||||
|
||||
#define NUM_BUTTONS (MAX_BUTTON - MIN_BUTTON + 1)
|
||||
#define BUTTON_INDEX(b) ((b)-MIN_BUTTON)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct button_info_s
|
||||
{
|
||||
FAR const char *name; /* Name for the button */
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t handler; /* Button interrupt handler */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void show_buttons(uint8_t oldset, uint8_t newset);
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
static void button_handler(int id, int irq);
|
||||
|
||||
#if MIN_BUTTON < 1
|
||||
static int button0_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 2 && MAX_BUTTON > 0
|
||||
static int button1_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 3 && MAX_BUTTON > 1
|
||||
static int button2_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 4 && MAX_BUTTON > 2
|
||||
static int button3_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 5 && MAX_BUTTON > 3
|
||||
static int button4_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 6 && MAX_BUTTON > 4
|
||||
static int button5_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MIN_BUTTON < 7 && MAX_BUTTON > 5
|
||||
static int button6_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#if MAX_BUTTON > 6
|
||||
static int button7_handler(int irq, FAR void *context);
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_IRQBUTTONS */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Button Names */
|
||||
|
||||
static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
|
||||
{
|
||||
#if MIN_BUTTON < 1
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME0,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button0_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 2 && MAX_BUTTON > 0
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME1,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button1_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 3 && MAX_BUTTON > 1
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME2,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button2_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 4 && MAX_BUTTON > 2
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME3,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button3_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 5 && MAX_BUTTON > 3
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME4,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button4_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 6 && MAX_BUTTON > 4
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME5,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button5_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MIN_BUTTON < 7 && MAX_BUTTON > 5
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME6,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button6_handler
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#if MAX_BUTTON > 6
|
||||
{
|
||||
CONFIG_EXAMPLES_BUTTONS_NAME7,
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
button7_handler
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Last sampled button set */
|
||||
|
||||
static uint8_t g_oldset;
|
||||
|
||||
/* Used to limit the number of button presses */
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
static volatile long g_nbuttons;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void show_buttons(uint8_t oldset, uint8_t newset)
|
||||
{
|
||||
uint8_t chgset = oldset ^ newset;
|
||||
int i;
|
||||
|
||||
/* Update the count of button presses shown */
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
if ((chgset & newset) != 0)
|
||||
{
|
||||
g_nbuttons++;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Show each button state change */
|
||||
|
||||
for (i = MIN_BUTTON; i <= MAX_BUTTON; i++)
|
||||
{
|
||||
uint8_t mask = (1 << i);
|
||||
if ((chgset & mask) != 0)
|
||||
{
|
||||
FAR const char *state;
|
||||
|
||||
/* Get the button state */
|
||||
|
||||
if ((newset & mask) != 0)
|
||||
{
|
||||
state = "depressed";
|
||||
}
|
||||
else
|
||||
{
|
||||
state = "released";
|
||||
}
|
||||
|
||||
/* Use lowsyslog() because we make be executing from an
|
||||
* interrupt handler.
|
||||
*/
|
||||
|
||||
lowsyslog(" %s %s\n", g_buttoninfo[BUTTON_INDEX(i)].name, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
static void button_handler(int id, int irq)
|
||||
{
|
||||
uint8_t newset = up_buttons();
|
||||
|
||||
lowsyslog("IRQ:%d Button %d:%s SET:%02x:\n",
|
||||
irq, id, g_buttoninfo[BUTTON_INDEX(id)].name, newset);
|
||||
show_buttons(g_oldset, newset);
|
||||
g_oldset = newset;
|
||||
}
|
||||
|
||||
#if MIN_BUTTON < 1
|
||||
static int button0_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(0, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 2 && MAX_BUTTON > 0
|
||||
static int button1_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(1, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 3 && MAX_BUTTON > 1
|
||||
static int button2_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(2, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 4 && MAX_BUTTON > 2
|
||||
static int button3_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(3, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 5 && MAX_BUTTON > 3
|
||||
static int button4_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(4, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 6 && MAX_BUTTON > 4
|
||||
static int button5_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(5, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MIN_BUTTON < 7 && MAX_BUTTON > 5
|
||||
static int button6_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(6, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAX_BUTTON > 6
|
||||
static int button7_handler(int irq, FAR void *context)
|
||||
{
|
||||
button_handler(7, irq);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_IRQBUTTONS */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* buttons_main
|
||||
****************************************************************************/
|
||||
|
||||
int buttons_main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t newset;
|
||||
irqstate_t flags;
|
||||
int i;
|
||||
|
||||
/* If this example is configured as an NX add-on, then limit the number of
|
||||
* samples that we collect before returning. Otherwise, we never return
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
long maxbuttons = 1;
|
||||
g_nbuttons = 0;
|
||||
if (argc > 1)
|
||||
{
|
||||
maxbuttons = strtol(argv[1], NULL, 10);
|
||||
}
|
||||
lowsyslog("maxbuttons: %d\n", maxbuttons);
|
||||
#endif
|
||||
|
||||
/* Initialize the button GPIOs */
|
||||
|
||||
up_buttoninit();
|
||||
|
||||
/* Register to recieve button interrupts */
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
|
||||
{
|
||||
xcpt_t oldhandler = up_irqbutton(i, g_buttoninfo[BUTTON_INDEX(i)].handler);
|
||||
|
||||
/* Use lowsyslog() for compatibility with interrrupt handler output. */
|
||||
|
||||
lowsyslog("Attached handler at %p to button %d [%s], oldhandler:%p\n",
|
||||
g_buttoninfo[BUTTON_INDEX(i)].handler, i,
|
||||
g_buttoninfo[BUTTON_INDEX(i)].name, oldhandler);
|
||||
|
||||
/* Some hardware multiplexes different GPIO button sources to the same
|
||||
* physical interrupt. If we register multiple such multiplexed button
|
||||
* interrupts, then the second registration will overwrite the first. In
|
||||
* this case, the first button interrupts may be aliased to the second
|
||||
* interrupt handler (or worse, could be lost).
|
||||
*/
|
||||
|
||||
if (oldhandler != NULL)
|
||||
{
|
||||
lowsyslog("WARNING: oldhandler:%p is not NULL! "
|
||||
"Button events may be lost or aliased!\n",
|
||||
oldhandler);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Poll button state */
|
||||
|
||||
g_oldset = up_buttons();
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
while (g_nbuttons < maxbuttons)
|
||||
#else
|
||||
for (;;)
|
||||
#endif
|
||||
{
|
||||
/* Get the set of pressed and release buttons. */
|
||||
|
||||
newset = up_buttons();
|
||||
|
||||
/* Any changes from the last sample? */
|
||||
|
||||
if (newset != g_oldset)
|
||||
{
|
||||
/* Disable interrupts so that output here will not collide with
|
||||
* output from an interrupt handler.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
|
||||
/* Use lowsyslog() for compatibility with interrrupt handler
|
||||
* output.
|
||||
*/
|
||||
|
||||
lowsyslog("POLL SET:%02x:\n", newset);
|
||||
show_buttons(g_oldset, newset);
|
||||
g_oldset = newset;
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
/* Sleep a little... but not long. This will determine how fast we
|
||||
* poll for button changes.
|
||||
*/
|
||||
|
||||
usleep(150000); /* 150 Milliseconds */
|
||||
}
|
||||
|
||||
/* Un-register button handlers */
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NSH_BUILTIN_APPS)
|
||||
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
|
||||
{
|
||||
(void)up_irqbutton(i, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_CAN
|
||||
bool "CAN example"
|
||||
default n
|
||||
---help---
|
||||
Enable the CAN example
|
||||
|
||||
if EXAMPLES_CAN
|
||||
endif
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/can/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# NuttX NX Graphics Example.
|
||||
|
||||
ASRCS =
|
||||
CSRCS = can_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Touchscreen built-in application info
|
||||
|
||||
APPNAME = can
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: context clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,131 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/examples/can/can.h
|
||||
*
|
||||
* Copyright (C) 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_EXAMPLES_CAN_CAN_H
|
||||
#define __APPS_EXAMPLES_CAN_CAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* This test depends on these specific CAN configurations settings (your
|
||||
* specific CAN settings might require additional settings).
|
||||
*
|
||||
* CONFIG_CAN - Enables CAN support.
|
||||
* CONFIG_CAN_LOOPBACK - A CAN driver may or may not support a loopback
|
||||
* mode for testing. The STM32 CAN driver does support loopback mode.
|
||||
*
|
||||
* Specific configuration options for this example include:
|
||||
*
|
||||
* CONFIG_NSH_BUILTIN_APPS - Build the CAN test as an NSH built-in function.
|
||||
* Default: Built as a standalone problem
|
||||
* CONFIG_CAN_LOOPBACK
|
||||
* CONFIG_EXAMPLES_CAN_DEVPATH - The path to the CAN device. Default: /dev/can0
|
||||
* CONFIG_EXAMPLES_CAN_NMSGS - If CONFIG_NSH_BUILTIN_APPS
|
||||
* is defined, then the number of loops is provided on the command line
|
||||
* and this value is ignored. Otherwise, this number of CAN message is
|
||||
* collected and the program terminates. Default: If built as an NSH
|
||||
* built-in, the default is 32. Otherwise messages are sent and received
|
||||
* indefinitely.
|
||||
* CONFIG_EXAMPLES_CAN_READONLY - Only receive messages
|
||||
* CONFIG_EXAMPLES_CAN_WRITEONLY - Only send messages
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_CAN
|
||||
# error "CAN device support is not enabled (CONFIG_CAN)"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_CAN_LOOPBACK
|
||||
# warning "CAN loopback is not enabled (CONFIG_CAN_LOOPBACK)"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_DEVPATH
|
||||
# define CONFIG_EXAMPLES_CAN_DEVPATH "/dev/can0"
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_EXAMPLES_CAN_NMSGS)
|
||||
# define CONFIG_EXAMPLES_CAN_NMSGS 32
|
||||
#endif
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) syslog(__VA_ARGS__)
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message syslog
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message printf
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_devinit()
|
||||
*
|
||||
* Description:
|
||||
* Perform architecuture-specific initialization of the CAN hardware. This
|
||||
* interface must be provided by all configurations using apps/examples/can
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int can_devinit(void);
|
||||
|
||||
#endif /* __APPS_EXAMPLES_CAN_CAN_H */
|
||||
@@ -1,301 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/can/can_main.c
|
||||
*
|
||||
* Copyright (C) 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 <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/can.h>
|
||||
|
||||
#include "can.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_CAN_READONLY)
|
||||
# undef CONFIG_EXAMPLES_CAN_WRITEONLY
|
||||
# undef CONFIG_EXAMPLES_CAN_READWRITE
|
||||
# define CAN_OFLAGS O_RDONLY
|
||||
#elif defined(CONFIG_EXAMPLES_CAN_WRITEONLY)
|
||||
# undef CONFIG_EXAMPLES_CAN_READWRITE
|
||||
# define CAN_OFLAGS O_WRONLY
|
||||
#else
|
||||
# undef CONFIG_EXAMPLES_CAN_READWRITE
|
||||
# define CONFIG_EXAMPLES_CAN_READWRITE 1
|
||||
# define CAN_OFLAGS O_RDWR
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
# define MAX_ID (1 << 29)
|
||||
#else
|
||||
# define MAX_ID (1 << 11)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_main
|
||||
****************************************************************************/
|
||||
|
||||
int can_main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef CONFIG_EXAMPLES_CAN_READONLY
|
||||
struct can_msg_s txmsg;
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
uint32_t msgid;
|
||||
#else
|
||||
uint16_t msgid;
|
||||
#endif
|
||||
int msgdlc;
|
||||
uint8_t msgdata;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_WRITEONLY
|
||||
struct can_msg_s rxmsg;
|
||||
#endif
|
||||
|
||||
size_t msgsize;
|
||||
ssize_t nbytes;
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_CAN_NMSGS)
|
||||
long nmsgs;
|
||||
#endif
|
||||
|
||||
int fd;
|
||||
int errval = 0;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* If this example is configured as an NX add-on, then limit the number of
|
||||
* samples that we collect before returning. Otherwise, we never return
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS)
|
||||
nmsgs = CONFIG_EXAMPLES_CAN_NMSGS;
|
||||
if (argc > 1)
|
||||
{
|
||||
nmsgs = strtol(argv[1], NULL, 10);
|
||||
}
|
||||
message("can_main: nmsgs: %d\n", nmsgs);
|
||||
#elif defined(CONFIG_EXAMPLES_CAN_NMSGS)
|
||||
message("can_main: nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS);
|
||||
#endif
|
||||
|
||||
/* Initialization of the CAN hardware is performed by logic external to
|
||||
* this test.
|
||||
*/
|
||||
|
||||
message("can_main: Initializing external CAN device\n");
|
||||
ret = can_devinit();
|
||||
if (ret != OK)
|
||||
{
|
||||
message("can_main: can_devinit failed: %d\n", ret);
|
||||
errval = 1;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Open the CAN device for reading */
|
||||
|
||||
message("can_main: Hardware initialized. Opening the CAN device\n");
|
||||
fd = open(CONFIG_EXAMPLES_CAN_DEVPATH, CAN_OFLAGS);
|
||||
if (fd < 0)
|
||||
{
|
||||
message("can_main: open %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_CAN_DEVPATH, errno);
|
||||
errval = 2;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
/* Now loop the appropriate number of times, performing one loopback test
|
||||
* on each pass.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_READONLY
|
||||
msgdlc = 1;
|
||||
msgid = 1;
|
||||
msgdata = 0;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_BUILTIN_APPS)
|
||||
for (; nmsgs > 0; nmsgs--)
|
||||
#elif defined(CONFIG_EXAMPLES_CAN_NMSGS)
|
||||
for (nmsgs = 0; nmsgs < CONFIG_EXAMPLES_CAN_NMSGS; nmsgs++)
|
||||
#else
|
||||
for (;;)
|
||||
#endif
|
||||
{
|
||||
/* Flush any output before the loop entered or from the previous pass
|
||||
* through the loop.
|
||||
*/
|
||||
|
||||
msgflush();
|
||||
|
||||
/* Construct the next TX message */
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_READONLY
|
||||
txmsg.cm_hdr.ch_id = msgid;
|
||||
txmsg.cm_hdr.ch_rtr = false;
|
||||
txmsg.cm_hdr.ch_dlc = msgdlc;
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
txmsg.cm_hdr.ch_extid = true;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < msgdlc; i++)
|
||||
{
|
||||
txmsg.cm_data[i] = msgdata + i;
|
||||
}
|
||||
|
||||
/* Send the TX message */
|
||||
|
||||
msgsize = CAN_MSGLEN(msgdlc);
|
||||
nbytes = write(fd, &txmsg, msgsize);
|
||||
if (nbytes != msgsize)
|
||||
{
|
||||
message("ERROR: write(%d) returned %d\n", msgsize, nbytes);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CAN_WRITEONLY
|
||||
message(" ID: %4d DLC: %d\n", msgid, msgdlc);
|
||||
#endif
|
||||
|
||||
/* Read the RX message */
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_WRITEONLY
|
||||
msgsize = sizeof(struct can_msg_s);
|
||||
nbytes = read(fd, &rxmsg, msgsize);
|
||||
if (nbytes < CAN_MSGLEN(0) || nbytes > msgsize)
|
||||
{
|
||||
message("ERROR: read(%d) returned %d\n", msgsize, nbytes);
|
||||
errval = 4;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_READONLY
|
||||
message(" ID: %4d DLC: %d\n", rxmsg.cm_hdr.id, rxmsg.cm_hdr.dlc);
|
||||
#endif
|
||||
|
||||
/* Verify that the received messages are the same */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CAN_READWRITE
|
||||
if (memcmp(&txmsg.cm_hdr, &rxmsg.cm_hdr, sizeof(struct can_hdr_s)) != 0)
|
||||
{
|
||||
message("ERROR: Sent header does not match received header:\n");
|
||||
lib_dumpbuffer("Sent header", (FAR const uint8_t*)&txmsg.cm_hdr,
|
||||
sizeof(struct can_hdr_s));
|
||||
lib_dumpbuffer("Received header", (FAR const uint8_t*)&rxmsg.cm_hdr,
|
||||
sizeof(struct can_hdr_s));
|
||||
errval = 4;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
if (memcmp(txmsg.cm_data, rxmsg.cm_data, msgdlc) != 0)
|
||||
{
|
||||
message("ERROR: Data does not match. DLC=%d\n", msgdlc);
|
||||
for (i = 0; i < msgdlc; i++)
|
||||
{
|
||||
message(" %d: TX %02x RX %02x\n", i, txmsg.cm_data[i], rxmsg.cm_data[i]);
|
||||
errval = 5;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
}
|
||||
|
||||
/* Report success */
|
||||
|
||||
message(" ID: %4d DLC: %d -- OK\n", msgid, msgdlc);
|
||||
#endif
|
||||
|
||||
/* Set up for the next pass */
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CAN_READONLY
|
||||
msgdata += msgdlc;
|
||||
|
||||
if (++msgid >= MAX_ID)
|
||||
{
|
||||
msgid = 1;
|
||||
}
|
||||
|
||||
if (++msgdlc > CAN_MAXDATALEN)
|
||||
{
|
||||
msgdlc = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
errout_with_dev:
|
||||
close(fd);
|
||||
|
||||
errout:
|
||||
message("Terminating!\n");
|
||||
msgflush();
|
||||
return errval;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_CDCACM
|
||||
bool "CAN example"
|
||||
default n
|
||||
---help---
|
||||
Enable the USB CDC/ACM class driver example
|
||||
|
||||
if EXAMPLES_CDCACM
|
||||
endif
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/cdcacm/Makefile
|
||||
#
|
||||
# Copyright (C) 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# USB CDC/ACM serial mass storage example
|
||||
|
||||
ASRCS =
|
||||
CSRCS = cdcacm_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# USB CDC/ACM built-in application info
|
||||
|
||||
APPNAME1 = sercon
|
||||
PRIORITY1 = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE1 = 2048
|
||||
|
||||
APPNAME2 = serdis
|
||||
PRIORITY2 = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE2 = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: context clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main)
|
||||
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/cdcacm/cdcacm.h
|
||||
*
|
||||
* Copyright (C) 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 __EXAMPLES_CDCACM_CDCACM_H
|
||||
#define __EXAMPLES_CDCACM_CDCACM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* Prerequisites */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# error "CONFIG_USBDEV is not defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_CDCACM
|
||||
# error "CONFIG_CDCACM is not defined"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_BUILTIN_APPS
|
||||
# error "This example can only be built as an NSH built-in application"
|
||||
#endif
|
||||
|
||||
/* Default configuration values */
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_CDCACM_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_CDCACM_DEVMINOR 0
|
||||
#endif
|
||||
|
||||
/* Trace Configuration ******************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CDCACM_TRACEINIT
|
||||
# define TRACE_INIT_BITS (TRACE_INIT_BIT)
|
||||
#else
|
||||
# define TRACE_INIT_BITS (0)
|
||||
#endif
|
||||
|
||||
#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CDCACM_TRACECLASS
|
||||
# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT)
|
||||
#else
|
||||
# define TRACE_CLASS_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CDCACM_TRACETRANSFERS
|
||||
# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\
|
||||
TRACE_WRITE_BIT|TRACE_COMPLETE_BIT)
|
||||
#else
|
||||
# define TRACE_TRANSFER_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CDCACM_TRACECONTROLLER
|
||||
# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT)
|
||||
#else
|
||||
# define TRACE_CONTROLLER_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_CDCACM_TRACEINTERRUPTS
|
||||
# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT)
|
||||
#else
|
||||
# define TRACE_INTERRUPT_BITS (0)
|
||||
#endif
|
||||
|
||||
#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\
|
||||
TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message(...) lowsyslog(__VA_ARGS__)
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message(...) printf(__VA_ARGS__)
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#else
|
||||
# ifdef CONFIG_DEBUG
|
||||
# define message lowsyslog
|
||||
# define msgflush()
|
||||
# else
|
||||
# define message printf
|
||||
# define msgflush() fflush(stdout)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* All global variables used by this example are packed into a structure in
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
struct cdcacm_state_s
|
||||
{
|
||||
/* This is the handle that references to this particular USB storage driver
|
||||
* instance. It is only needed if the USB mass storage device example is
|
||||
* built using CONFIG_NSH_BUILTIN_APPS. In this case, the value
|
||||
* of the driver handle must be remembered between the 'sercon' and 'msdis'
|
||||
* commands.
|
||||
*/
|
||||
|
||||
FAR void *handle;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* All global variables used by this example are packed into a structure in
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
extern struct cdcacm_state_s g_cdcacm;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __EXAMPLES_CDCACM_CDCACM_H */
|
||||
@@ -1,147 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/cdcacm/cdcacm_main.c
|
||||
*
|
||||
* Copyright (C) 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 <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/cdcacm.h>
|
||||
|
||||
#include "cdcacm.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* All global variables used by this example are packed into a structure in
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
struct cdcacm_state_s g_cdcacm;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* sercon_main
|
||||
*
|
||||
* Description:
|
||||
* This is the main program that configures the CDC/ACM serial device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sercon_main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Check if there is a non-NULL USB mass storage device handle (meaning that the
|
||||
* USB mass storage device is already configured).
|
||||
*/
|
||||
|
||||
if (g_cdcacm.handle)
|
||||
{
|
||||
message("sercon:: ERROR: Already connected\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Then, in any event, enable trace data collection as configured BEFORE
|
||||
* enabling the CDC/ACM device.
|
||||
*/
|
||||
|
||||
usbtrace_enable(TRACE_BITSET);
|
||||
|
||||
/* Initialize the USB CDC/ACM serial driver */
|
||||
|
||||
message("sercon: Registering CDC/ACM serial driver\n");
|
||||
ret = cdcacm_initialize(CONFIG_EXAMPLES_CDCACM_DEVMINOR, &g_cdcacm.handle);
|
||||
if (ret < 0)
|
||||
{
|
||||
message("sercon: ERROR: Failed to create the CDC/ACM serial device: %d\n", -ret);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
message("sercon: Successfully registered the CDC/ACM serial driver\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* serdis_main
|
||||
*
|
||||
* Description:
|
||||
* This is a program entry point that will disconnect the CDC/ACM serial
|
||||
* device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int serdis_main(int argc, char *argv[])
|
||||
{
|
||||
/* First check if the USB mass storage device is already connected */
|
||||
|
||||
if (!g_cdcacm.handle)
|
||||
{
|
||||
message("serdis: ERROR: Not connected\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Then, in any event, disable trace data collection as configured BEFORE
|
||||
* enabling the CDC/ACM device.
|
||||
*/
|
||||
|
||||
usbtrace_enable(0);
|
||||
|
||||
/* Then disconnect the device and uninitialize the USB mass storage driver */
|
||||
|
||||
cdcacm_uninitialize(g_cdcacm.handle);
|
||||
g_cdcacm.handle = NULL;
|
||||
message("serdis: Disconnected\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_HELLO
|
||||
bool "\"Hello, World!\" example"
|
||||
default n
|
||||
---help---
|
||||
Enable the \"Hello, World!\" example
|
||||
|
||||
if EXAMPLES_HELLO
|
||||
endif
|
||||
@@ -1,109 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/hello/Makefile
|
||||
#
|
||||
# Copyright (C) 2008, 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Hello, World! built-in application info
|
||||
|
||||
APPNAME = hello
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Hello, World! Example
|
||||
|
||||
ASRCS =
|
||||
CSRCS = hello_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
* examples/hello/hello_main.c
|
||||
*
|
||||
* Copyright (C) 2008, 2011-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 <stdio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* hello_main
|
||||
****************************************************************************/
|
||||
|
||||
int hello_main(int argc, char *argv[])
|
||||
{
|
||||
printf("Hello, World!!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_HELLOXX
|
||||
bool "\"Hello, World!\" C++ example"
|
||||
default n
|
||||
---help---
|
||||
Enable the \"Hello, World!\" C++ example
|
||||
|
||||
if EXAMPLES_HELLOXX
|
||||
endif
|
||||
@@ -1,126 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/helloxx/Makefile
|
||||
#
|
||||
# Copyright (C) 2009-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Hello, World! C++ Example
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
CXXSRCS = helloxx_main.cxx
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# helloxx built-in application info
|
||||
|
||||
APPNAME = helloxx
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: clean depend distclean chkcxx
|
||||
|
||||
chkcxx:
|
||||
ifneq ($(CONFIG_HAVE_CXX),y)
|
||||
@echo ""
|
||||
@echo "In order to use this example, you toolchain must support must"
|
||||
@echo ""
|
||||
@echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
|
||||
@echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
|
||||
@echo " of the configuration that you are using."
|
||||
@echo ""
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(CXXOBJS): %$(OBJEXT): %.cxx
|
||||
$(call COMPILEXX, $<, $@)
|
||||
|
||||
.built: chkcxx $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
@@ -1,165 +0,0 @@
|
||||
//***************************************************************************
|
||||
// examples/helloxx/helloxx_main.cxx
|
||||
//
|
||||
// Copyright (C) 2009, 2011-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 <cstdio>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/init.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
//***************************************************************************
|
||||
// Definitions
|
||||
//***************************************************************************
|
||||
// Debug ********************************************************************
|
||||
// Non-standard debug that may be enabled just for testing the constructors
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_CXX
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_CXX
|
||||
# define cxxdbg dbg
|
||||
# define cxxlldbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define cxxvdbg vdbg
|
||||
# define cxxllvdbg llvdbg
|
||||
# else
|
||||
# define cxxvdbg(x...)
|
||||
# define cxxllvdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define cxxdbg(x...)
|
||||
# define cxxlldbg(x...)
|
||||
# define cxxvdbg(x...)
|
||||
# define cxxllvdbg(x...)
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
// Private Classes
|
||||
//***************************************************************************
|
||||
|
||||
class CHelloWorld
|
||||
{
|
||||
public:
|
||||
CHelloWorld(void) : mSecret(42)
|
||||
{
|
||||
cxxdbg("Constructor: mSecret=%d\n", mSecret);
|
||||
}
|
||||
|
||||
~CHelloWorld(void)
|
||||
{
|
||||
cxxdbg("Destructor\n");
|
||||
}
|
||||
|
||||
bool HelloWorld(void)
|
||||
{
|
||||
cxxdbg("HelloWorld: mSecret=%d\n", mSecret);
|
||||
|
||||
if (mSecret != 42)
|
||||
{
|
||||
printf("CHelloWorld::HelloWorld: CONSTRUCTION FAILED!\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CHelloWorld::HelloWorld: Hello, World!!\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int mSecret;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
// Private Data
|
||||
//***************************************************************************
|
||||
|
||||
// Define a statically constructed CHellowWorld instance if C++ static
|
||||
// initializers are supported by the platform
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
static CHelloWorld g_HelloWorld;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
// Public Functions
|
||||
//***************************************************************************
|
||||
|
||||
/****************************************************************************
|
||||
* Name: helloxx_main
|
||||
****************************************************************************/
|
||||
|
||||
int helloxx_main(int argc, char *argv[])
|
||||
{
|
||||
// If C++ initialization for static constructors is supported, then do
|
||||
// that first
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
up_cxxinitialize();
|
||||
#endif
|
||||
|
||||
// Exercise an explictly instantiated C++ object
|
||||
|
||||
CHelloWorld *pHelloWorld = new CHelloWorld;
|
||||
printf("helloxx_main: Saying hello from the dynamically constructed instance\n");
|
||||
pHelloWorld->HelloWorld();
|
||||
|
||||
// Exercise an C++ object instantiated on the stack
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST
|
||||
CHelloWorld HelloWorld;
|
||||
|
||||
printf("helloxx_main: Saying hello from the instance constructed on the stack\n");
|
||||
HelloWorld.HelloWorld();
|
||||
#endif
|
||||
|
||||
// Exercise an statically constructed C++ object
|
||||
|
||||
#ifdef CONFIG_HAVE_CXXINITIALIZE
|
||||
printf("helloxx_main: Saying hello from the statically constructed instance\n");
|
||||
g_HelloWorld.HelloWorld();
|
||||
#endif
|
||||
|
||||
delete pHelloWorld;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_LCDRW
|
||||
bool "LCD read/write example"
|
||||
default n
|
||||
---help---
|
||||
Enable the LCD read/write example
|
||||
|
||||
if EXAMPLES_LCDRW
|
||||
endif
|
||||
@@ -1,13 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_MM
|
||||
bool "Memory management example"
|
||||
default n
|
||||
---help---
|
||||
Enable the memory management example
|
||||
|
||||
if EXAMPLES_MM
|
||||
endif
|
||||
@@ -1,96 +0,0 @@
|
||||
############################################################################
|
||||
# apps/examples/mm/Makefile
|
||||
#
|
||||
# Copyright (C) 2011-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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Memory Management Test
|
||||
|
||||
ASRCS =
|
||||
CSRCS = mm_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
context:
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user