From 298a72c71e2393638c2de3b48e698bcf47eba22f Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Wed, 23 Sep 2015 11:09:29 -0400 Subject: [PATCH] Add UAVCAN library --- Application.mk | 11 ++++- Directory.mk | 68 ++++++++++++++++++++++++++++ canutils/Kconfig | 10 ++++ canutils/Make.defs | 37 +++++++++++++++ canutils/Makefile | 36 +++++++++++++++ canutils/uavcan/.gitignore | 3 ++ canutils/uavcan/Kconfig | 85 ++++++++++++++++++++++++++++++++++ canutils/uavcan/Make.defs | 38 ++++++++++++++++ canutils/uavcan/Makefile | 93 ++++++++++++++++++++++++++++++++++++++ examples/Makefile | 34 +------------- 10 files changed, 380 insertions(+), 35 deletions(-) create mode 100644 Directory.mk create mode 100644 canutils/Kconfig create mode 100644 canutils/Make.defs create mode 100644 canutils/Makefile create mode 100644 canutils/uavcan/.gitignore create mode 100644 canutils/uavcan/Kconfig create mode 100644 canutils/uavcan/Make.defs create mode 100644 canutils/uavcan/Makefile diff --git a/Application.mk b/Application.mk index 99cbd8bc7..ef0a3d615 100644 --- a/Application.mk +++ b/Application.mk @@ -39,12 +39,15 @@ -include $(TOPDIR)/Make.defs include $(APPDIR)/Make.defs +CXXEXT ?= .cxx + AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) +CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT)) MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) -OBJS = $(AOBJS) $(COBJS) +OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) OBJS += $(MAINOBJ) @@ -71,6 +74,9 @@ $(AOBJS): %$(OBJEXT): %.S $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c $(call COMPILE, $<, $@) +$(CXXOBJS): %$(OBJEXT): %$(CXXEXT) + $(call COMPILEXX, $<, $@) + .built: $(OBJS) $(call ARCHIVE, $(BIN), $(OBJS)) $(Q) touch .built @@ -107,8 +113,9 @@ else context: endif -.depend: Makefile $(SRCS) +.depend: Makefile $(SRCS) $(CXXSRCS) $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(CXXSRCS) >Make.dep $(Q) touch $@ depend: .depend diff --git a/Directory.mk b/Directory.mk new file mode 100644 index 000000000..9c233fe9c --- /dev/null +++ b/Directory.mk @@ -0,0 +1,68 @@ +############################################################################ +# apps/Directory.mk +# +# Copyright (C) 2011-2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config # Current configuration + +# Sub-directories + +SUBDIRS = $(dir $(wildcard */Makefile)) + +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, $(SUBDIRS), $(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: + +install: + +context: $(foreach SDIR, $(SUBDIRS), $(SDIR)_context) + +depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend) + +clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean) + +distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) + +-include Make.dep diff --git a/canutils/Kconfig b/canutils/Kconfig new file mode 100644 index 000000000..59830cba2 --- /dev/null +++ b/canutils/Kconfig @@ -0,0 +1,10 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menu "CAN Utilities" + +source "$APPSDIR/canutils/uavcan/Kconfig" + +endmenu # CAN Utilities diff --git a/canutils/Make.defs b/canutils/Make.defs new file mode 100644 index 000000000..92373732f --- /dev/null +++ b/canutils/Make.defs @@ -0,0 +1,37 @@ +############################################################################ +# apps/canutils/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include $(wildcard canutils/*/Make.defs) diff --git a/canutils/Makefile b/canutils/Makefile new file mode 100644 index 000000000..abe102db3 --- /dev/null +++ b/canutils/Makefile @@ -0,0 +1,36 @@ +############################################################################ +# apps/canutils/Makefile +# +# Copyright (C) 2011-2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include $(APPDIR)/Directory.mk diff --git a/canutils/uavcan/.gitignore b/canutils/uavcan/.gitignore new file mode 100644 index 000000000..38297bc61 --- /dev/null +++ b/canutils/uavcan/.gitignore @@ -0,0 +1,3 @@ +/.built +/dsdlc_generated +/libuavcan diff --git a/canutils/uavcan/Kconfig b/canutils/uavcan/Kconfig new file mode 100644 index 000000000..16ac492e4 --- /dev/null +++ b/canutils/uavcan/Kconfig @@ -0,0 +1,85 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config CANUTILS_UAVCAN + bool "UAVCAN Library" + default n + depends on STM32_CAN1 + depends on STM32_TIM2 || STM32_TIM3 || STM32_TIM4 || STM32_TIM5 || STM32_TIM6 || STM32_TIM7 + depends on C99_BOOL8 + depends on HAVE_CXX + depends on !DISABLE_POLL + ---help--- + Enables support for the UAVCAN library. + +if CANUTILS_UAVCAN + +config UAVCAN_STM32_TIMER_NUMBER + int "Timer Number" + default 2 + range 2 7 + ---help--- + Specifies the timer number. + +choice + prompt "C++ Version" + default UAVCAN_CPP03 + +config UAVCAN_CPP03 + bool "C++03" + ---help--- + The library will use C++03. + +config UAVCAN_CPP11 + bool "C++11" + ---help--- + The library will use C++11. + +endchoice + +config UAVCAN_TINY + bool "Tiny" + default n + ---help--- + Removes some features to save memory. + +config UAVCAN_TOSTRING + bool "Implement toString" + default n + ---help--- + The library will add a toString method to most of its classes. + +config UAVCAN_IMPLEMENT_PLACEMENT_NEW + bool "Implement Placement new" + default n + ---help--- + The library will implement placement new. + +config UAVCAN_USE_EXTERNAL_SNPRINTF + bool "Use External snprintf" + default n + ---help--- + The library will use an external snprintf. + +config UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION + bool "Use External float16 Conversion" + default n + ---help--- + The library will use an external float16 conversion. + +config UAVCAN_NO_ASSERTIONS + bool "Disable Assertions" + default n + ---help--- + Disables assertions. + +config UAVCAN_MEM_POOL_BLOCK_SIZE + int "Memory Pool Block Size" + default 0 + ---help--- + Specifies the memory pool block size. A value of 0 will + use the library default. + +endif diff --git a/canutils/uavcan/Make.defs b/canutils/uavcan/Make.defs new file mode 100644 index 000000000..fa3c9c602 --- /dev/null +++ b/canutils/uavcan/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# apps/canutils/uavcan/Make.defs +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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_CANUTILS_UAVCAN),y) +CONFIGURED_APPS += canutils/uavcan +endif diff --git a/canutils/uavcan/Makefile b/canutils/uavcan/Makefile new file mode 100644 index 000000000..0bd05c28e --- /dev/null +++ b/canutils/uavcan/Makefile @@ -0,0 +1,93 @@ +############################################################################ +# apps/canutils/uavcan/Makefile +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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. +# +############################################################################ + +CXXEXT = .cpp + +include libuavcan/libuavcan/include.mk +include libuavcan/libuavcan_drivers/stm32/driver/include.mk + +$(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR))) + +CXXSRCS += $(LIBUAVCAN_SRC) $(LIBUAVCAN_STM32_SRC) + +include $(APPDIR)/Application.mk + +CXXFLAGS += -I$(LIBUAVCAN_INC) -I$(LIBUAVCAN_STM32_INC) -Idsdlc_generated +CXXFLAGS += -I$(TOPDIR)/arch/arm/src/stm32 + +CXXFLAGS += -DUAVCAN_STM32_NUTTX=1 +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=$(CONFIG_UAVCAN_STM32_TIMER_NUMBER) + +ifeq ($(CONFIG_STM32_CAN2),y) +CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=2 +else +CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=1 +endif + +ifeq ($(CONFIG_UAVCAN_CPP03),y) +CXXFLAGS += -std=c++03 -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 +else +ifeq ($(CONFIG_UAVCAN_CPP11),y) +CXXFLAGS += -std=c++11 -DUAVCAN_CPP_VERSION=UAVCAN_CPP11 +endif +endif + +ifeq ($(CONFIG_UAVCAN_TINY),y) +CXXFLAGS += -DUAVCAN_TINY=1 +endif + +ifeq ($(CONFIG_UAVCAN_TOSTRING),y) +CXXFLAGS += -DUAVCAN_TOSTRING=1 +endif + +ifeq ($(CONFIG_UAVCAN_IMPLEMENT_PLACEMENT_NEW),y) +CXXFLAGS += -DUAVCAN_IMPLEMENT_PLACEMENT_NEW=1 +endif + +ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_SNPRINTF),y) +CXXFLAGS += -DUAVCAN_USE_EXTERNAL_SNPRINTF=1 +endif + +ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION),y) +CXXFLAGS += -DUAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION=1 +endif + +ifeq ($(CONFIG_UAVCAN_NO_ASSERTIONS),y) +CXXFLAGS += -DUAVCAN_NO_ASSERTIONS=1 +endif + +ifneq ($(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE),0) +CXXFLAGS += -DUAVCAN_MEM_POOL_BLOCK_SIZE=$(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE) +endif diff --git a/examples/Makefile b/examples/Makefile index e3e67d6aa..70315d06c 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -33,36 +33,4 @@ # ############################################################################ --include $(TOPDIR)/.config # Current configuration - -# Sub-directories - -SUBDIRS = $(dir $(wildcard */Makefile)) - -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, $(SUBDIRS), $(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: - -install: - -context: $(foreach SDIR, $(SUBDIRS), $(SDIR)_context) - -depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend) - -clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean) - -distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) - --include Make.dep +include $(APPDIR)/Directory.mk