From c4c45b995f5c8192c7a36c4293c201711ceac74d Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 10 Jan 2015 01:52:25 +0300 Subject: [PATCH] STM32 driver -Wundef fix --- .../include/uavcan_stm32/build_config.hpp | 32 +++++++++++++++++++ .../driver/include/uavcan_stm32/bxcan.hpp | 6 ++-- .../stm32/driver/include/uavcan_stm32/can.hpp | 1 + .../driver/include/uavcan_stm32/clock.hpp | 1 + .../driver/include/uavcan_stm32/thread.hpp | 2 ++ .../stm32/driver/src/internal.hpp | 10 ++---- .../stm32/driver/src/uc_stm32_clock.cpp | 2 +- .../stm32/test_stm32f107/Makefile | 2 ++ .../stm32/test_stm32f107/README.md | 2 +- .../stm32/test_stm32f107/src/sys/chconf.h | 4 +-- 10 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 libuavcan_drivers/stm32/driver/include/uavcan_stm32/build_config.hpp diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/build_config.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/build_config.hpp new file mode 100644 index 0000000000..3eba3ba6bf --- /dev/null +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/build_config.hpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 Pavel Kirienko + */ + +#pragma once + +/** + * OS detection + */ +#ifndef UAVCAN_STM32_CHIBIOS +# define UAVCAN_STM32_CHIBIOS 0 +#endif + +#ifndef UAVCAN_STM32_NUTTX +# define UAVCAN_STM32_NUTTX 0 +#endif + +/** + * Number of interfaces must be enabled explicitly + */ +#if !defined(UAVCAN_STM32_NUM_IFACES) || (UAVCAN_STM32_NUM_IFACES != 1 && UAVCAN_STM32_NUM_IFACES != 2) +# error "UAVCAN_STM32_NUM_IFACES must be set to either 1 or 2" +#endif + +/** + * Any General-Purpose timer (TIM2, TIM3, TIM4, TIM5) + * e.g. -DUAVCAN_STM32_TIMER_NUMBER=2 + */ +#ifndef UAVCAN_STM32_TIMER_NUMBER +// In this case the clock driver should be implemented by the application +# define UAVCAN_STM32_TIMER_NUMBER 0 +#endif diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/bxcan.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/bxcan.hpp index 2bf1e375f2..7e4679443a 100644 --- a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/bxcan.hpp +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/bxcan.hpp @@ -5,6 +5,8 @@ #pragma once +#include + #include #include @@ -17,10 +19,6 @@ # define constexpr const #endif -#if !defined(UAVCAN_STM32_NUM_IFACES) || (UAVCAN_STM32_NUM_IFACES != 1 && UAVCAN_STM32_NUM_IFACES != 2) -# error UAVCAN_STM32_NUM_IFACES -#endif - namespace uavcan_stm32 { namespace bxcan diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp index fae14e2b10..45e022bf38 100644 --- a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/can.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/clock.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/clock.hpp index 1af0daefd3..7ab754251a 100644 --- a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/clock.hpp +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/clock.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include namespace uavcan_stm32 diff --git a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp index eb1c6358e8..d2c6869ddc 100644 --- a/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp +++ b/libuavcan_drivers/stm32/driver/include/uavcan_stm32/thread.hpp @@ -4,6 +4,8 @@ #pragma once +#include + #if UAVCAN_STM32_CHIBIOS # include #elif UAVCAN_STM32_NUTTX diff --git a/libuavcan_drivers/stm32/driver/src/internal.hpp b/libuavcan_drivers/stm32/driver/src/internal.hpp index 06906c4fd4..3a63ef5de0 100644 --- a/libuavcan_drivers/stm32/driver/src/internal.hpp +++ b/libuavcan_drivers/stm32/driver/src/internal.hpp @@ -4,6 +4,8 @@ #pragma once +#include + #if UAVCAN_STM32_CHIBIOS # include #elif UAVCAN_STM32_NUTTX @@ -52,14 +54,6 @@ # endif #endif -/** - * Any General-Purpose timer (TIM2, TIM3, TIM4, TIM5) - * e.g. -DUAVCAN_STM32_TIMER_NUMBER=2 - */ -#ifndef UAVCAN_STM32_TIMER_NUMBER -// In this case the clock driver should be implemented by the application -#endif - /** * Glue macros */ diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp index b5ce28cd7c..046aa30a78 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp @@ -126,7 +126,7 @@ uavcan::MonotonicTime getMonotonic() } usec = time + cnt; -#if !NDEBUG +#ifndef NDEBUG static uavcan::uint64_t prev_usec = 0; // Self-test UAVCAN_ASSERT(prev_usec <= usec); prev_usec = usec; diff --git a/libuavcan_drivers/stm32/test_stm32f107/Makefile b/libuavcan_drivers/stm32/test_stm32f107/Makefile index 0a4c521deb..6695c37092 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/Makefile +++ b/libuavcan_drivers/stm32/test_stm32f107/Makefile @@ -40,6 +40,8 @@ UINCDIR += src/sys SERIAL_CLI_PORT_NUMBER = 2 +CPPWARN := -Wundef -Wno-error=undef + RELEASE_OPT = -Os -fomit-frame-pointer DEBUG_OPT = -Os -g3 #USE_OPT = -flto diff --git a/libuavcan_drivers/stm32/test_stm32f107/README.md b/libuavcan_drivers/stm32/test_stm32f107/README.md index be6e0a530d..691eea57a0 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/README.md +++ b/libuavcan_drivers/stm32/test_stm32f107/README.md @@ -1,4 +1,4 @@ UAVCAN test project for STM32 ----------------------------- -Please checkout/symlink https://github.com/Zubax/zubax_chibios into subdirectory `zubax_chibios`; then follow instructions in `zubax_chibios/README.md`. +Please checkout/symlink https://github.com/Zubax/zubax_chibios, branch `stable_v1`, into subdirectory `zubax_chibios`; then follow instructions in `zubax_chibios/README.md`. diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/sys/chconf.h b/libuavcan_drivers/stm32/test_stm32f107/src/sys/chconf.h index 1c5f1e9e45..8ef09b83f5 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/sys/chconf.h +++ b/libuavcan_drivers/stm32/test_stm32f107/src/sys/chconf.h @@ -9,7 +9,7 @@ #define CH_USE_HEAP TRUE #define CH_USE_DYNAMIC FALSE -#if DEBUG_BUILD +#if defined(DEBUG_BUILD) && DEBUG_BUILD # define CH_OPTIMIZE_SPEED FALSE # define CH_DBG_SYSTEM_STATE_CHECK TRUE # define CH_DBG_ENABLE_CHECKS TRUE @@ -17,7 +17,7 @@ # define CH_DBG_ENABLE_STACK_CHECK TRUE # define CH_DBG_FILL_THREADS TRUE # define CH_DBG_THREADS_PROFILING TRUE -#elif RELEASE_BUILD +#elif defined(RELEASE_BUILD) && RELEASE_BUILD # define CH_DBG_THREADS_PROFILING FALSE #else # error "Invalid configuration: Either DEBUG_BUILD or RELEASE_BUILD must be true"