diff --git a/include/sta/assert.hpp b/include/sta/assert.hpp index adf08ac..e7a3884 100644 --- a/include/sta/assert.hpp +++ b/include/sta/assert.hpp @@ -1,6 +1,11 @@ /** * @file * @brief Assertion handling. + * + * Configuration: + * * STA_ASSERT_FORCE: Ignore debug defines and always enable assertions + * * DEBUG: Enables assertions when defined + * * NDEBUG: Disables assertions when defined (overrides DEBUG) */ #ifndef STA_CORE_ASSERT_HPP #define STA_CORE_ASSERT_HPP @@ -22,52 +27,24 @@ * @brief Assertion handling. */ -#ifdef DOXYGEN -/** - * @def STA_ASSERT_ENABLE - * @brief Enable module. - * - * Automatically defined if DEBUG is defined. - * Automatically disabled if NDEBUG is defined. - * - * @ingroup staCoreBuildConfig - */ -# define STA_ASSERT_ENABLE - -/** - * @def STA_ASSERT_DISABLE - * @brief Force disable module. - * - * Overrides STA_ASSERT_ENABLE option. - * - * @ingroup staCoreBuildConfig - */ -# define STA_ASSERT_DISABLE -#endif // DOXYGEN - #include -#ifdef DEBUG -# ifndef STA_ASSERT_ENABLE -# define STA_ASSERT_ENABLE -# endif // !STA_ASSERT_ENABLE -#endif // DEBUG - -#if defined(NDEBUG) || defined(STA_ASSERT_DISABLE) -# ifdef STA_ASSERT_ENABLE -# undef STA_ASSERT_ENABLE -# endif // STA_ASSERT_ENABLE -#endif // NDEBUG || STA_ASSERT_DISABLE +// Determine if module should be enabled +// Condition: +// STA_ASSERT_FORCE is defined +// or +// DEBUG is defined but not NDEBUG +#ifdef STA_ASSERT_FORCE +# define STA_ASSERT_ENABLED +#else // !STA_ASSERT_FORCE +# if defined(DEBUG) && !defined(NDEBUG) +# define STA_ASSERT_ENABLED +# endif // DEBUG && !NDEBUG +#endif // !STA_ASSERT_FORCE -// Show enabled module in doxygen output -#ifdef DOXYGEN -# define STA_ASSERT_ENABLE -#endif // DOXYGEN - - -#ifdef STA_ASSERT_ENABLE +#if defined(STA_ASSERT_ENABLED) || defined(DOXYGEN) #include @@ -152,7 +129,7 @@ namespace sta # define STA_ASSERT_EXTRA(expr) expr; -#else // !STA_ASSERT_ENABLE +#else // !STA_ASSERT_ENABLED # define STA_ASSERT(expr) ((void)0) # define STA_ASSERT_MSG(expr, msg) ((void)0) @@ -161,7 +138,7 @@ namespace sta # define STA_ASSERT_EXTRA(expr) ((void)0) -#endif // !STA_ASSERT_ENABLE +#endif // !STA_ASSERT_ENABLED #endif // STA_CORE_ASSERT_HPP diff --git a/include/sta/atomic/mutex.hpp b/include/sta/atomic/mutex.hpp index 2001152..ad1d7b7 100644 --- a/include/sta/atomic/mutex.hpp +++ b/include/sta/atomic/mutex.hpp @@ -1,14 +1,19 @@ /** + * @file * @brief Atomic mutex implementation. * * Configuration: - * STA_ATOMIC_ENABLE: Enable module + * STA_STDLIB_HAS_ATOMIC: Enable module */ #ifndef STA_CORE_ATOMIC_MUTEX_HPP #define STA_CORE_ATOMIC_MUTEX_HPP #include -#ifdef STA_ATOMIC_ENABLE +#ifdef STA_STDLIB_HAS_ATOMIC +# define STA_ATOMIC_ENABLED +#endif // STA_STDLIB_HAS_ATOMIC + +#if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN) #include @@ -34,6 +39,6 @@ namespace sta } // namespace sta -#endif // STA_ATOMIC_ENABLE +#endif // STA_ATOMIC_ENABLED #endif // STA_CORE_ATOMIC_MUTEX_HPP diff --git a/include/sta/atomic/signal.hpp b/include/sta/atomic/signal.hpp index 8d9df3b..73c9645 100644 --- a/include/sta/atomic/signal.hpp +++ b/include/sta/atomic/signal.hpp @@ -1,14 +1,19 @@ /** + * @file * @brief Atomic signal implementation. * * Configuration: - * STA_ATOMIC_ENABLE: Enable module + * STA_STDLIB_HAS_ATOMIC: Enable module */ #ifndef STA_CORE_ATOMIC_SIGNAL_HPP #define STA_CORE_ATOMIC_SIGNAL_HPP #include -#ifdef STA_ATOMIC_ENABLE +#ifdef STA_STDLIB_HAS_ATOMIC +# define STA_ATOMIC_ENABLED +#endif // STA_STDLIB_HAS_ATOMIC + +#if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN) #include @@ -36,6 +41,6 @@ namespace sta } // namespace sta -#endif // STA_ATOMIC_ENABLE +#endif // STA_ATOMIC_ENABLED #endif // STA_CORE_ATOMIC_SIGNAL_HPP diff --git a/include/sta/can/iter.hpp b/include/sta/can/iter.hpp index 5f2d8a3..32a924a 100644 --- a/include/sta/can/iter.hpp +++ b/include/sta/can/iter.hpp @@ -1,3 +1,7 @@ +/** + * @file + * @brief Custom iterators for CAN controllers. + */ #ifndef STA_CORE_CAN_ITER_HPP #define STA_CORE_CAN_ITER_HPP diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 8dd9904..325130a 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -3,10 +3,10 @@ * @brief Debug output via UART. * * Configuration: - * STA_DEBUG_SERIAL_UART: UART interface for output - * STA_DEBUG_SERIAL_FORCE: Ignore debug defines and always enable output - * DEBUG: Enables output when defined - * NDEBUG: Disables output when defined (overrides DEBUG) + * * STA_DEBUG_SERIAL_UART: UART interface for output + * * STA_DEBUG_SERIAL_FORCE: Ignore debug defines and always enable output + * * DEBUG: Enables output when defined + * * NDEBUG: Disables output when defined (overrides DEBUG) */ #ifndef STA_CORE_DEBUG_SERIAL_HPP #define STA_CORE_DEBUG_SERIAL_HPP @@ -17,28 +17,6 @@ * @brief Debug serial output. */ -#ifdef DOXYGEN -/** - * @def STA_DEBUG_SERIAL_UART - * @brief UART interface for debug output. - * - * @ingroup staCoreBuildConfig - */ -# define STA_DEBUG_SERIAL_UART - -/** - * @def STA_DEBUG_SERIAL_FORCE - * @brief Force enable module. - * - * Enables debug output even if NDEBUG is defined - * or DEBUG is not defined. - * - * @ingroup staCoreBuildConfig - */ -# define STA_DEBUG_SERIAL_FORCE -#endif // DOXYGEN - - #include // Determine if module should be enabled @@ -57,14 +35,7 @@ # endif // !STA_DEBUG_SERIAL_FORCE #endif // STA_DEBUG_SERIAL_UART - -// Show enabled module in doxygen output -#ifdef DOXYGEN -# define STA_DEBUG_SERIAL_ENABLED -#endif // DOXYGEN - - -#ifdef STA_DEBUG_SERIAL_ENABLED +#if defined(STA_DEBUG_SERIAL_ENABLED) || defined(DOXYGEN) #include diff --git a/include/sta/gpio_pin.hpp b/include/sta/gpio_pin.hpp index 090c0f1..84cc974 100644 --- a/include/sta/gpio_pin.hpp +++ b/include/sta/gpio_pin.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief GPIO pin interface definitions. */ #ifndef STA_CORE_GPIO_PIN_HPP diff --git a/include/sta/mutex.hpp b/include/sta/mutex.hpp index e19f47e..fb8edea 100644 --- a/include/sta/mutex.hpp +++ b/include/sta/mutex.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Mutex interface definition. */ #ifndef STA_CORE_MUTEX_HPP diff --git a/include/sta/printf.hpp b/include/sta/printf.hpp index 3f02595..c738424 100644 --- a/include/sta/printf.hpp +++ b/include/sta/printf.hpp @@ -1,29 +1,14 @@ /** * @file * @brief Compatibility layer for different printf implementations. + * + * Configuration: + * * STA_PRINTF_USE_STDLIB: Use printf implementation from standard library + * * STA_PRINTF_USE_MPALAND: Use printf implementation from Marco Paland */ #ifndef STA_CORE_PRINTF_HPP #define STA_CORE_PRINTF_HPP -#ifdef DOXYGEN -/** - * @def STA_PRINTF_USE_STDLIB - * @brief Use printf implementation from STD library. - * - * @ingroup staCoreBuildConfig - */ -# define STA_PRINTF_USE_STDLIB - -/** - * @def STA_PRINTF_USE_MPALAND - * @brief Use printf implementation from Marco Paland. - * - * @ingroup staCoreBuildConfig - */ -# define STA_PRINTF_USE_MPALAND -#endif // DOXYGEN - - #include #if !defined(STA_PRINTF_USE_STDLIB) && !defined(STA_PRINTF_USE_MPALAND) diff --git a/include/sta/signal.hpp b/include/sta/signal.hpp index ffb0e1e..1005290 100644 --- a/include/sta/signal.hpp +++ b/include/sta/signal.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Signal interface definition. */ #ifndef STA_CORE_SIGNAL_HPP diff --git a/include/sta/stm32/can.hpp b/include/sta/stm32/can.hpp index 1af57c4..32fefe8 100644 --- a/include/sta/stm32/can.hpp +++ b/include/sta/stm32/can.hpp @@ -1,6 +1,9 @@ /** * @file * @brief Implementation of CanController using STM32 HAL. + * + * Configuration: + * * STA_STM32_CAN_GLOBAL: Create global CanBus object using this CAN instance */ #ifndef STA_CORE_STM32_CAN_HPP #define STA_CORE_STM32_CAN_HPP @@ -13,18 +16,6 @@ * Check @ref stm32BuildConfig for configuration options. */ -#ifdef DOXYGEN -/** - * @def STA_STM32_CAN_GLOBAL - * @brief Create global CanBus object using this CAN instance. - * - * @ingroup stm32BuildConfig - */ -# define STA_STM32_CAN_GLOBAL -#endif // DOXYGEN - - - // Only enable module on STM32 platform w/ HAL CAN module enabled #include #ifdef STA_PLATFORM_STM32 @@ -35,7 +26,7 @@ #endif // STA_PLATFORM_STM32 -#ifdef STA_STM32_CAN_ENABLED +#if defined(STA_STM32_CAN_ENABLED) || defined(DOXYGEN) #include @@ -104,7 +95,7 @@ namespace sta -#ifdef STA_STM32_CAN_GLOBAL +#if defined(STA_STM32_CAN_GLOBAL) || DOXYGEN /** * @brief Global CAN instance. * diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp index 29a9b4f..3168f51 100644 --- a/include/sta/stm32/clocks.hpp +++ b/include/sta/stm32/clocks.hpp @@ -26,7 +26,7 @@ // Only enable module on STM32 platform #include -#ifdef STA_PLATFORM_STM32 +#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN) #include diff --git a/include/sta/stm32/delay.hpp b/include/sta/stm32/delay.hpp index 94cbe90..df7f6e7 100644 --- a/include/sta/stm32/delay.hpp +++ b/include/sta/stm32/delay.hpp @@ -1,6 +1,12 @@ /** * @file * @brief Delay functions. + * + * Configuration: + * * STA_STM32_DELAY_US_TIM: 1 MHz TIM instance used by sta::delayUs + * + * NOTE: TIM time base must be started before use of sta::delayUs by calling sta::initHAL. + * When using startup system task this is handled automatically. */ #ifndef STA_CORE_STM32_DELAY_HPP #define STA_CORE_STM32_DELAY_HPP @@ -11,23 +17,9 @@ * @brief STM32 Delay module. */ -#ifdef DOXYGEN -/** - * @def STA_STM32_DELAY_US_TIM - * @brief 1 MHz TIM instance used by sta::delayUs. - * - * NOTE: TIM time base must be started before use of sta::delayUs by calling sta::initHAL. - * When using startup system task this is handled automatically. - * - * @ingroup stm32BuildConfig - */ -# define STA_STM32_DELAY_US_TIM -#endif // DOXYGEN - - // Only enable module on STM32 platform #include -#ifdef STA_PLATFORM_STM32 +#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN) #include @@ -43,7 +35,7 @@ namespace sta */ void delayMs(uint32_t ms); -#ifdef STA_STM32_DELAY_US_TIM +#if defined(STA_STM32_DELAY_US_TIM) || defined(DOXYGEN) /** * @brief Microsecond delay. * diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index c69f6ed..b112d7e 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -11,17 +11,6 @@ * @brief STM32 GPIO module. */ -#ifdef DOXYGEN -/** - * @def STA_STM32_GPIO_ENABLE - * @brief Enable module. - * - * @ingroup stm32BuildConfig - */ -# define STA_STM32_GPIO_ENABLE -#endif // DOXYGEN - - // Only enable module on STM32 platform w/ HAL GPIO module enabled #include #ifdef STA_PLATFORM_STM32 @@ -32,7 +21,7 @@ #endif // STA_PLATFORM_STM32 -#ifdef STA_STM32_GPIO_ENABLED +#if defined(STA_STM32_GPIO_ENABLED) || defined(DOXYGEN) #include diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp index b6b5b4b..2aacf3c 100644 --- a/include/sta/stm32/hal.hpp +++ b/include/sta/stm32/hal.hpp @@ -1,3 +1,7 @@ +/** + * @file + * @brief Generic header for including the STM32 HAL headers. + */ #ifndef STA_CORE_STM32_HAL_HPP #define STA_CORE_STM32_HAL_HPP diff --git a/include/sta/stm32/mcu/STM32F411xE.hpp b/include/sta/stm32/mcu/STM32F411xE.hpp index 48e0ecb..838408d 100644 --- a/include/sta/stm32/mcu/STM32F411xE.hpp +++ b/include/sta/stm32/mcu/STM32F411xE.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Configuration for STM32F411xE family. */ #ifndef STA_CORE_STM32_MCU_STM32F411xE_HPP diff --git a/include/sta/stm32/mcu/STM32F413xx.hpp b/include/sta/stm32/mcu/STM32F413xx.hpp index cd0e2a5..26ad175 100644 --- a/include/sta/stm32/mcu/STM32F413xx.hpp +++ b/include/sta/stm32/mcu/STM32F413xx.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Configuration for STM32F413xx family. */ #ifndef STA_CORE_STM32_MCU_STM32F413xx_HPP diff --git a/include/sta/stm32/mcu/common.hpp b/include/sta/stm32/mcu/common.hpp index 4ec69e8..5c809b2 100644 --- a/include/sta/stm32/mcu/common.hpp +++ b/include/sta/stm32/mcu/common.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Common configuration for STM32 MCUs */ #ifndef STA_CORE_STM32_MCU_COMMON_HPP diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp index 595cbf0..88515d0 100644 --- a/include/sta/stm32/spi.hpp +++ b/include/sta/stm32/spi.hpp @@ -24,8 +24,7 @@ # endif // HAL_SPI_MODULE_ENABLED #endif // STA_PLATFORM_STM32 - -#ifdef STA_STM32_SPI_ENABLED +#if defined(STA_STM32_SPI_ENABLED) || defined(DOXYGEN) #include #include diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index 7669968..58f90c2 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -22,7 +22,7 @@ #endif // STA_PLATFORM_STM32 -#ifdef STA_STM32_UART_ENABLED +#if defined(STA_STM32_UART_ENABLED) || defined(DOXYGEN) #include diff --git a/include/sta/time.hpp b/include/sta/time.hpp index da7ecd7..a86cacc 100644 --- a/include/sta/time.hpp +++ b/include/sta/time.hpp @@ -1,4 +1,5 @@ /** + * @file * @brief Signatures for time related functions. */ #ifndef STA_CORE_TIME_HPP diff --git a/src/assert.cpp b/src/assert.cpp index 5d2f552..fc34e2a 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_ASSERT_ENABLE +#ifdef STA_ASSERT_ENABLED #include #include @@ -27,4 +27,4 @@ namespace sta } // namespace sta -#endif // STA_ASSERT_ENABLE +#endif // STA_ASSERT_ENABLED diff --git a/src/atomic/mutex.cpp b/src/atomic/mutex.cpp index 60dc82b..f427656 100644 --- a/src/atomic/mutex.cpp +++ b/src/atomic/mutex.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_ATOMIC_ENABLE +#ifdef STA_ATOMIC_ENABLED namespace sta @@ -20,4 +20,4 @@ namespace sta } // namespace sta -#endif // STA_ATOMIC_ENABLE +#endif // STA_ATOMIC_ENABLED diff --git a/src/atomic/signal.cpp b/src/atomic/signal.cpp index e33d7f6..96a80db 100644 --- a/src/atomic/signal.cpp +++ b/src/atomic/signal.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_ATOMIC_ENABLE +#ifdef STA_ATOMIC_ENABLED namespace sta @@ -30,4 +30,4 @@ namespace sta } // namespace sta -#endif // STA_ATOMIC_ENABLE +#endif // STA_ATOMIC_ENABLED diff --git a/src/stm32/init.cpp b/src/stm32/init.cpp index 7b59818..b02627f 100644 --- a/src/stm32/init.cpp +++ b/src/stm32/init.cpp @@ -3,7 +3,13 @@ #include #ifdef STA_STM32_DELAY_US_TIM + +#ifndef HAL_TIM_MODULE_ENABLED +# error "STM32 HAL TIM module not enabled!" +#endif // HAL_TIM_MODULE_ENABLED + #include + #endif // STA_STM32_DELAY_US_TIM