Change module enable logic

This commit is contained in:
Henrik Stickann 2023-01-20 01:52:18 +01:00
parent 7f2f4a4df9
commit dd2983821e
12 changed files with 70 additions and 71 deletions

View File

@ -14,14 +14,6 @@
*/
#ifdef DOXYGEN
/**
* @def STA_STM32_CAN_ENABLE
* @brief Enable module.
*
* @ingroup stm32BuildConfig
*/
# define STA_STM32_CAN_ENABLE
/**
* @def STA_STM32_CAN_GLOBAL
* @brief Create global CanBus object using this CAN instance.
@ -32,12 +24,20 @@
#endif // DOXYGEN
// Only enable module on STM32 platform w/ HAL CAN module enabled
#include <sta/config.hpp>
#ifdef STA_STM32_CAN_ENABLE
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifdef HAL_CAN_MODULE_ENABLED
# define STA_STM32_CAN_ENABLED
# endif // HAL_CAN_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#include <sta/can_bus/controller.hpp>
#include <sta/stm32/hal.hpp>
#ifdef STA_STM32_CAN_ENABLED
#include <sta/can/controller.hpp>
namespace sta
@ -124,6 +124,6 @@ namespace sta
} // namespace sta
#endif // STA_STM32_CAN_ENABLE
#endif // STA_STM32_CAN_ENABLED
#endif // STA_CORE_STM32_CAN_HPP

View File

@ -23,7 +23,10 @@
* @{
*/
// Only enable module on STM32 platform
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
#include <sta/stm32/hal.hpp>
@ -96,4 +99,6 @@
/** @} */
#endif // STA_PLATFORM_STM32
#endif // STA_CORE_STM32_CLOCKS_HPP

View File

@ -12,14 +12,6 @@
*/
#ifdef DOXYGEN
/**
* @def STA_STM32_DELAY_ENABLE
* @brief Enable module.
*
* @ingroup stm32BuildConfig
*/
# define STA_STM32_DELAY_ENABLE
/**
* @def STA_STM32_DELAY_US_TIM
* @brief 1 MHz TIM instance used by sta::delayUs.
@ -33,8 +25,9 @@
#endif // DOXYGEN
// Only enable module on STM32 platform
#include <sta/config.hpp>
#ifdef STA_STM32_DELAY_ENABLE
#ifdef STA_PLATFORM_STM32
#include <cstdint>
@ -63,6 +56,6 @@ namespace sta
} // namespace sta
#endif // STA_STM32_DELAY_ENABLE
#endif // STA_PLATFORM_STM32
#endif // STA_CORE_STM32_DELAY_HPP

View File

@ -22,12 +22,20 @@
#endif // DOXYGEN
// Only enable module on STM32 platform w/ HAL GPIO module enabled
#include <sta/config.hpp>
#ifdef STA_STM32_GPIO_ENABLE
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifdef HAL_GPIO_MODULE_ENABLED
# define STA_STM32_GPIO_ENABLED
# endif // HAL_GPIO_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#ifdef STA_STM32_GPIO_ENABLED
#include <sta/gpio_pin.hpp>
#include <sta/stm32/hal.hpp>
namespace sta
@ -103,6 +111,6 @@ namespace sta
#define STA_STM32_GPIO_PIN(label) sta::STM32GpioPin{label##_GPIO_Port, label##_Pin}
#endif // STA_STM32_GPIO_ENABLE
#endif // STA_STM32_GPIO_ENABLED
#endif // STA_CORE_STM32_GPIO_PIN_HPP

View File

@ -1,6 +1,7 @@
#ifndef STA_CORE_STM32_HAL_HPP
#define STA_CORE_STM32_HAL_HPP
// Include STM32 HAL headers
#include <main.h>

View File

@ -11,26 +11,21 @@
* @brief STM32 SPI module.
*/
#ifdef DOXYGEN
/**
* @def STA_STM32_SPI_ENABLE
* @brief Enable module.
*
* Requires **STM_GPIO** module.
*
* @ingroup stm32BuildConfig
*/
# define STA_STM32_SPI_ENABLE
#endif // DOXYGEN
// Only enable module on STM32 platform w/ HAL SPI module enabled
#include <sta/config.hpp>
#ifdef STA_STM32_SPI_ENABLE
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifndef HAL_GPIO_MODULE_ENABLED
# error "STM32 GPIO module required!"
# endif // !HAL_GPIO_MODULE_ENABLED
# ifdef HAL_SPI_MODULE_ENABLED
# define STA_STM32_SPI_ENABLED
# endif // HAL_SPI_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#ifndef STA_STM32_GPIO_ENABLE
#error "STM32 GPIO module required"
#endif // !STA_STM32_GPIO_ENABLE
#ifdef STA_STM32_SPI_ENABLED
#include <sta/spi/device.hpp>
#include <sta/spi/interface.hpp>
@ -128,6 +123,6 @@ namespace sta
#define STA_STM32_SPI_INFO(handle) sta::STM32SpiInterfaceInfo{&handle, STA_STM32_GET_HANDLE_PCLK_FREQ_FN(handle)}
#endif // STA_STM32_SPI_ENABLE
#endif // STA_STM32_SPI_ENABLED
#endif // STA_CORE_STM32_SPI_HPP

View File

@ -12,14 +12,6 @@
*/
#ifdef DOXYGEN
/**
* @def STA_STM32_UART_ENABLE
* @brief Enable module.
*
* @ingroup stm32BuildConfig
*/
# define STA_STM32_UART_ENABLE
/**
* @def STA_STM32_UART_DEBUG_SERIAL
* @brief Create global sta::DebugSerial object using this HAL UART instance.
@ -30,13 +22,20 @@
#endif // DOXYGEN
// Only enable module on STM32 platform w/ HAL UART module enabled
#include <sta/config.hpp>
#ifdef STA_STM32_UART_ENABLE
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifdef HAL_UART_MODULE_ENABLED
# define STA_STM32_UART_ENABLED
# endif // HAL_UART_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#ifdef STA_STM32_UART_ENABLED
#include <sta/uart.hpp>
#include <sta/stm32/hal.hpp>
namespace sta
{
@ -61,6 +60,6 @@ namespace sta
} // namespace sta
#endif // STA_STM32_UART_ENABLE
#endif // STA_STM32_UART_ENABLED
#endif // STA_CORE_STM32_UART_HPP

View File

@ -1,5 +1,5 @@
#include <sta/stm32/can.hpp>
#ifdef STA_STM32_CAN_ENABLE
#ifdef STA_STM32_CAN_ENABLED
#include <sta/assert.hpp>
#include <sta/lang.hpp>
@ -207,4 +207,4 @@ extern "C"
#endif // STA_STM32_CAN_GLOBAL
#endif // STA_STM32_CAN_ENABLE
#endif // STA_STM32_CAN_ENABLED

View File

@ -1,5 +1,5 @@
#include <sta/stm32/delay.hpp>
#ifdef STA_STM32_DELAY_ENABLE
#ifdef STA_PLATFORM_STM32
#include <sta/stm32/hal.hpp>
#include <sta/stm32/clocks.hpp>
@ -19,6 +19,10 @@ namespace sta
#ifdef STA_STM32_DELAY_US_TIM
#ifndef HAL_TIM_MODULE_ENABLED
# error "STM32 HAL TIM module not enabled!"
#endif // HAL_TIM_MODULE_ENABLED
#include <tim.h>
namespace sta
@ -68,4 +72,4 @@ namespace sta
#endif // STA_STM32_DELAY_US_TIM
#endif // STA_STM32_DELAY_ENABLE
#endif // STA_PLATFORM_STM32

View File

@ -1,5 +1,5 @@
#include <sta/stm32/gpio_pin.hpp>
#ifdef STA_STM32_GPIO_ENABLE
#ifdef STA_STM32_GPIO_ENABLED
#include <sta/assert.hpp>
#include <sta/lang.hpp>
@ -80,4 +80,4 @@ namespace sta
} // namespace sta
#endif // STA_STM32_GPIO_ENABLE
#endif // STA_STM32_GPIO_ENABLED

View File

@ -1,5 +1,5 @@
#include <sta/stm32/spi.hpp>
#ifdef STA_STM32_SPI_ENABLE
#ifdef STA_STM32_SPI_ENABLED
#include <sta/assert.hpp>
#include <sta/endian.hpp>
@ -10,13 +10,7 @@
# define STA_STM32_SPI_REVERSE_BIT_ORDER SpiBitOrder::MSB
#elif STA_MCU_BIG_ENDIAN
# define STA_STM32_SPI_REVERSE_BIT_ORDER SpiBitOrder::LSB
#else // !STA_MCU_LITTLE_ENDIAN && !STA_MCU_BIG_ENDIAN
# ifdef STA_STM32_SPI_REVERSE_BIT_ORDER
# warning "Internal STA_STM32_SPI_REVERSE_BIT_ORDER macro manually defined! Better now what you are doing!!!"
# else // !STA_STM32_SPI_REVERSE_BIT_ORDER
# error "Unknown endian-ness. Define STA_MCU_LITTLE_ENDIAN or STA_MCU_BIG_ENDIAN in <sta/config.hpp>"
# endif // !STA_STM32_SPI_REVERSE_BIT_ORDER
#endif // !STA_MCU_LITTLE_ENDIAN && !STA_MCU_BIG_ENDIAN
#endif
namespace sta
@ -178,4 +172,4 @@ namespace sta
} // namespace sta
#endif // STA_HAL_SPI_ENABLE
#endif // STA_STM32_SPI_ENABLED

View File

@ -1,5 +1,5 @@
#include <sta/stm32/uart.hpp>
#ifdef STA_STM32_UART_ENABLE
#ifdef STA_STM32_UART_ENABLED
#include <sta/assert.hpp>
@ -40,4 +40,4 @@ namespace sta
#endif // STA_STM32_UART_DEBUG_SERIAL
#endif // STA_STM32_UART_ENABLE
#endif // STA_STM32_UART_ENABLED