diff --git a/canutils/uavcan/Kconfig b/canutils/uavcan/Kconfig index 8b9c4cc02..841d5d20f 100644 --- a/canutils/uavcan/Kconfig +++ b/canutils/uavcan/Kconfig @@ -60,36 +60,52 @@ config UAVCAN_STM32_NUM_IFACES range 1 1 if !STM32_HAVE_CAN2 range 1 2 if STM32_HAVE_CAN2 -if UAVCAN_STM32_TIMER_NUMBER = 2 && STM32_TIM2 -comment "Timer 2 is already configured for NuttX" -endif -if UAVCAN_STM32_TIMER_NUMBER = 3 && STM32_TIM3 -comment "Timer 3 is already configured for NuttX" -endif -if UAVCAN_STM32_TIMER_NUMBER = 4 && STM32_TIM4 -comment "Timer 4 is already configured for NuttX" -endif -if UAVCAN_STM32_TIMER_NUMBER = 5 && STM32_TIM5 -comment "Timer 5 is already configured for NuttX" -endif -if UAVCAN_STM32_TIMER_NUMBER = 6 && STM32_TIM6 -comment "Timer 6 is already configured for NuttX" -endif -if UAVCAN_STM32_TIMER_NUMBER = 7 && STM32_TIM7 -comment "Timer 7 is already configured for NuttX" -endif +choice + prompt "Timer" + default UAVCAN_STM32_TIM2 if STM32_HAVE_TIM2 && !STM32_TIM2 + default UAVCAN_STM32_TIM3 if STM32_HAVE_TIM3 && !STM32_TIM3 + default UAVCAN_STM32_TIM4 if STM32_HAVE_TIM4 && !STM32_TIM4 + default UAVCAN_STM32_TIM5 if STM32_HAVE_TIM5 && !STM32_TIM5 + default UAVCAN_STM32_TIM6 if STM32_HAVE_TIM6 && !STM32_TIM6 + default UAVCAN_STM32_TIM7 if STM32_HAVE_TIM7 && !STM32_TIM7 -config UAVCAN_STM32_TIMER_NUMBER - int "Timer Number" - default 2 if STM32_HAVE_TIM2 && !STM32_TIM2 - default 3 if STM32_HAVE_TIM3 && !STM32_TIM3 - default 4 if STM32_HAVE_TIM4 && !STM32_TIM4 - default 5 if STM32_HAVE_TIM5 && !STM32_TIM5 - default 6 if STM32_HAVE_TIM6 && !STM32_TIM6 - default 7 if STM32_HAVE_TIM7 && !STM32_TIM7 - range 2 7 +config UAVCAN_STM32_TIM2 + bool "TIM2" + depends on STM32_HAVE_TIM2 && !STM32_TIM2 ---help--- - Specifies the timer number. + The library will use TIM2. + +config UAVCAN_STM32_TIM3 + bool "TIM3" + depends on STM32_HAVE_TIM3 && !STM32_TIM3 + ---help--- + The library will use TIM3. + +config UAVCAN_STM32_TIM4 + bool "TIM4" + depends on STM32_HAVE_TIM4 && !STM32_TIM4 + ---help--- + The library will use TIM4. + +config UAVCAN_STM32_TIM5 + bool "TIM5" + depends on STM32_HAVE_TIM5 && !STM32_TIM5 + ---help--- + The library will use TIM5. + +config UAVCAN_STM32_TIM6 + bool "TIM6" + depends on STM32_HAVE_TIM6 && !STM32_TIM6 + ---help--- + The library will use TIM6. + +config UAVCAN_STM32_TIM7 + bool "TIM7" + depends on STM32_HAVE_TIM7 && !STM32_TIM7 + ---help--- + The library will use TIM7. + +endchoice choice prompt "C++ Version" @@ -107,15 +123,34 @@ config UAVCAN_CPP11 endchoice +config UAVCAN_DEBUG + bool "Debug" + default n + ---help--- + Enables debug. + +config UAVCAN_EXCEPTIONS + bool "Exceptions" + default n + ---help--- + Enables exceptions. + config UAVCAN_TINY bool "Tiny" default n ---help--- Removes some features to save memory. +config UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY + bool "No Global Data Type Registry" + default n + ---help--- + Removes the global data type registry. + config UAVCAN_TOSTRING bool "Implement toString" default n + depends on UAVCAN_EXCEPTIONS ---help--- The library will add a toString method to most of its classes. @@ -138,7 +173,7 @@ config UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION The library will use an external float16 conversion. config UAVCAN_NO_ASSERTIONS - bool "Disable Assertions" + bool "No Assertions" default n ---help--- Disables assertions. @@ -150,6 +185,27 @@ config UAVCAN_MEM_POOL_BLOCK_SIZE Specifies the memory pool block size. If the value is 0, the library will use a default value. +config UAVCAN_FLOAT_COMPARISON_EPSILON_MULT + int "Float Comparion Epsilon Mult" + default 0 + ---help--- + Specifies the float comparison epsilon mult. If the value is + 0, the library will use a default value. + +config UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS + int "Max CAN Acceptance Filters" + default 0 + ---help--- + Specifies the maximum number of CAN acceptance filters. If + the value is 0, the library will use a default value. + +config UAVCAN_MAX_NETWORK_SIZE_HINT + int "Max Network Size Hint" + default 0 + ---help--- + Specifies the maximum network size. If the value is 0, the + library will use a default value. + config UAVCAN_RX_QUEUE_CAPACITY int "Rx Queue Capacity" default 0 diff --git a/canutils/uavcan/Makefile b/canutils/uavcan/Makefile index 72346f49f..4fa9b6cc6 100644 --- a/canutils/uavcan/Makefile +++ b/canutils/uavcan/Makefile @@ -66,9 +66,33 @@ CXXSRCS = platform_stm32.cpp $(LIBUAVCAN_SRC) $(LIBUAVCAN_STM32_SRC) CXXFLAGS += -I$(LIBUAVCAN_INC) -I$(LIBUAVCAN_STM32_INC) -Idsdlc_generated CXXFLAGS += -I$(TOPDIR)/arch/arm/src/common -I$(TOPDIR)/arch/arm/src/stm32 +CXXFLAGS += -D__KERNEL__ CXXFLAGS += -DUAVCAN_STM32_NUTTX=1 CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=$(CONFIG_UAVCAN_STM32_NUM_IFACES) -CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=$(CONFIG_UAVCAN_STM32_TIMER_NUMBER) + +ifeq ($(CONFIG_UAVCAN_STM32_TIM2),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=2 +else +ifeq ($(CONFIG_UAVCAN_STM32_TIM3),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=3 +else +ifeq ($(CONFIG_UAVCAN_STM32_TIM4),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=4 +else +ifeq ($(CONFIG_UAVCAN_STM32_TIM5),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=5 +else +ifeq ($(CONFIG_UAVCAN_STM32_TIM6),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=6 +else +ifeq ($(CONFIG_UAVCAN_STM32_TIM7),y) +CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=7 +endif +endif +endif +endif +endif +endif ifeq ($(CONFIG_UAVCAN_CPP03),y) CXXFLAGS += -std=c++03 -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 @@ -78,12 +102,28 @@ CXXFLAGS += -std=c++11 -DUAVCAN_CPP_VERSION=UAVCAN_CPP11 endif endif +ifeq ($(CONFIG_UAVCAN_DEBUG),y) +CXXFLAGS += -DUAVCAN_DEBUG=1 +endif + +ifeq ($(CONFIG_UAVCAN_EXCEPTIONS),y) +CXXFLAGS += -DUAVCAN_EXCEPTIONS=1 +else +CXXFLAGS += -DUAVCAN_EXCEPTIONS=0 +endif + ifeq ($(CONFIG_UAVCAN_TINY),y) CXXFLAGS += -DUAVCAN_TINY=1 endif +ifeq ($(CONFIG_UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY),y) +CXXFLAGS += -DUAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY=1 +endif + ifeq ($(CONFIG_UAVCAN_TOSTRING),y) CXXFLAGS += -DUAVCAN_TOSTRING=1 +else +CXXFLAGS += -DUAVCAN_TOSTRING=0 endif ifeq ($(CONFIG_UAVCAN_IMPLEMENT_PLACEMENT_NEW),y) @@ -106,6 +146,18 @@ ifneq ($(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE),0) CXXFLAGS += -DUAVCAN_MEM_POOL_BLOCK_SIZE=$(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE) endif +ifneq ($(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT),0) +CXXFLAGS += -DUAVCAN_FLOAT_COMPARISON_EPSILON_MULT=$(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT) +endif + +ifneq ($(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS),0) +CXXFLAGS += -DUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS=$(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS) +endif + +ifneq ($(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT),0) +CXXFLAGS += -DUAVCAN_MAX_NETWORK_SIZE_HINT=$(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT) +endif + CXXEXT = .cpp CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT)) @@ -159,7 +211,7 @@ libuavcan: $(LIBUAVCAN_UNPACKNAME) $(DSDL_UNPACKNAME) $(PYUAVCAN_UNPACKNAME) dsdlc_generated: libuavcan $(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR))) -$(APPDIR)/include/uavcan: libuavcan/libuavcan/include/uavcan dsdlc_generated/uavcan +$(APPDIR)/include/uavcan: libuavcan dsdlc_generated $(Q) mkdir -p $(APPDIR)/include/uavcan $(Q) cp -R libuavcan/libuavcan/include/uavcan/* $(APPDIR)/include/uavcan $(Q) cp -R dsdlc_generated/uavcan/* $(APPDIR)/include/uavcan diff --git a/examples/uavcan/uavcan_main.cxx b/examples/uavcan/uavcan_main.cxx index 74f8924a0..7181356a0 100644 --- a/examples/uavcan/uavcan_main.cxx +++ b/examples/uavcan/uavcan_main.cxx @@ -48,13 +48,6 @@ * Public Function Prototypes ****************************************************************************/ -#ifndef CONFIG_BUILD_KERNEL -extern "C" -{ - int uavcan_main(int argc, FAR char *argv[]); -} -#endif - uavcan::ICanDriver& getCanDriver(); uavcan::ISystemClock& getSystemClock(); @@ -69,7 +62,7 @@ uavcan::ISystemClock& getSystemClock(); #ifdef CONFIG_BUILD_KERNEL int main(int argc, FAR char *argv[]) #else -int uavcan_main(int argc, FAR char *argv[]) +extern "C" int uavcan_main(int argc, FAR char *argv[]) #endif { uavcan::Node