From 460f4e3c25072304dfd89d59edbd1621ca8acadb Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Mon, 9 May 2022 21:19:06 +0200 Subject: [PATCH 01/28] Move STM32 related code to sta-stm32-core repo --- README.md | 0 include/sta/stm32/can.hpp | 129 ++++++++++++++++ include/sta/stm32/clocks.hpp | 82 ++++++++++ include/sta/stm32/delay.hpp | 68 +++++++++ include/sta/stm32/gpio_pin.hpp | 82 ++++++++++ include/sta/stm32/hal.hpp | 8 + include/sta/stm32/init.hpp | 20 +++ include/sta/stm32/mcu/STM32F411xE.hpp | 77 ++++++++++ include/sta/stm32/mcu/STM32F413xx.hpp | 16 ++ include/sta/stm32/mcu/common.hpp | 12 ++ include/sta/stm32/spi.hpp | 133 ++++++++++++++++ include/sta/stm32/uart.hpp | 66 ++++++++ library.json | 11 ++ src/can.cpp | 210 ++++++++++++++++++++++++++ src/delay.cpp | 66 ++++++++ src/gpio_pin.cpp | 83 ++++++++++ src/init.cpp | 22 +++ src/spi.cpp | 181 ++++++++++++++++++++++ src/uart.cpp | 43 ++++++ 19 files changed, 1309 insertions(+) create mode 100644 README.md create mode 100644 include/sta/stm32/can.hpp create mode 100644 include/sta/stm32/clocks.hpp create mode 100644 include/sta/stm32/delay.hpp create mode 100644 include/sta/stm32/gpio_pin.hpp create mode 100644 include/sta/stm32/hal.hpp create mode 100644 include/sta/stm32/init.hpp create mode 100644 include/sta/stm32/mcu/STM32F411xE.hpp create mode 100644 include/sta/stm32/mcu/STM32F413xx.hpp create mode 100644 include/sta/stm32/mcu/common.hpp create mode 100644 include/sta/stm32/spi.hpp create mode 100644 include/sta/stm32/uart.hpp create mode 100644 library.json create mode 100644 src/can.cpp create mode 100644 src/delay.cpp create mode 100644 src/gpio_pin.cpp create mode 100644 src/init.cpp create mode 100644 src/spi.cpp create mode 100644 src/uart.cpp diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/include/sta/stm32/can.hpp b/include/sta/stm32/can.hpp new file mode 100644 index 0000000..537a5f8 --- /dev/null +++ b/include/sta/stm32/can.hpp @@ -0,0 +1,129 @@ +/** + * @file + * @brief Implementation of CanController using STM32 HAL. + */ +#ifndef STA_STM32_CAN_HPP +#define STA_STM32_CAN_HPP + +/** + * @defgroup stm32CAN CAN + * @ingroup stm32 + * @brief STM32 CAN module. + * + * Check @ref stm32BuildConfig for configuration options. + */ + +#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. + * + * @ingroup stm32BuildConfig + */ +# define STA_STM32_CAN_GLOBAL +#endif // DOXYGEN + + +#include +#ifdef STA_STM32_CAN_ENABLE + +#include + +#include + + +namespace sta +{ + /** + * @brief Implementation of CanController interface using HAL. + * + * @ingroup stm32CAN + */ + class STM32CanController : public CanController + { + public: + static constexpr uint8_t MAX_FILTER_COUNT = 14; /**< Max number of filters */ + static constexpr uint8_t MAX_FIFO_COUNT = 2; /**< Max number of FIFOs */ + static constexpr uint8_t MAX_PAYLOAD_SIZE = 8; /**< Maximum payload size */ + + public: + /** + * @param handle CAN handle + */ + STM32CanController(CAN_HandleTypeDef * handle); + + /** + * @brief Enable RX pending interrupts. + */ + void enableRxInterrupts(); + + /** + * @brief Start CAN controller. + */ + void start(); + /** + * @brief Stop CAN controller. + */ + void stop(); + + + // RX/TX + // + + bool sendFrame(const CanTxHeader & header, const uint8_t * payload) override; + bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) override; + + uint32_t getRxFifoFlags() override; + + // RX Filter + // + + void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) override; + void enableFilter(uint8_t idx) override; + void disableFilter(uint8_t idx) override; + void clearFilters() override; + + private: + /** + * @brief Initialize filter settings. + */ + void initFilters(); + + private: + CAN_HandleTypeDef * handle_; /**< CAN handle */ + CAN_FilterTypeDef filters_[MAX_FILTER_COUNT]; /**< Filter settings */ + }; + + + +#ifdef STA_STM32_CAN_GLOBAL + /** + * @brief Global CAN instance. + * + * @ingroup stm32CAN + */ + extern STM32CanController CanBus; + + /** + * @brief Interrupt handler for pending RX frames. + * + * May be implemented by application. + * + * @ingroup stm32CAN + */ + void CanBus_RxPendingCallback(); +#endif // STA_STM32_CAN_GLOBAL +} // namespace sta + + +#endif // STA_STM32_CAN_ENABLE + +#endif // STA_STM32_CAN_HPP diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp new file mode 100644 index 0000000..65e5d27 --- /dev/null +++ b/include/sta/stm32/clocks.hpp @@ -0,0 +1,82 @@ +/** + * @file + * @brief Helper macros for STM32 clock queries. + */ +#ifndef STA_STM32_CLOCKS_HPP +#define STA_STM32_CLOCKS_HPP + +/** + * @defgroup stm32 STM32 + * @brief Modules implemented for STM32 MCUs. + */ + +/** + * @defgroup stm32BuildConfig Build config + * @ingroup stm32 + * @brief Build configuration options. + */ + +/** + * @defgroup stm32Clocks Clocks + * @ingroup stm32 + * @brief STM32 clock queries. + * @{ + */ + +#include + +#include + + +/** + * @brief Get function returning PCLK frequency. + * + * @param n Index of peripheral clock + */ +#define STA_STM32_GET_PCLK_FREQ_FN(n) HAL_RCC_GetPCLK ## n ## Freq + + +// Internal helper for macro expansion +#define _STA_STM32_GET_PCLK_FREQ_FN(n) STA_STM32_GET_PCLK_FREQ_FN(n) +// Get instance to PCLK index map macro +#define _STA_STM32_PCLK_IDX_MAP(type, idx) STA_STM32_ ## type ## _ ## idx ## _PCLK_IDX +// Get HAL handle to PCLK index map macro +#define _STA_STM32_HANDLE_PCLK_IDX_MAP(handle) STA_STM32_ ## handle ## _PCLK_IDX + + +/** + * @brief Get function returning frequency of PCLK used by TIM. + * + * @param n TIM index + */ +#define STA_STM32_GET_TIM_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(TIM, n)) +/** + * @brief Get function returning frequency of PCLK used by SPI interface. + * + * @param n SPI interface index + */ +#define STA_STM32_GET_SPI_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(SPI, n)) +/** + * @brief Get function returning frequency of PCLK used by I2C interface. + * + * @param n I2C interface index + */ +#define STA_STM32_GET_I2C_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(I2C, n)) +/** + * @brief Get function returning frequency of PCLK used by USART interface. + * + * @param n USART interface index + */ +#define STA_STM32_GET_USART_PCLK_FREQ_FN(n) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_PCLK_IDX_MAP(USART, n)) + +/** + * @brief Get function returning frequency of PCLK used by HAL instance. + * + * @param handle Instance handle + */ +#define STA_STM32_GET_HANDLE_PCLK_FREQ_FN(handle) _STA_STM32_GET_PCLK_FREQ_FN(_STA_STM32_HANDLE_PCLK_IDX_MAP(handle)) + + +/** @} */ + +#endif // STA_STM32_CLOCKS_HPP diff --git a/include/sta/stm32/delay.hpp b/include/sta/stm32/delay.hpp new file mode 100644 index 0000000..fee499c --- /dev/null +++ b/include/sta/stm32/delay.hpp @@ -0,0 +1,68 @@ +/** + * @file + * @brief Delay functions. + */ +#ifndef STA_STM32_DELAY_HPP +#define STA_STM32_DELAY_HPP + +/** + * @defgroup stm32Delay Delay + * @ingroup stm32 + * @brief STM32 Delay module. + */ + +#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. + * + * 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 + + +#include +#ifdef STA_STM32_DELAY_ENABLE + +#include + + +namespace sta +{ + /** + * @brief Millisecond delay. + * + * @param ms Milliseconds + * + * @ingroup stm32Delay + */ + void delayMs(uint32_t ms); + +#ifdef STA_STM32_DELAY_US_TIM + /** + * @brief Microsecond delay. + * + * @param us Microseconds + * + * @ingroup stm32Delay + */ + void delayUs(uint32_t us); +#endif // STA_STM32_DELAY_US_TIM +} // namespace sta + + +#endif // STA_STM32_DELAY_ENABLE + +#endif // STA_STM32_DELAY_HPP diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp new file mode 100644 index 0000000..8fc5938 --- /dev/null +++ b/include/sta/stm32/gpio_pin.hpp @@ -0,0 +1,82 @@ +/** + * @file + * @brief Wrapper for STM32 GPIO pins. + */ +#ifndef STA_STM32_GPIO_PIN_HPP +#define STA_STM32_GPIO_PIN_HPP + +/** + * @defgroup stm32GPIO GPIO + * @ingroup stm32 + * @brief STM GPIO module. + */ + +#ifdef DOXYGEN +/** + * @def STA_STM32_GPIO_ENABLE + * @brief Enable module. + * + * @ingroup stm32BuildConfig + */ +# define STA_STM32_GPIO_ENABLE +#endif // DOXYGEN + + +#include +#ifdef STA_STM32_GPIO_ENABLE + +#include + +#include + + +namespace sta +{ + /** + * @brief Container for STM GPIO Pin data. + * + * @ingroup stm32GPIO + */ + class STM32GpioPin : public GpioPin + { + public: + STM32GpioPin(GPIO_TypeDef * port, uint16_t pin); + + void setState(GpioPinState state) override; + + GPIO_TypeDef * getPort() const; + uint16_t getPin() const; + uint8_t getIndex() const; + + private: + GPIO_TypeDef * port_; /**< GPIO port */ + uint16_t pin_; /**< GPIO pin */ + }; + + + /** + * @brief Interrupt trigger edge. + */ + enum class InterruptEdge + { + RISING, /**< Rising edge */ + FALLING, /**< Falling edge */ + BOTH /**< Rising and falling edge */ + }; + + bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge); +} // namespace sta + +/** + * @brief Create STM32GpioPin object from pin label. + * + * @param label Pin label + * + * @ingroup stm32GPIO + */ +#define STA_STM32_GPIO_PIN(label) sta::STM32GpioPin{label##_GPIO_Port, label##_Pin} + + +#endif // STA_STM32_GPIO_ENABLE + +#endif // STA_STM32_GPIO_PIN_HPP diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp new file mode 100644 index 0000000..322b44e --- /dev/null +++ b/include/sta/stm32/hal.hpp @@ -0,0 +1,8 @@ +#ifndef STA_STM32_HAL_HPP +#define STA_STM32_HAL_HPP + +// Include STM32 HAL headers +#include + + +#endif // STA_STM32_HAL_HPP diff --git a/include/sta/stm32/init.hpp b/include/sta/stm32/init.hpp new file mode 100644 index 0000000..7b1f350 --- /dev/null +++ b/include/sta/stm32/init.hpp @@ -0,0 +1,20 @@ +/** + * @file + * @brief Global STM32 HAL initialization. + */ +#ifndef STA_STM32_INIT_HPP +#define STA_STM32_INIT_HPP + + +namespace sta +{ + /** + * @brief Initialize global HAL objects. + * + * @ingroup stm32 + */ + void initHAL(); +} // namespace sta + + +#endif // STA_STM32_INIT_HPP diff --git a/include/sta/stm32/mcu/STM32F411xE.hpp b/include/sta/stm32/mcu/STM32F411xE.hpp new file mode 100644 index 0000000..1d4060b --- /dev/null +++ b/include/sta/stm32/mcu/STM32F411xE.hpp @@ -0,0 +1,77 @@ +/** + * @brief Configuration for STM32F411xE family. + */ +#ifndef STA_STM32_MCU_STM32F411xE_HPP +#define STA_STM32_MCU_STM32F411xE_HPP + + +#ifndef STM32F411xE +# error "MCU config incompatible" +#endif // !STM32F411xE + + +#include + + +// Peripheral clock mappings +// + +// TIM to PCLK +#define STA_STM32_TIM_1_PCLK_IDX 2 +#define STA_STM32_TIM_2_PCLK_IDX 1 +#define STA_STM32_TIM_3_PCLK_IDX 1 +#define STA_STM32_TIM_4_PCLK_IDX 1 +#define STA_STM32_TIM_5_PCLK_IDX 1 +#define STA_STM32_TIM_9_PCLK_IDX 2 +#define STA_STM32_TIM_10_PCLK_IDX 2 +#define STA_STM32_TIM_11_PCLK_IDX 2 + +// SPI to PCLK +#define STA_STM32_SPI_1_PCLK_IDX 2 +#define STA_STM32_SPI_2_PCLK_IDX 1 +#define STA_STM32_SPI_3_PCLK_IDX 1 +#define STA_STM32_SPI_4_PCLK_IDX 2 +#define STA_STM32_SPI_5_PCLK_IDX 2 + +// I2C to PCLK +#define STA_STM32_I2C_1_PCLK_IDX 1 +#define STA_STM32_I2C_2_PCLK_IDX 1 +#define STA_STM32_I2C_3_PCLK_IDX 1 + +// USART to PCLK +#define STA_STM32_USART_1_PCLK_IDX 2 +#define STA_STM32_USART_2_PCLK_IDX 1 +#define STA_STM32_USART_6_PCLK_IDX 2 + + +// HAL handle mappings +// + +#define STA_STM32_htim1_PCLK_IDX STA_STM32_TIM_1_PCLK_IDX +#define STA_STM32_htim2_PCLK_IDX STA_STM32_TIM_2_PCLK_IDX +#define STA_STM32_htim3_PCLK_IDX STA_STM32_TIM_3_PCLK_IDX +#define STA_STM32_htim4_PCLK_IDX STA_STM32_TIM_4_PCLK_IDX +#define STA_STM32_htim5_PCLK_IDX STA_STM32_TIM_5_PCLK_IDX +#define STA_STM32_htim9_PCLK_IDX STA_STM32_TIM_9_PCLK_IDX +#define STA_STM32_htim10_PCLK_IDX STA_STM32_TIM_10_PCLK_IDX +#define STA_STM32_htim11_PCLK_IDX STA_STM32_TIM_11_PCLK_IDX + +// SPI to PCLK +#define STA_STM32_hspi1_PCLK_IDX STA_STM32_SPI_1_PCLK_IDX +#define STA_STM32_hspi2_PCLK_IDX STA_STM32_SPI_2_PCLK_IDX +#define STA_STM32_hspi3_PCLK_IDX STA_STM32_SPI_3_PCLK_IDX +#define STA_STM32_hspi4_PCLK_IDX STA_STM32_SPI_4_PCLK_IDX +#define STA_STM32_hspi5_PCLK_IDX STA_STM32_SPI_5_PCLK_IDX + +// I2C to PCLK +#define STA_STM32_hi2c1_PCLK_IDX STA_STM32_I2C_1_PCLK_IDX +#define STA_STM32_hi2c2_PCLK_IDX STA_STM32_I2C_2_PCLK_IDX +#define STA_STM32_h12c3_PCLK_IDX STA_STM32_I2C_3_PCLK_IDX + +// USART to PCLK +#define STA_STM32_husart1_PCLK_IDX STA_STM32_USART_1_PCLK_IDX +#define STA_STM32_husart2_PCLK_IDX STA_STM32_USART_2_PCLK_IDX +#define STA_STM32_husart6_PCLK_IDX STA_STM32_USART_6_PCLK_IDX + + +#endif // STA_STM32_MCU_STM32F411xE_HPP diff --git a/include/sta/stm32/mcu/STM32F413xx.hpp b/include/sta/stm32/mcu/STM32F413xx.hpp new file mode 100644 index 0000000..dc02bbe --- /dev/null +++ b/include/sta/stm32/mcu/STM32F413xx.hpp @@ -0,0 +1,16 @@ +/** + * @brief Configuration for STM32F413xx family. + */ +#ifndef STA_STM32_MCU_STM32F413xx_HPP +#define STA_STM32_MCU_STM32F413xx_HPP + + +#ifndef STM32F413xx +# error "MCU config incompatible" +#endif // !STM32F413xx + + +#include + + +#endif // STA_STM32_MCU_STM32F413xx_HPP diff --git a/include/sta/stm32/mcu/common.hpp b/include/sta/stm32/mcu/common.hpp new file mode 100644 index 0000000..afe4d55 --- /dev/null +++ b/include/sta/stm32/mcu/common.hpp @@ -0,0 +1,12 @@ +/** + * @brief Common configuration for STM32 MCUs + */ +#ifndef STA_STM32_MCU_COMMON_HPP +#define STA_STM32_MCU_COMMON_HPP + + +// TODO: Are all STM32 MCUs little endian? +#define STA_MCU_LITTLE_ENDIAN + + +#endif // STA_STM32_MCU_COMMON_HPP diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp new file mode 100644 index 0000000..d68b262 --- /dev/null +++ b/include/sta/stm32/spi.hpp @@ -0,0 +1,133 @@ +/** + * @file + * @brief Implementations for SpiInterface and SpiDevice using STM32 HAL. + */ +#ifndef STA_STM32_SPI_HPP +#define STA_STM32_SPI_HPP + +/** + * @defgroup stm32SPI SPI + * @ingroup stm32 + * @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 + + +#include +#ifdef STA_STM32_SPI_ENABLE + +#ifndef STA_STM32_GPIO_ENABLE +#error "STM32 GPIO module required" +#endif // !STA_STM32_GPIO_ENABLE + + +#include +#include + +#include +#include + + +namespace sta +{ + /** + * @ingroup stm32SPI + * @{ + */ + + + /** + * @brief Get peripheral clock frequency. + * + * @return Clock frequency + */ + using STM32SpiPCLKFreqFn = uint32_t (*)(); + + /** + * @brief Info related to STM SPI interface. + */ + struct STM32SpiInterfaceInfo + { + SPI_HandleTypeDef * handle; /**< Interface handle */ + STM32SpiPCLKFreqFn getPCLKFreq; /**< Getter for peripheral clock used by interface */ + }; + + + /** + * @brief Implementation of SpiInterface interface using STM32 HAL. + */ + class STM32SpiInterface : public SpiInterface + { + public: + /** + * @param info SPI interface info + * @param mutex Mutex object for managing access. Pass nullptr for no access control + */ + STM32SpiInterface(const STM32SpiInterfaceInfo & info, Mutex * mutex = nullptr); + + void transfer(uint8_t value) override; + void transfer16(uint16_t value) override; + void transfer(const uint8_t * buffer, size_t size) override; + void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override; + void receive(uint8_t * buffer, size_t size) override; + + void fill(uint8_t value, size_t count) override; + + const SpiSettings & settings() const override; + + private: + STM32SpiInterfaceInfo info_; /**< SPI interface info */ + }; + + + /** + * @brief Implementation of SpiDevice interface using STM32 HAL. + */ + class STM32SpiDevice : public SpiDevice + { + public: + /** + * @param intf SPI interface + * @param csPin Device CS pin + */ + STM32SpiDevice(STM32SpiInterface * intf, STM32GpioPin csPin); + + private: + STM32GpioPin csPin_; /**< Device CS pin */ + }; + + + /** @} */ +} // namespace sta + + +/** + * @brief Get SPI interface info struct for STM32 HAL handle. + * + * Requires STA_STM32__PCLK_IDX to be defined for the MCU. + * MCU mappings are found in `core` -> sta/mcu/.hpp files. + * + * Check the MCUs Reference Manual RCC register documentation to see which + * peripheral clock is used. + * + * @param handle SPI interface handle + * + * @ingroup halSPI + */ +#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_HPP diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp new file mode 100644 index 0000000..97fb2dc --- /dev/null +++ b/include/sta/stm32/uart.hpp @@ -0,0 +1,66 @@ +/** + * @file + * @brief Implementation of UART using STM32 HAL. + */ +#ifndef STA_STM32_UART_HPP +#define STA_STM32_UART_HPP + +/** + * @defgroup stm32UART UART + * @ingroup stm32 + * @brief STM32 UART module. + */ + +#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. + * + * @ingroup stm32BuildConfig + */ +# define STA_STM32_UART_DEBUG_SERIAL +#endif // DOXYGEN + + +#include +#ifdef STA_STM32_UART_ENABLE + +#include + +#include + + +namespace sta +{ + /** + * @brief Implementation of UART interface using HAL. + * + * @ingroup stm32UART + */ + class STM32UART : public UART + { + public: + /** + * @param handle UART handle + */ + STM32UART(UART_HandleTypeDef * handle); + + void write(const uint8_t * buffer, size_t size) override; + + private: + UART_HandleTypeDef * handle_; /**< UART handle */ + }; +} // namespace sta + + +#endif // STA_STM32_UART_ENABLE + +#endif // STA_STM32_UART_HPP diff --git a/library.json b/library.json new file mode 100644 index 0000000..5bbf196 --- /dev/null +++ b/library.json @@ -0,0 +1,11 @@ +{ + "owner" : "sta", + "name": "sta-stm32-core", + "version": "0.1.0", + "dependencies": [ + { + "url": "git@gitlab.com:sta-git/avionics/stm32/libs/sta-core.git", + "ref": "main" + } + ] +} \ No newline at end of file diff --git a/src/can.cpp b/src/can.cpp new file mode 100644 index 0000000..ec83936 --- /dev/null +++ b/src/can.cpp @@ -0,0 +1,210 @@ +#include +#ifdef STA_STM32_CAN_ENABLE + +#include +#include + + +namespace sta +{ + STM32CanController::STM32CanController(CAN_HandleTypeDef * handle) + : handle_{handle} + { + initFilters(); + } + + + void STM32CanController::enableRxInterrupts() + { + HAL_CAN_ActivateNotification(handle_, + CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_RX_FIFO1_MSG_PENDING + ); + } + + + void STM32CanController::start() + { + HAL_CAN_Start(handle_); + } + + void STM32CanController::stop() + { + HAL_CAN_Stop(handle_); + } + + + bool STM32CanController::sendFrame(const CanTxHeader & header, const uint8_t * payload) + { + STA_ASSERT_MSG(header.payloadLength <= 8, "CAN 2.0B payload size exceeded"); + + CAN_TxHeaderTypeDef halHeader; + + if (header.id.format == CanIdFormat::STD) + { + halHeader.StdId = header.id.sid & 0x7FF; + halHeader.IDE = CAN_ID_STD; + } + else + { + // Combine SID and EID + halHeader.ExtId = ((header.id.sid & 0x7FF) << 18) | (header.id.eid & 0x3FFFF); + halHeader.IDE = CAN_ID_EXT; + } + + halHeader.DLC = header.payloadLength; + + uint32_t mailbox; // Don't care + return (HAL_OK == HAL_CAN_AddTxMessage(handle_, &halHeader, const_cast(payload), &mailbox)); + } + + bool STM32CanController::receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) + { + // Check if message is available + if (HAL_CAN_GetRxFifoFillLevel(handle_, fifo) == 0) + return false; + + // Retrieve message + CAN_RxHeaderTypeDef halHeader; + HAL_CAN_GetRxMessage(handle_, fifo, &halHeader, payload); + + if (halHeader.IDE == CAN_ID_STD) + { + header->id.format = CanIdFormat::STD; + header->id.sid = halHeader.StdId; + header->id.eid = 0; + } + else + { + header->id.format = CanIdFormat::EXT; + // Separate SID and EID + header->id.sid = (halHeader.ExtId >> 18); + header->id.eid = halHeader.ExtId & 0x3FFFF; + } + // No conversion required for CAN 2B standard + header->payloadLength = halHeader.DLC; + header->timestamp = halHeader.Timestamp; + header->filter = halHeader.FilterMatchIndex; + + return true; + } + + uint32_t STM32CanController::getRxFifoFlags() + { + // + return (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0) + | (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0) << 1; + } + + + void STM32CanController::configureFilter(uint8_t idx, const CanFilter & filter, bool active /* = false */) + { + CAN_FilterTypeDef * config = &filters_[idx]; + + if (filter.type == CanFilterIdFormat::STD) + { + config->FilterIdHigh = 0; + config->FilterIdLow = filter.obj.sid & 0x7FF; + config->FilterMaskIdHigh = 0; + config->FilterMaskIdLow = filter.mask.sid & 0x7FF; + } + else + { + config->FilterIdHigh = ((filter.obj.sid & 0x7FF) << 2) | ((filter.obj.eid >> 16) & 0x3); + config->FilterIdLow = filter.obj.eid & 0xFFFF; + config->FilterMaskIdHigh = ((filter.mask.sid & 0x7FF) << 2) | ((filter.mask.eid >> 16) & 0x3); + config->FilterMaskIdLow = filter.mask.eid & 0xFFFF; + } + + config->FilterFIFOAssignment = filter.fifo; + config->FilterActivation = (active ? CAN_FILTER_ENABLE : CAN_FILTER_DISABLE); + + HAL_CAN_ConfigFilter(handle_, config); + } + + void STM32CanController::enableFilter(uint8_t idx) + { + CAN_FilterTypeDef * config = &filters_[idx]; + + config->FilterActivation = CAN_FILTER_ENABLE; + + HAL_CAN_ConfigFilter(handle_, config); + } + + void STM32CanController::disableFilter(uint8_t idx) + { + CAN_FilterTypeDef * config = &filters_[idx]; + + config->FilterActivation = CAN_FILTER_DISABLE; + + HAL_CAN_ConfigFilter(handle_, config); + } + + void STM32CanController::clearFilters() + { + for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) + { + CAN_FilterTypeDef * config = &filters_[i]; + + // Only disable active filters + if (config->FilterActivation == CAN_FILTER_ENABLE) + { + config->FilterActivation = CAN_FILTER_DISABLE; + HAL_CAN_ConfigFilter(handle_, config); + } + } + } + + + void STM32CanController::initFilters() + { + for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) + { + CAN_FilterTypeDef * config = &filters_[i]; + + config->FilterBank = i; + config->FilterMode = CAN_FILTERMODE_IDMASK; + config->FilterScale = CAN_FILTERSCALE_32BIT; + config->FilterActivation = CAN_FILTER_DISABLE; + config->SlaveStartFilterBank = MAX_FILTER_COUNT; + } + } +} // namespace sta + + +#ifdef STA_STM32_CAN_GLOBAL + +#include + +namespace sta +{ + STM32CanController CanBus(&STA_STM32_CAN_GLOBAL); + + STA_WEAK + void CanBus_RxPendingCallback() + {} +} // namespace sta + + +extern "C" +{ + void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) + { + if (hcan == &STA_STM32_CAN_GLOBAL) + { + sta::CanBus_RxPendingCallback(); + } + } + + void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan) + { + if (hcan == &STA_STM32_CAN_GLOBAL) + { + sta::CanBus_RxPendingCallback(); + } + } +} + +#endif // STA_STM32_CAN_GLOBAL + + +#endif // STA_STM32_CAN_ENABLE diff --git a/src/delay.cpp b/src/delay.cpp new file mode 100644 index 0000000..9fef137 --- /dev/null +++ b/src/delay.cpp @@ -0,0 +1,66 @@ +#include +#ifdef STA_STM32_DELAY_ENABLE + +#include +#include + +#include +#include + + +namespace sta +{ + void delayMs(uint32_t ms) + { + HAL_Delay(ms); + } +} // namespace sta + + +#ifdef STA_STM32_DELAY_US_TIM + +#include + +namespace sta +{ + void delayUs(uint32_t us) + { + __HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0); + while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us); + } + + + bool isValidDelayUsTIM() + { + // Get PCLK multiplier for TIM clock + uint32_t pclkMul = 1; + switch (STA_STM32_DELAY_US_TIM.Init.ClockDivision) + { + case TIM_CLOCKDIVISION_DIV1: + pclkMul = 1; + break; + case TIM_CLOCKDIVISION_DIV2: + pclkMul = 2; + break; + case TIM_CLOCKDIVISION_DIV4: + pclkMul = 4; + break; + default: + STA_ASSERT(false); + STA_UNREACHABLE(); + } + + // Calculate TIM clock frequency + uint32_t clkFreq = pclkMul * STA_STM32_GET_HANDLE_PCLK_FREQ_FN(STA_STM32_DELAY_US_TIM)(); + // Calculate update frequency based on prescaler value + uint32_t updateFreq = clkFreq / STA_STM32_DELAY_US_TIM.Init.Prescaler; + + // TIM must have at least microsecond precision (>= 1 MHz frequency) + return (updateFreq == 1000000); + } +} // namespace sta + +#endif // STA_STM32_DELAY_US_TIM + + +#endif // STA_STM32_DELAY_ENABLE diff --git a/src/gpio_pin.cpp b/src/gpio_pin.cpp new file mode 100644 index 0000000..cb52d1d --- /dev/null +++ b/src/gpio_pin.cpp @@ -0,0 +1,83 @@ +#include +#ifdef STA_STM32_GPIO_ENABLE + +#include +#include + + +namespace sta +{ + STM32GpioPin::STM32GpioPin(GPIO_TypeDef * port, uint16_t pin) + : port_{port}, pin_{pin} + { + STA_ASSERT(port != nullptr); + } + + void STM32GpioPin::setState(GpioPinState state) + { + HAL_GPIO_WritePin(port_, pin_, (state == GpioPinState::LOW) ? GPIO_PIN_RESET : GPIO_PIN_SET); + } + + GPIO_TypeDef * STM32GpioPin::getPort() const + { + return port_; + } + + uint16_t STM32GpioPin::getPin() const + { + return pin_; + } + + uint8_t STM32GpioPin::getIndex() const + { + return GPIO_GET_INDEX(port_); + } + + + bool isInterruptEdge(const STM32GpioPin & gpioPin, InterruptEdge edge) + { + uint32_t pin = gpioPin.getPin(); + + for (uint32_t i = 0; i < 8 * sizeof(pin); ++i) + { + uint32_t ioPos = 1U << i; + if (pin & ioPos) + { + // Check input mode + uint32_t mode = (gpioPin.getPort()->MODER >> (2U * i)) & GPIO_MODE; + if (mode != MODE_INPUT) + { + return false; + } + + // Is EXTI configured? + if (EXTI->IMR & ioPos) + { + bool rising = (EXTI->RTSR & ioPos); + bool falling = (EXTI->FTSR & ioPos); + + switch (edge) + { + case InterruptEdge::RISING: + return rising; + + case InterruptEdge::FALLING: + return falling; + + case InterruptEdge::BOTH: + return rising && falling; + + default: + STA_ASSERT(false); + STA_UNREACHABLE(); + } + } + } + } + + return false; + } +} // namespace sta + + +#endif // STA_STM32_GPIO_ENABLE diff --git a/src/init.cpp b/src/init.cpp new file mode 100644 index 0000000..7b59818 --- /dev/null +++ b/src/init.cpp @@ -0,0 +1,22 @@ +#include + +#include + +#ifdef STA_STM32_DELAY_US_TIM +#include +#endif // STA_STM32_DELAY_US_TIM + + +namespace sta +{ + void initHAL() + { +#ifdef STA_STM32_DELAY_US_TIM + // Validate TIM used for delayUs + extern bool isValidDelayUsTIM(); + STA_ASSERT(isValidDelayUsTIM()); + // Start timer base + HAL_TIM_Base_Start(&STA_STM32_DELAY_US_TIM); +#endif // STA_STM32_DELAY_US_TIM + } +} // namespace sta diff --git a/src/spi.cpp b/src/spi.cpp new file mode 100644 index 0000000..90243aa --- /dev/null +++ b/src/spi.cpp @@ -0,0 +1,181 @@ +#include +#ifdef STA_STM32_SPI_ENABLE + +#include +#include +#include + + +#ifdef STA_MCU_LITTLE_ENDIAN +# 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 " +# endif // !STA_STM32_SPI_REVERSE_BIT_ORDER +#endif // !STA_MCU_LITTLE_ENDIAN && !STA_MCU_BIG_ENDIAN + + +namespace sta +{ + static SpiSettings getSpiSettings(SPI_HandleTypeDef * handle, uint32_t pclkFreq) + { + SpiSettings settings; + + settings.mode = getSpiMode( + (handle->Init.CLKPolarity == SPI_POLARITY_LOW) ? SpiClkPolarity::LOW : SpiClkPolarity::HIGH, + (handle->Init.CLKPhase == SPI_PHASE_1EDGE) ? SpiClkPhase::EDGE_1 : SpiClkPhase::EDGE_2 + ); + settings.dataSize = (handle->Init.DataSize == SPI_DATASIZE_8BIT) ? SpiDataSize::SIZE_8 : SpiDataSize::SIZE_16; + settings.bitOrder = (handle->Init.FirstBit == SPI_FIRSTBIT_MSB) ? SpiBitOrder::MSB : SpiBitOrder::LSB; + + uint32_t prescaler = 1; + switch (handle->Init.BaudRatePrescaler) + { + case SPI_BAUDRATEPRESCALER_2: + prescaler = 2; + break; + case SPI_BAUDRATEPRESCALER_4: + prescaler = 4; + break; + case SPI_BAUDRATEPRESCALER_8: + prescaler = 8; + break; + case SPI_BAUDRATEPRESCALER_16: + prescaler = 16; + break; + case SPI_BAUDRATEPRESCALER_32: + prescaler = 32; + break; + case SPI_BAUDRATEPRESCALER_64: + prescaler = 64; + break; + case SPI_BAUDRATEPRESCALER_128: + prescaler = 128; + break; + case SPI_BAUDRATEPRESCALER_256: + prescaler = 256; + break; + default: + // Unreachable case + STA_ASSERT_MSG(false, "Case for SPI_BAUDRATEPRESCALER not handled"); + STA_UNREACHABLE(); + } + + // SPI clock speed is based of PCLK + settings.clkSpeed = pclkFreq / prescaler; + + return settings; + } + + + STM32SpiInterface::STM32SpiInterface(const STM32SpiInterfaceInfo & info, Mutex * mutex /* = nullptr */) + : SpiInterface(mutex), info_{info} + { + STA_ASSERT(info.handle != nullptr); + STA_ASSERT(info.getPCLKFreq != nullptr); + } + + + void STM32SpiInterface::transfer(uint8_t value) + { + if (settings().dataSize == SpiDataSize::SIZE_8) + { + HAL_SPI_Transmit(info_.handle, &value, 1, HAL_MAX_DELAY); + } + else + { + // Required since tx buffer is cast to uint16_t * internally + uint16_t dummy = value; + HAL_SPI_Transmit(info_.handle, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); + } + } + + void STM32SpiInterface::transfer16(uint16_t value) + { + uint16_t size = 1; + + // Send as two bytes if data size is 8-bit + if (settings().dataSize == SpiDataSize::SIZE_8) + { + size = 2; + + if (settings().bitOrder == STA_STM32_SPI_REVERSE_BIT_ORDER) + { + // Reverse byte order from internal representation + value = STA_UINT16_SWAP_BYTE_ORDER(value); + } + } + + HAL_SPI_Transmit(info_.handle, reinterpret_cast(&value), size, HAL_MAX_DELAY); + } + + void STM32SpiInterface::transfer(const uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); + STA_ASSERT(size != 0); + + HAL_SPI_Transmit(info_.handle, const_cast(buffer), size, HAL_MAX_DELAY); + } + + void STM32SpiInterface::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) + { + STA_ASSERT(txBuffer != nullptr); + STA_ASSERT(rxBuffer != nullptr); + STA_ASSERT(size != 0); + + HAL_SPI_TransmitReceive(info_.handle, const_cast(txBuffer), rxBuffer, size, HAL_MAX_DELAY); + } + + void STM32SpiInterface::receive(uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); + + HAL_SPI_Receive(info_.handle, buffer, size, HAL_MAX_DELAY); + } + + + void STM32SpiInterface::fill(uint8_t value, size_t count) + { + STA_ASSERT(count != 0); + + if (settings().dataSize == SpiDataSize::SIZE_8) + { + for (size_t i = 0; i < count; ++i) + { + HAL_SPI_Transmit(info_.handle, &value, 1, HAL_MAX_DELAY); + } + } + else + { + // Required since tx buffer is cast to uint16_t * internally + uint16_t dummy = value; + for (size_t i = 0; i < count; ++i) + { + HAL_SPI_Transmit(info_.handle, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); + } + } + } + + + const SpiSettings & STM32SpiInterface::settings() const + { + // Cache settings + static SpiSettings settings = getSpiSettings(info_.handle, info_.getPCLKFreq()); + + return settings; + } + + + + + STM32SpiDevice::STM32SpiDevice(STM32SpiInterface * intf, STM32GpioPin csPin) + : SpiDevice(intf, &csPin_), csPin_{csPin} + {} +} // namespace sta + + +#endif // STA_HAL_SPI_ENABLE diff --git a/src/uart.cpp b/src/uart.cpp new file mode 100644 index 0000000..3a99564 --- /dev/null +++ b/src/uart.cpp @@ -0,0 +1,43 @@ +#include +#ifdef STA_STM32_UART_ENABLE + +#include + + +namespace sta +{ + STM32UART::STM32UART(UART_HandleTypeDef * handle) + : handle_{handle} + { + STA_ASSERT(handle != nullptr); + } + + + void STM32UART::write(const uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); + + HAL_UART_Transmit(handle_, const_cast(buffer), size, HAL_MAX_DELAY); + } +} // namespace sta + + +#ifdef STA_STM32_UART_DEBUG_SERIAL + +// Get extern declaration for DebugSerial because const namespace level variables have internal linkage by default +#include + +#include + +namespace sta +{ + STM32UART gStm32DebugSerial(&STA_STM32_UART_DEBUG_SERIAL); + + // Used by + PrintableUART DebugSerial(&gStm32DebugSerial); +} // namespace sta + +#endif // STA_STM32_UART_DEBUG_SERIAL + + +#endif // STA_STM32_UART_ENABLE From e4f5e3cd2e63b260ee30ae93770a52af958ce030 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Tue, 10 May 2022 02:11:40 +0200 Subject: [PATCH 02/28] Update doc --- include/sta/stm32/clocks.hpp | 23 ++++++++++++++++++++--- include/sta/stm32/gpio_pin.hpp | 30 ++++++++++++++++++++++++++++-- src/gpio_pin.cpp | 2 +- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp index 65e5d27..748f3c8 100644 --- a/include/sta/stm32/clocks.hpp +++ b/include/sta/stm32/clocks.hpp @@ -19,7 +19,7 @@ /** * @defgroup stm32Clocks Clocks * @ingroup stm32 - * @brief STM32 clock queries. + * @brief STM32 Clock queries. * @{ */ @@ -36,11 +36,28 @@ #define STA_STM32_GET_PCLK_FREQ_FN(n) HAL_RCC_GetPCLK ## n ## Freq -// Internal helper for macro expansion +/** + * @brief Internal helper for macro expansion. + * + * @param n PCLK index + * @return Function returning PCLK frequency + */ #define _STA_STM32_GET_PCLK_FREQ_FN(n) STA_STM32_GET_PCLK_FREQ_FN(n) -// Get instance to PCLK index map macro +/** + * @brief Map instance name to PCLK index. + * + * @param type Hardware type + * @param idx Instance index + * @return PCLK index + */ #define _STA_STM32_PCLK_IDX_MAP(type, idx) STA_STM32_ ## type ## _ ## idx ## _PCLK_IDX // Get HAL handle to PCLK index map macro +/** + * @brief Map instance handle to PCLK index. + * + * @param handle HAL handle + * @return PCLK index + */ #define _STA_STM32_HANDLE_PCLK_IDX_MAP(handle) STA_STM32_ ## handle ## _PCLK_IDX diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index 8fc5938..b340551 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -8,7 +8,7 @@ /** * @defgroup stm32GPIO GPIO * @ingroup stm32 - * @brief STM GPIO module. + * @brief STM32 GPIO module. */ #ifdef DOXYGEN @@ -40,13 +40,32 @@ namespace sta class STM32GpioPin : public GpioPin { public: + /** + * @param port GPIO port + * @param pin Pin index + */ STM32GpioPin(GPIO_TypeDef * port, uint16_t pin); void setState(GpioPinState state) override; + /** + * @brief Get GPIO port for pin. + * + * @return GPIO port + */ GPIO_TypeDef * getPort() const; + /** + * @brief Get pin index for pin. + * + * @return Pin index + */ uint16_t getPin() const; - uint8_t getIndex() const; + /** + * @brief Get GPIO port index for pin. + * + * @return GPIO port index + */ + uint8_t getPortIndex() const; private: GPIO_TypeDef * port_; /**< GPIO port */ @@ -64,6 +83,13 @@ namespace sta BOTH /**< Rising and falling edge */ }; + /** + * @brief Check pin EXIT pin configuration. + * + * @param pin GPIO pin + * @param edge Interrupt trigger edge + * @return True if EXIT pin and trigger edge matches + */ bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge); } // namespace sta diff --git a/src/gpio_pin.cpp b/src/gpio_pin.cpp index cb52d1d..11f841e 100644 --- a/src/gpio_pin.cpp +++ b/src/gpio_pin.cpp @@ -28,7 +28,7 @@ namespace sta return pin_; } - uint8_t STM32GpioPin::getIndex() const + uint8_t STM32GpioPin::getPortIndex() const { return GPIO_GET_INDEX(port_); } From b9f5949bfc06f7d02f8bb2e954a6c910a4bf907c Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Tue, 10 May 2022 15:37:23 +0200 Subject: [PATCH 03/28] Fix include paths --- include/sta/stm32/spi.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp index d68b262..4aa709f 100644 --- a/include/sta/stm32/spi.hpp +++ b/include/sta/stm32/spi.hpp @@ -32,8 +32,8 @@ #endif // !STA_STM32_GPIO_ENABLE -#include -#include +#include +#include #include #include From 441f42fb621b046b8dc942358db9edede8f37af0 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 2 Dec 2022 16:25:40 +0100 Subject: [PATCH 04/28] Update deps url --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 5bbf196..8ba3fc7 100644 --- a/library.json +++ b/library.json @@ -4,7 +4,7 @@ "version": "0.1.0", "dependencies": [ { - "url": "git@gitlab.com:sta-git/avionics/stm32/libs/sta-core.git", + "url": "git@gitlab.com:sta-git/alpaka/sta-core.git", "ref": "main" } ] From d793e1dc1c352221aacad2afaec5ac427d496a32 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 13 Jan 2023 14:04:23 +0100 Subject: [PATCH 05/28] Fix usDelay handling freq != 1MHz incorrectly --- src/delay.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/delay.cpp b/src/delay.cpp index 9fef137..684cf8f 100644 --- a/src/delay.cpp +++ b/src/delay.cpp @@ -23,10 +23,12 @@ namespace sta namespace sta { + uint32_t gDelayUsMul = 1; + void delayUs(uint32_t us) { __HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0); - while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us); + while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us * gDelayUsMul); } @@ -53,10 +55,13 @@ namespace sta // Calculate TIM clock frequency uint32_t clkFreq = pclkMul * STA_STM32_GET_HANDLE_PCLK_FREQ_FN(STA_STM32_DELAY_US_TIM)(); // Calculate update frequency based on prescaler value - uint32_t updateFreq = clkFreq / STA_STM32_DELAY_US_TIM.Init.Prescaler; + uint32_t prescaler = (STA_STM32_DELAY_US_TIM.Init.Prescaler) ? STA_STM32_DELAY_US_TIM.Init.Prescaler : 1; + uint32_t updateFreq = clkFreq / prescaler; + + gDelayUsMul = updateFreq / 1000000; // TIM must have at least microsecond precision (>= 1 MHz frequency) - return (updateFreq == 1000000); + return (updateFreq >= 1000000); } } // namespace sta From 6bc05daad000c30d2b4e57aab9d68fa4296cbffe Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 23:02:42 +0100 Subject: [PATCH 06/28] Move source files to subdir --- src/{ => stm32}/can.cpp | 0 src/{ => stm32}/delay.cpp | 0 src/{ => stm32}/gpio_pin.cpp | 0 src/{ => stm32}/init.cpp | 0 src/{ => stm32}/spi.cpp | 0 src/{ => stm32}/uart.cpp | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => stm32}/can.cpp (100%) rename src/{ => stm32}/delay.cpp (100%) rename src/{ => stm32}/gpio_pin.cpp (100%) rename src/{ => stm32}/init.cpp (100%) rename src/{ => stm32}/spi.cpp (100%) rename src/{ => stm32}/uart.cpp (100%) diff --git a/src/can.cpp b/src/stm32/can.cpp similarity index 100% rename from src/can.cpp rename to src/stm32/can.cpp diff --git a/src/delay.cpp b/src/stm32/delay.cpp similarity index 100% rename from src/delay.cpp rename to src/stm32/delay.cpp diff --git a/src/gpio_pin.cpp b/src/stm32/gpio_pin.cpp similarity index 100% rename from src/gpio_pin.cpp rename to src/stm32/gpio_pin.cpp diff --git a/src/init.cpp b/src/stm32/init.cpp similarity index 100% rename from src/init.cpp rename to src/stm32/init.cpp diff --git a/src/spi.cpp b/src/stm32/spi.cpp similarity index 100% rename from src/spi.cpp rename to src/stm32/spi.cpp diff --git a/src/uart.cpp b/src/stm32/uart.cpp similarity index 100% rename from src/uart.cpp rename to src/stm32/uart.cpp From b7e24cd5a3a043ee318c45ae0a6dc12fbe25c06c Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 23:11:25 +0100 Subject: [PATCH 07/28] Add directory for Arduino implementations --- include/sta/arduino/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 include/sta/arduino/.gitkeep diff --git a/include/sta/arduino/.gitkeep b/include/sta/arduino/.gitkeep new file mode 100644 index 0000000..e69de29 From 2a5a816c571afc012c9eecb186a03c91cd9f967b Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 23:14:39 +0100 Subject: [PATCH 08/28] Flatten directories --- include/sta/{intf => }/gpio_pin.hpp | 0 include/sta/{intf => }/mutex.hpp | 0 include/sta/{intf => }/signal.hpp | 0 include/sta/{intf => }/time.hpp | 0 include/sta/{intf => }/uart.hpp | 0 src/{intf => }/mutex.cpp | 0 src/{intf => }/uart.cpp | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename include/sta/{intf => }/gpio_pin.hpp (100%) rename include/sta/{intf => }/mutex.hpp (100%) rename include/sta/{intf => }/signal.hpp (100%) rename include/sta/{intf => }/time.hpp (100%) rename include/sta/{intf => }/uart.hpp (100%) rename src/{intf => }/mutex.cpp (100%) rename src/{intf => }/uart.cpp (100%) diff --git a/include/sta/intf/gpio_pin.hpp b/include/sta/gpio_pin.hpp similarity index 100% rename from include/sta/intf/gpio_pin.hpp rename to include/sta/gpio_pin.hpp diff --git a/include/sta/intf/mutex.hpp b/include/sta/mutex.hpp similarity index 100% rename from include/sta/intf/mutex.hpp rename to include/sta/mutex.hpp diff --git a/include/sta/intf/signal.hpp b/include/sta/signal.hpp similarity index 100% rename from include/sta/intf/signal.hpp rename to include/sta/signal.hpp diff --git a/include/sta/intf/time.hpp b/include/sta/time.hpp similarity index 100% rename from include/sta/intf/time.hpp rename to include/sta/time.hpp diff --git a/include/sta/intf/uart.hpp b/include/sta/uart.hpp similarity index 100% rename from include/sta/intf/uart.hpp rename to include/sta/uart.hpp diff --git a/src/intf/mutex.cpp b/src/mutex.cpp similarity index 100% rename from src/intf/mutex.cpp rename to src/mutex.cpp diff --git a/src/intf/uart.cpp b/src/uart.cpp similarity index 100% rename from src/intf/uart.cpp rename to src/uart.cpp From c4ef41ddf7a0d3809345b8cffe4e0167d5569c6f Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 23:22:35 +0100 Subject: [PATCH 09/28] Fix changed includes --- include/sta/atomic/mutex.hpp | 2 +- include/sta/atomic/signal.hpp | 2 +- include/sta/printable_uart.hpp | 2 +- include/sta/spi/device.hpp | 2 +- include/sta/spi/interface.hpp | 2 +- include/sta/stm32/gpio_pin.hpp | 2 +- include/sta/stm32/uart.hpp | 2 +- src/mutex.cpp | 2 +- src/uart.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/sta/atomic/mutex.hpp b/include/sta/atomic/mutex.hpp index b0824ab..a41b89f 100644 --- a/include/sta/atomic/mutex.hpp +++ b/include/sta/atomic/mutex.hpp @@ -10,7 +10,7 @@ #include #ifdef STA_ATOMIC_ENABLE -#include +#include #include diff --git a/include/sta/atomic/signal.hpp b/include/sta/atomic/signal.hpp index 9f846cf..b84f030 100644 --- a/include/sta/atomic/signal.hpp +++ b/include/sta/atomic/signal.hpp @@ -10,7 +10,7 @@ #include #ifdef STA_ATOMIC_ENABLE -#include +#include #include diff --git a/include/sta/printable_uart.hpp b/include/sta/printable_uart.hpp index 35e62eb..5117dee 100644 --- a/include/sta/printable_uart.hpp +++ b/include/sta/printable_uart.hpp @@ -5,7 +5,7 @@ #ifndef STA_PRINTABLE_UART_HPP #define STA_PRINTABLE_UART_HPP -#include +#include #include #include diff --git a/include/sta/spi/device.hpp b/include/sta/spi/device.hpp index 2c4c589..727e880 100644 --- a/include/sta/spi/device.hpp +++ b/include/sta/spi/device.hpp @@ -5,7 +5,7 @@ #ifndef STA_SPI_DEVICE_HPP #define STA_SPI_DEVICE_HPP -#include +#include #include #include diff --git a/include/sta/spi/interface.hpp b/include/sta/spi/interface.hpp index a7a7d03..d139860 100644 --- a/include/sta/spi/interface.hpp +++ b/include/sta/spi/interface.hpp @@ -5,7 +5,7 @@ #ifndef STA_SPI_INTERFACE_HPP #define STA_SPI_INTERFACE_HPP -#include +#include #include #include diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index b340551..f93cffc 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -25,7 +25,7 @@ #include #ifdef STA_STM32_GPIO_ENABLE -#include +#include #include diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index 97fb2dc..e98c30d 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -33,7 +33,7 @@ #include #ifdef STA_STM32_UART_ENABLE -#include +#include #include diff --git a/src/mutex.cpp b/src/mutex.cpp index ba8af2e..b861ebd 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -1,4 +1,4 @@ -#include +#include namespace sta diff --git a/src/uart.cpp b/src/uart.cpp index 9d06dae..e4eaa35 100644 --- a/src/uart.cpp +++ b/src/uart.cpp @@ -1,4 +1,4 @@ -#include +#include #include From 7f2f4a4df90f8c1deace8eba737f801b43506a96 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 23:35:15 +0100 Subject: [PATCH 10/28] Change include guard prefix to STA_CORE --- include/sta/assert.hpp | 6 +++--- include/sta/atomic/mutex.hpp | 6 +++--- include/sta/atomic/signal.hpp | 6 +++--- include/sta/can/controller.hpp | 6 +++--- include/sta/can/filter.hpp | 6 +++--- include/sta/can/headers.hpp | 6 +++--- include/sta/can/id.hpp | 6 +++--- include/sta/can/iter.hpp | 6 +++--- include/sta/can/subscribable.hpp | 6 +++--- include/sta/can/subscribable.tpp | 12 ++++++------ include/sta/debug_serial.hpp | 6 +++--- include/sta/endian.hpp | 6 +++--- include/sta/enum_flags.hpp | 6 +++--- include/sta/enum_flags.tpp | 10 +++++----- include/sta/fifo_buffer.hpp | 6 +++--- include/sta/fifo_buffer.tpp | 10 +++++----- include/sta/gpio_pin.hpp | 6 +++--- include/sta/lang.hpp | 6 +++--- include/sta/mutex.hpp | 6 +++--- include/sta/printable_uart.hpp | 6 +++--- include/sta/printf.hpp | 6 +++--- include/sta/signal.hpp | 6 +++--- include/sta/spi/device.hpp | 6 +++--- include/sta/spi/interface.hpp | 6 +++--- include/sta/spi/settings.hpp | 6 +++--- include/sta/stm32/can.hpp | 6 +++--- include/sta/stm32/clocks.hpp | 6 +++--- include/sta/stm32/delay.hpp | 6 +++--- include/sta/stm32/gpio_pin.hpp | 6 +++--- include/sta/stm32/hal.hpp | 6 +++--- include/sta/stm32/init.hpp | 6 +++--- include/sta/stm32/mcu/STM32F411xE.hpp | 6 +++--- include/sta/stm32/mcu/STM32F413xx.hpp | 6 +++--- include/sta/stm32/mcu/common.hpp | 6 +++--- include/sta/stm32/spi.hpp | 6 +++--- include/sta/stm32/uart.hpp | 6 +++--- include/sta/time.hpp | 6 +++--- include/sta/uart.hpp | 6 +++--- 38 files changed, 121 insertions(+), 121 deletions(-) diff --git a/include/sta/assert.hpp b/include/sta/assert.hpp index a3aa2a8..adf08ac 100644 --- a/include/sta/assert.hpp +++ b/include/sta/assert.hpp @@ -2,8 +2,8 @@ * @file * @brief Assertion handling. */ -#ifndef STA_ASSERT_HPP -#define STA_ASSERT_HPP +#ifndef STA_CORE_ASSERT_HPP +#define STA_CORE_ASSERT_HPP /** * @defgroup staCore Core @@ -164,4 +164,4 @@ namespace sta #endif // !STA_ASSERT_ENABLE -#endif // STA_ASSERT_HPP +#endif // STA_CORE_ASSERT_HPP diff --git a/include/sta/atomic/mutex.hpp b/include/sta/atomic/mutex.hpp index a41b89f..2001152 100644 --- a/include/sta/atomic/mutex.hpp +++ b/include/sta/atomic/mutex.hpp @@ -4,8 +4,8 @@ * Configuration: * STA_ATOMIC_ENABLE: Enable module */ -#ifndef STA_ATOMIC_MUTEX_HPP -#define STA_ATOMIC_MUTEX_HPP +#ifndef STA_CORE_ATOMIC_MUTEX_HPP +#define STA_CORE_ATOMIC_MUTEX_HPP #include #ifdef STA_ATOMIC_ENABLE @@ -36,4 +36,4 @@ namespace sta #endif // STA_ATOMIC_ENABLE -#endif // STA_ATOMIC_MUTEX_HPP +#endif // STA_CORE_ATOMIC_MUTEX_HPP diff --git a/include/sta/atomic/signal.hpp b/include/sta/atomic/signal.hpp index b84f030..8d9df3b 100644 --- a/include/sta/atomic/signal.hpp +++ b/include/sta/atomic/signal.hpp @@ -4,8 +4,8 @@ * Configuration: * STA_ATOMIC_ENABLE: Enable module */ -#ifndef STA_ATOMIC_SIGNAL_HPP -#define STA_ATOMIC_SIGNAL_HPP +#ifndef STA_CORE_ATOMIC_SIGNAL_HPP +#define STA_CORE_ATOMIC_SIGNAL_HPP #include #ifdef STA_ATOMIC_ENABLE @@ -38,4 +38,4 @@ namespace sta #endif // STA_ATOMIC_ENABLE -#endif // STA_ATOMIC_SIGNAL_HPP +#endif // STA_CORE_ATOMIC_SIGNAL_HPP diff --git a/include/sta/can/controller.hpp b/include/sta/can/controller.hpp index 73aee6d..305eeff 100644 --- a/include/sta/can/controller.hpp +++ b/include/sta/can/controller.hpp @@ -2,8 +2,8 @@ * @file * @brief CAN controller driver interface. */ -#ifndef STA_CAN_CONTROLLER_HPP -#define STA_CAN_CONTROLLER_HPP +#ifndef STA_CORE_CAN_CONTROLLER_HPP +#define STA_CORE_CAN_CONTROLLER_HPP /** * @defgroup can CAN @@ -117,4 +117,4 @@ namespace sta } // namespace sta -#endif // STA_CAN_CONTROLLER_HPP +#endif // STA_CORE_CAN_CONTROLLER_HPP diff --git a/include/sta/can/filter.hpp b/include/sta/can/filter.hpp index a38c6d1..f8a98a8 100644 --- a/include/sta/can/filter.hpp +++ b/include/sta/can/filter.hpp @@ -2,8 +2,8 @@ * @file * @brief CAN message filter types. */ -#ifndef STA_CAN_FILTER_HPP -#define STA_CAN_FILTER_HPP +#ifndef STA_CORE_CAN_FILTER_HPP +#define STA_CORE_CAN_FILTER_HPP #include @@ -46,4 +46,4 @@ namespace sta } // namespace sta -#endif // STA_CAN_FILTER_HPP +#endif // STA_CORE_CAN_FILTER_HPP diff --git a/include/sta/can/headers.hpp b/include/sta/can/headers.hpp index a7667dc..99f0d81 100644 --- a/include/sta/can/headers.hpp +++ b/include/sta/can/headers.hpp @@ -2,8 +2,8 @@ * @file * @brief CAN frame headers. */ -#ifndef STA_CAN_HEADERS_HPP -#define STA_CAN_HEADERS_HPP +#ifndef STA_CORE_CAN_HEADERS_HPP +#define STA_CORE_CAN_HEADERS_HPP #include @@ -45,4 +45,4 @@ namespace sta } // namespace sta -#endif // STA_CAN_HEADERS_HPP +#endif // STA_CORE_CAN_HEADERS_HPP diff --git a/include/sta/can/id.hpp b/include/sta/can/id.hpp index f0202bd..0cd9f57 100644 --- a/include/sta/can/id.hpp +++ b/include/sta/can/id.hpp @@ -2,8 +2,8 @@ * @file * @brief CAN frame ID types. */ -#ifndef STA_CAN_ID_HPP -#define STA_CAN_ID_HPP +#ifndef STA_CORE_CAN_ID_HPP +#define STA_CORE_CAN_ID_HPP #include @@ -115,4 +115,4 @@ namespace sta #define CAN_EID_MAX UINT32_C(0x3FFFF) -#endif // STA_CAN_ID_HPP +#endif // STA_CORE_CAN_ID_HPP diff --git a/include/sta/can/iter.hpp b/include/sta/can/iter.hpp index fbd7722..5f2d8a3 100644 --- a/include/sta/can/iter.hpp +++ b/include/sta/can/iter.hpp @@ -1,5 +1,5 @@ -#ifndef STA_CAN_ITER_HPP -#define STA_CAN_ITER_HPP +#ifndef STA_CORE_CAN_ITER_HPP +#define STA_CORE_CAN_ITER_HPP #include @@ -60,4 +60,4 @@ namespace sta } // namespace sta -#endif // STA_CAN_ITER_HPP +#endif // STA_CORE_CAN_ITER_HPP diff --git a/include/sta/can/subscribable.hpp b/include/sta/can/subscribable.hpp index 87bdeef..0251cc6 100644 --- a/include/sta/can/subscribable.hpp +++ b/include/sta/can/subscribable.hpp @@ -2,8 +2,8 @@ * @file * @brief Subscription interface for CAN controller drivers. */ -#ifndef STA_CAN_SUBSCRIBABLE_HPP -#define STA_CAN_SUBSCRIBABLE_HPP +#ifndef STA_CORE_CAN_SUBSCRIBABLE_HPP +#define STA_CORE_CAN_SUBSCRIBABLE_HPP #include #include @@ -101,4 +101,4 @@ namespace sta #include -#endif // STA_CAN_SUBSCRIBABLE_HPP +#endif // STA_CORE_CAN_SUBSCRIBABLE_HPP diff --git a/include/sta/can/subscribable.tpp b/include/sta/can/subscribable.tpp index e50008c..d05fc9c 100644 --- a/include/sta/can/subscribable.tpp +++ b/include/sta/can/subscribable.tpp @@ -1,12 +1,12 @@ /** * @brief Implementation of template class CanController. */ -#ifndef STA_CAN_SUBSCRIBABLE_TPP -#define STA_CAN_SUBSCRIBABLE_TPP +#ifndef STA_CORE_CAN_SUBSCRIBABLE_TPP +#define STA_CORE_CAN_SUBSCRIBABLE_TPP -#ifndef STA_CAN_SUBSCRIBABLE_HPP -#error "Direct use of internal header. Use instead" -#endif // !STA_CAN_SUBSCRIBABLE_HPP +#ifndef STA_CORE_CAN_SUBSCRIBABLE_HPP +#error "Direct use of internal header. Use instead" +#endif // !STA_CORE_CAN_SUBSCRIBABLE_HPP #ifndef STA_STDLIB_DISABLE # include // fill_n @@ -117,4 +117,4 @@ namespace sta } // namespace sta -#endif // STA_CAN_SUBSCRIBABLE_TPP +#endif // STA_CORE_CAN_SUBSCRIBABLE_TPP diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 6a2b964..68cb77d 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -13,8 +13,8 @@ * the default internal linkage of const namespace variables * will cause undefined reference errors otherwise. */ -#ifndef STA_DEBUG_SERIAL_HPP -#define STA_DEBUG_SERIAL_HPP +#ifndef STA_CORE_DEBUG_SERIAL_HPP +#define STA_CORE_DEBUG_SERIAL_HPP /** * @defgroup staCoreDebug Debug Serial @@ -105,4 +105,4 @@ namespace sta #endif // !STA_DEBUG_SERIAL_ENABLE -#endif // STA_DEBUG_SERIAL_HPP +#endif // STA_CORE_DEBUG_SERIAL_HPP diff --git a/include/sta/endian.hpp b/include/sta/endian.hpp index 41abaa2..7abf201 100644 --- a/include/sta/endian.hpp +++ b/include/sta/endian.hpp @@ -2,8 +2,8 @@ * @file * @brief Helper macros for managing endian handling. */ -#ifndef STA_ENDIAN_HPP -#define STA_ENDIAN_HPP +#ifndef STA_CORE_ENDIAN_HPP +#define STA_CORE_ENDIAN_HPP /** * @defgroup staCoreEndian Endian @@ -201,4 +201,4 @@ #endif // STA_MCU_BIG_ENDIAN -#endif // STA_ENDIAN_HPP +#endif // STA_CORE_ENDIAN_HPP diff --git a/include/sta/enum_flags.hpp b/include/sta/enum_flags.hpp index f848487..f7704e6 100644 --- a/include/sta/enum_flags.hpp +++ b/include/sta/enum_flags.hpp @@ -2,8 +2,8 @@ * @file * @brief Helper for using enum values as flags. */ -#ifndef STA_ENUM_FLAGS_HPP -#define STA_ENUM_FLAGS_HPP +#ifndef STA_CORE_ENUM_FLAGS_HPP +#define STA_CORE_ENUM_FLAGS_HPP #include @@ -195,4 +195,4 @@ namespace sta #include -#endif // STA_ENUM_FLAGS_HPP +#endif // STA_CORE_ENUM_FLAGS_HPP diff --git a/include/sta/enum_flags.tpp b/include/sta/enum_flags.tpp index 3321973..9251b05 100644 --- a/include/sta/enum_flags.tpp +++ b/include/sta/enum_flags.tpp @@ -1,12 +1,12 @@ /** * @brief Template class implementation for `EnumFlags`. */ -#ifndef STA_ENUM_FLAGS_TPP -#define STA_ENUM_FLAGS_TPP +#ifndef STA_CORE_ENUM_FLAGS_TPP +#define STA_CORE_ENUM_FLAGS_TPP -#ifndef STA_ENUM_FLAGS_HPP +#ifndef STA_CORE_ENUM_FLAGS_HPP # error "Direct use of internal header. Use instead" -#endif // !STA_ENUM_FLAGS_HPP +#endif // !STA_CORE_ENUM_FLAGS_HPP namespace sta @@ -113,4 +113,4 @@ namespace sta } // namespace sta -#endif // STA_ENUM_FLAGS_TPP +#endif // STA_CORE_ENUM_FLAGS_TPP diff --git a/include/sta/fifo_buffer.hpp b/include/sta/fifo_buffer.hpp index 2971712..646aff3 100644 --- a/include/sta/fifo_buffer.hpp +++ b/include/sta/fifo_buffer.hpp @@ -2,8 +2,8 @@ * @file * @brief FIFO buffer type. */ -#ifndef STA_FIFO_BUFFER_HPP -#define STA_FIFO_BUFFER_HPP +#ifndef STA_CORE_FIFO_BUFFER_HPP +#define STA_CORE_FIFO_BUFFER_HPP namespace sta @@ -115,4 +115,4 @@ namespace sta #include -#endif // STA_FIFO_BUFFER_HPP +#endif // STA_CORE_FIFO_BUFFER_HPP diff --git a/include/sta/fifo_buffer.tpp b/include/sta/fifo_buffer.tpp index b593d53..c02db2e 100644 --- a/include/sta/fifo_buffer.tpp +++ b/include/sta/fifo_buffer.tpp @@ -1,9 +1,9 @@ -#ifndef STA_FIFO_BUFFER_TPP -#define STA_FIFO_BUFFER_TPP +#ifndef STA_CORE_FIFO_BUFFER_TPP +#define STA_CORE_FIFO_BUFFER_TPP -#ifndef STA_FIFO_BUFFER_HPP +#ifndef STA_CORE_FIFO_BUFFER_HPP # error "Internal header. Include instead" -#endif // !STA_FIFO_BUFFER_HPP +#endif // !STA_CORE_FIFO_BUFFER_HPP #include @@ -100,4 +100,4 @@ namespace sta } // namespace sta -#endif // STA_FIFO_BUFFER_TPP +#endif // STA_CORE_FIFO_BUFFER_TPP diff --git a/include/sta/gpio_pin.hpp b/include/sta/gpio_pin.hpp index f91d27c..090c0f1 100644 --- a/include/sta/gpio_pin.hpp +++ b/include/sta/gpio_pin.hpp @@ -1,8 +1,8 @@ /** * @brief GPIO pin interface definitions. */ -#ifndef STA_GPIO_PIN_HPP -#define STA_GPIO_PIN_HPP +#ifndef STA_CORE_GPIO_PIN_HPP +#define STA_CORE_GPIO_PIN_HPP namespace sta @@ -32,4 +32,4 @@ namespace sta } // namespace sta -#endif // STA_GPIO_PIN_HPP +#endif // STA_CORE_GPIO_PIN_HPP diff --git a/include/sta/lang.hpp b/include/sta/lang.hpp index a09b2ba..6f83b4b 100644 --- a/include/sta/lang.hpp +++ b/include/sta/lang.hpp @@ -2,8 +2,8 @@ * @file * @brief Helper for useful compiler features. */ -#ifndef STA_LANG_HPP -#define STA_LANG_HPP +#ifndef STA_CORE_LANG_HPP +#define STA_CORE_LANG_HPP /** * @defgroup staCoreLang Lang @@ -113,4 +113,4 @@ /** @} */ -#endif // STA_LANG_HPP +#endif // STA_CORE_LANG_HPP diff --git a/include/sta/mutex.hpp b/include/sta/mutex.hpp index 5f1334a..e19f47e 100644 --- a/include/sta/mutex.hpp +++ b/include/sta/mutex.hpp @@ -1,8 +1,8 @@ /** * @brief Mutex interface definition. */ -#ifndef STA_MUTEX_HPP -#define STA_MUTEX_HPP +#ifndef STA_CORE_MUTEX_HPP +#define STA_CORE_MUTEX_HPP namespace sta @@ -27,4 +27,4 @@ namespace sta } // namespace sta -#endif // STA_MUTEX_HPP +#endif // STA_CORE_MUTEX_HPP diff --git a/include/sta/printable_uart.hpp b/include/sta/printable_uart.hpp index 5117dee..a5e2843 100644 --- a/include/sta/printable_uart.hpp +++ b/include/sta/printable_uart.hpp @@ -2,8 +2,8 @@ * @file * @brief Printable UART interface definition. */ -#ifndef STA_PRINTABLE_UART_HPP -#define STA_PRINTABLE_UART_HPP +#ifndef STA_CORE_PRINTABLE_UART_HPP +#define STA_CORE_PRINTABLE_UART_HPP #include @@ -201,4 +201,4 @@ namespace sta } // namespace sta -#endif // STA_PRINTABLE_UART_HPP +#endif // STA_CORE_PRINTABLE_UART_HPP diff --git a/include/sta/printf.hpp b/include/sta/printf.hpp index a48de80..3f02595 100644 --- a/include/sta/printf.hpp +++ b/include/sta/printf.hpp @@ -2,8 +2,8 @@ * @file * @brief Compatibility layer for different printf implementations. */ -#ifndef STA_PRINTF_HPP -#define STA_PRINTF_HPP +#ifndef STA_CORE_PRINTF_HPP +#define STA_CORE_PRINTF_HPP #ifdef DOXYGEN /** @@ -39,4 +39,4 @@ #endif // STA_PRINTF_USE_MPALAND -#endif // STA_PRINTF_HPP +#endif // STA_CORE_PRINTF_HPP diff --git a/include/sta/signal.hpp b/include/sta/signal.hpp index b38abf3..ffb0e1e 100644 --- a/include/sta/signal.hpp +++ b/include/sta/signal.hpp @@ -1,8 +1,8 @@ /** * @brief Signal interface definition. */ -#ifndef STA_SIGNAL_HPP -#define STA_SIGNAL_HPP +#ifndef STA_CORE_SIGNAL_HPP +#define STA_CORE_SIGNAL_HPP namespace sta @@ -37,4 +37,4 @@ namespace sta } // namespace sta -#endif // STA_SIGNAL_HPP +#endif // STA_CORE_SIGNAL_HPP diff --git a/include/sta/spi/device.hpp b/include/sta/spi/device.hpp index 727e880..80c0dce 100644 --- a/include/sta/spi/device.hpp +++ b/include/sta/spi/device.hpp @@ -2,8 +2,8 @@ * @file * @brief SPI device interface. */ -#ifndef STA_SPI_DEVICE_HPP -#define STA_SPI_DEVICE_HPP +#ifndef STA_CORE_SPI_DEVICE_HPP +#define STA_CORE_SPI_DEVICE_HPP #include #include @@ -112,4 +112,4 @@ namespace sta } // namespace sta -#endif // STA_SPI_DEVICE_HPP +#endif // STA_CORE_SPI_DEVICE_HPP diff --git a/include/sta/spi/interface.hpp b/include/sta/spi/interface.hpp index d139860..b830526 100644 --- a/include/sta/spi/interface.hpp +++ b/include/sta/spi/interface.hpp @@ -2,8 +2,8 @@ * @file * @brief SPI interface definition. */ -#ifndef STA_SPI_INTERFACE_HPP -#define STA_SPI_INTERFACE_HPP +#ifndef STA_CORE_SPI_INTERFACE_HPP +#define STA_CORE_SPI_INTERFACE_HPP #include #include @@ -100,4 +100,4 @@ namespace sta } // namespace sta -#endif // STA_SPI_INTERFACE_HPP +#endif // STA_CORE_SPI_INTERFACE_HPP diff --git a/include/sta/spi/settings.hpp b/include/sta/spi/settings.hpp index 172309f..bbd0e35 100644 --- a/include/sta/spi/settings.hpp +++ b/include/sta/spi/settings.hpp @@ -2,8 +2,8 @@ * @file * @brief SPI settings. */ -#ifndef STA_SPI_SETTINGS_HPP -#define STA_SPI_SETTINGS_HPP +#ifndef STA_CORE_SPI_SETTINGS_HPP +#define STA_CORE_SPI_SETTINGS_HPP /** * @defgroup staCoreSPI SPI @@ -111,4 +111,4 @@ namespace sta } // namespace sta -#endif // STA_SPI_SETTINGS_HPP +#endif // STA_CORE_SPI_SETTINGS_HPP diff --git a/include/sta/stm32/can.hpp b/include/sta/stm32/can.hpp index 537a5f8..f440ece 100644 --- a/include/sta/stm32/can.hpp +++ b/include/sta/stm32/can.hpp @@ -2,8 +2,8 @@ * @file * @brief Implementation of CanController using STM32 HAL. */ -#ifndef STA_STM32_CAN_HPP -#define STA_STM32_CAN_HPP +#ifndef STA_CORE_STM32_CAN_HPP +#define STA_CORE_STM32_CAN_HPP /** * @defgroup stm32CAN CAN @@ -126,4 +126,4 @@ namespace sta #endif // STA_STM32_CAN_ENABLE -#endif // STA_STM32_CAN_HPP +#endif // STA_CORE_STM32_CAN_HPP diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp index 748f3c8..4828ae7 100644 --- a/include/sta/stm32/clocks.hpp +++ b/include/sta/stm32/clocks.hpp @@ -2,8 +2,8 @@ * @file * @brief Helper macros for STM32 clock queries. */ -#ifndef STA_STM32_CLOCKS_HPP -#define STA_STM32_CLOCKS_HPP +#ifndef STA_CORE_STM32_CLOCKS_HPP +#define STA_CORE_STM32_CLOCKS_HPP /** * @defgroup stm32 STM32 @@ -96,4 +96,4 @@ /** @} */ -#endif // STA_STM32_CLOCKS_HPP +#endif // STA_CORE_STM32_CLOCKS_HPP diff --git a/include/sta/stm32/delay.hpp b/include/sta/stm32/delay.hpp index fee499c..a9400dc 100644 --- a/include/sta/stm32/delay.hpp +++ b/include/sta/stm32/delay.hpp @@ -2,8 +2,8 @@ * @file * @brief Delay functions. */ -#ifndef STA_STM32_DELAY_HPP -#define STA_STM32_DELAY_HPP +#ifndef STA_CORE_STM32_DELAY_HPP +#define STA_CORE_STM32_DELAY_HPP /** * @defgroup stm32Delay Delay @@ -65,4 +65,4 @@ namespace sta #endif // STA_STM32_DELAY_ENABLE -#endif // STA_STM32_DELAY_HPP +#endif // STA_CORE_STM32_DELAY_HPP diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index f93cffc..8ed6910 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -2,8 +2,8 @@ * @file * @brief Wrapper for STM32 GPIO pins. */ -#ifndef STA_STM32_GPIO_PIN_HPP -#define STA_STM32_GPIO_PIN_HPP +#ifndef STA_CORE_STM32_GPIO_PIN_HPP +#define STA_CORE_STM32_GPIO_PIN_HPP /** * @defgroup stm32GPIO GPIO @@ -105,4 +105,4 @@ namespace sta #endif // STA_STM32_GPIO_ENABLE -#endif // STA_STM32_GPIO_PIN_HPP +#endif // STA_CORE_STM32_GPIO_PIN_HPP diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp index 322b44e..fb3dedd 100644 --- a/include/sta/stm32/hal.hpp +++ b/include/sta/stm32/hal.hpp @@ -1,8 +1,8 @@ -#ifndef STA_STM32_HAL_HPP -#define STA_STM32_HAL_HPP +#ifndef STA_CORE_STM32_HAL_HPP +#define STA_CORE_STM32_HAL_HPP // Include STM32 HAL headers #include -#endif // STA_STM32_HAL_HPP +#endif // STA_CORE_STM32_HAL_HPP diff --git a/include/sta/stm32/init.hpp b/include/sta/stm32/init.hpp index 7b1f350..fcff1c1 100644 --- a/include/sta/stm32/init.hpp +++ b/include/sta/stm32/init.hpp @@ -2,8 +2,8 @@ * @file * @brief Global STM32 HAL initialization. */ -#ifndef STA_STM32_INIT_HPP -#define STA_STM32_INIT_HPP +#ifndef STA_CORE_STM32_INIT_HPP +#define STA_CORE_STM32_INIT_HPP namespace sta @@ -17,4 +17,4 @@ namespace sta } // namespace sta -#endif // STA_STM32_INIT_HPP +#endif // STA_CORE_STM32_INIT_HPP diff --git a/include/sta/stm32/mcu/STM32F411xE.hpp b/include/sta/stm32/mcu/STM32F411xE.hpp index 1d4060b..48e0ecb 100644 --- a/include/sta/stm32/mcu/STM32F411xE.hpp +++ b/include/sta/stm32/mcu/STM32F411xE.hpp @@ -1,8 +1,8 @@ /** * @brief Configuration for STM32F411xE family. */ -#ifndef STA_STM32_MCU_STM32F411xE_HPP -#define STA_STM32_MCU_STM32F411xE_HPP +#ifndef STA_CORE_STM32_MCU_STM32F411xE_HPP +#define STA_CORE_STM32_MCU_STM32F411xE_HPP #ifndef STM32F411xE @@ -74,4 +74,4 @@ #define STA_STM32_husart6_PCLK_IDX STA_STM32_USART_6_PCLK_IDX -#endif // STA_STM32_MCU_STM32F411xE_HPP +#endif // STA_CORE_STM32_MCU_STM32F411xE_HPP diff --git a/include/sta/stm32/mcu/STM32F413xx.hpp b/include/sta/stm32/mcu/STM32F413xx.hpp index dc02bbe..cd0e2a5 100644 --- a/include/sta/stm32/mcu/STM32F413xx.hpp +++ b/include/sta/stm32/mcu/STM32F413xx.hpp @@ -1,8 +1,8 @@ /** * @brief Configuration for STM32F413xx family. */ -#ifndef STA_STM32_MCU_STM32F413xx_HPP -#define STA_STM32_MCU_STM32F413xx_HPP +#ifndef STA_CORE_STM32_MCU_STM32F413xx_HPP +#define STA_CORE_STM32_MCU_STM32F413xx_HPP #ifndef STM32F413xx @@ -13,4 +13,4 @@ #include -#endif // STA_STM32_MCU_STM32F413xx_HPP +#endif // STA_CORE_STM32_MCU_STM32F413xx_HPP diff --git a/include/sta/stm32/mcu/common.hpp b/include/sta/stm32/mcu/common.hpp index afe4d55..f10bd2a 100644 --- a/include/sta/stm32/mcu/common.hpp +++ b/include/sta/stm32/mcu/common.hpp @@ -1,12 +1,12 @@ /** * @brief Common configuration for STM32 MCUs */ -#ifndef STA_STM32_MCU_COMMON_HPP -#define STA_STM32_MCU_COMMON_HPP +#ifndef STA_CORE_STM32_MCU_COMMON_HPP +#define STA_CORE_STM32_MCU_COMMON_HPP // TODO: Are all STM32 MCUs little endian? #define STA_MCU_LITTLE_ENDIAN -#endif // STA_STM32_MCU_COMMON_HPP +#endif // STA_CORE_STM32_MCU_COMMON_HPP diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp index 4aa709f..dbb1a2a 100644 --- a/include/sta/stm32/spi.hpp +++ b/include/sta/stm32/spi.hpp @@ -2,8 +2,8 @@ * @file * @brief Implementations for SpiInterface and SpiDevice using STM32 HAL. */ -#ifndef STA_STM32_SPI_HPP -#define STA_STM32_SPI_HPP +#ifndef STA_CORE_STM32_SPI_HPP +#define STA_CORE_STM32_SPI_HPP /** * @defgroup stm32SPI SPI @@ -130,4 +130,4 @@ namespace sta #endif // STA_STM32_SPI_ENABLE -#endif // STA_STM32_SPI_HPP +#endif // STA_CORE_STM32_SPI_HPP diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index e98c30d..18fd891 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -2,8 +2,8 @@ * @file * @brief Implementation of UART using STM32 HAL. */ -#ifndef STA_STM32_UART_HPP -#define STA_STM32_UART_HPP +#ifndef STA_CORE_STM32_UART_HPP +#define STA_CORE_STM32_UART_HPP /** * @defgroup stm32UART UART @@ -63,4 +63,4 @@ namespace sta #endif // STA_STM32_UART_ENABLE -#endif // STA_STM32_UART_HPP +#endif // STA_CORE_STM32_UART_HPP diff --git a/include/sta/time.hpp b/include/sta/time.hpp index 2dd772a..da7ecd7 100644 --- a/include/sta/time.hpp +++ b/include/sta/time.hpp @@ -1,8 +1,8 @@ /** * @brief Signatures for time related functions. */ -#ifndef STA_TIME_HPP -#define STA_TIME_HPP +#ifndef STA_CORE_TIME_HPP +#define STA_CORE_TIME_HPP #include @@ -24,4 +24,4 @@ namespace sta } // namespace sta -#endif // STA_TIME_HPP +#endif // STA_CORE_TIME_HPP diff --git a/include/sta/uart.hpp b/include/sta/uart.hpp index e707c51..765216e 100644 --- a/include/sta/uart.hpp +++ b/include/sta/uart.hpp @@ -2,8 +2,8 @@ * @file * @brief UART interface definition. */ -#ifndef STA_INTF_UART_HPP -#define STA_INTF_UART_HPP +#ifndef STA_CORE_UART_HPP +#define STA_CORE_UART_HPP #include #include @@ -47,4 +47,4 @@ namespace sta } // namespace sta -#endif // STA_INTF_UART_HPP +#endif // STA_CORE_UART_HPP From dd2983821ed23ef8d9c9059357abf11e7bc96a12 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 20 Jan 2023 01:52:18 +0100 Subject: [PATCH 11/28] Change module enable logic --- include/sta/stm32/can.hpp | 24 ++++++++++++------------ include/sta/stm32/clocks.hpp | 5 +++++ include/sta/stm32/delay.hpp | 13 +++---------- include/sta/stm32/gpio_pin.hpp | 14 +++++++++++--- include/sta/stm32/hal.hpp | 1 + include/sta/stm32/spi.hpp | 29 ++++++++++++----------------- include/sta/stm32/uart.hpp | 23 +++++++++++------------ src/stm32/can.cpp | 4 ++-- src/stm32/delay.cpp | 8 ++++++-- src/stm32/gpio_pin.cpp | 4 ++-- src/stm32/spi.cpp | 12 +++--------- src/stm32/uart.cpp | 4 ++-- 12 files changed, 70 insertions(+), 71 deletions(-) diff --git a/include/sta/stm32/can.hpp b/include/sta/stm32/can.hpp index f440ece..1af57c4 100644 --- a/include/sta/stm32/can.hpp +++ b/include/sta/stm32/can.hpp @@ -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 -#ifdef STA_STM32_CAN_ENABLE +#ifdef STA_PLATFORM_STM32 +# include +# ifdef HAL_CAN_MODULE_ENABLED +# define STA_STM32_CAN_ENABLED +# endif // HAL_CAN_MODULE_ENABLED +#endif // STA_PLATFORM_STM32 -#include -#include +#ifdef STA_STM32_CAN_ENABLED + +#include 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 diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp index 4828ae7..29a9b4f 100644 --- a/include/sta/stm32/clocks.hpp +++ b/include/sta/stm32/clocks.hpp @@ -23,7 +23,10 @@ * @{ */ + +// Only enable module on STM32 platform #include +#ifdef STA_PLATFORM_STM32 #include @@ -96,4 +99,6 @@ /** @} */ +#endif // STA_PLATFORM_STM32 + #endif // STA_CORE_STM32_CLOCKS_HPP diff --git a/include/sta/stm32/delay.hpp b/include/sta/stm32/delay.hpp index a9400dc..94cbe90 100644 --- a/include/sta/stm32/delay.hpp +++ b/include/sta/stm32/delay.hpp @@ -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 -#ifdef STA_STM32_DELAY_ENABLE +#ifdef STA_PLATFORM_STM32 #include @@ -63,6 +56,6 @@ namespace sta } // namespace sta -#endif // STA_STM32_DELAY_ENABLE +#endif // STA_PLATFORM_STM32 #endif // STA_CORE_STM32_DELAY_HPP diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index 8ed6910..c69f6ed 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -22,12 +22,20 @@ #endif // DOXYGEN +// Only enable module on STM32 platform w/ HAL GPIO module enabled #include -#ifdef STA_STM32_GPIO_ENABLE +#ifdef STA_PLATFORM_STM32 +# include +# 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 -#include 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 diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp index fb3dedd..b6b5b4b 100644 --- a/include/sta/stm32/hal.hpp +++ b/include/sta/stm32/hal.hpp @@ -1,6 +1,7 @@ #ifndef STA_CORE_STM32_HAL_HPP #define STA_CORE_STM32_HAL_HPP + // Include STM32 HAL headers #include diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp index dbb1a2a..595cbf0 100644 --- a/include/sta/stm32/spi.hpp +++ b/include/sta/stm32/spi.hpp @@ -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 -#ifdef STA_STM32_SPI_ENABLE +#ifdef STA_PLATFORM_STM32 +# include +# 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 #include @@ -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 diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index 18fd891..45ab782 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -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 -#ifdef STA_STM32_UART_ENABLE +#ifdef STA_PLATFORM_STM32 +# include +# 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 -#include - 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 diff --git a/src/stm32/can.cpp b/src/stm32/can.cpp index ec83936..0e0379c 100644 --- a/src/stm32/can.cpp +++ b/src/stm32/can.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_STM32_CAN_ENABLE +#ifdef STA_STM32_CAN_ENABLED #include #include @@ -207,4 +207,4 @@ extern "C" #endif // STA_STM32_CAN_GLOBAL -#endif // STA_STM32_CAN_ENABLE +#endif // STA_STM32_CAN_ENABLED diff --git a/src/stm32/delay.cpp b/src/stm32/delay.cpp index 684cf8f..d9c58fc 100644 --- a/src/stm32/delay.cpp +++ b/src/stm32/delay.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_STM32_DELAY_ENABLE +#ifdef STA_PLATFORM_STM32 #include #include @@ -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 namespace sta @@ -68,4 +72,4 @@ namespace sta #endif // STA_STM32_DELAY_US_TIM -#endif // STA_STM32_DELAY_ENABLE +#endif // STA_PLATFORM_STM32 diff --git a/src/stm32/gpio_pin.cpp b/src/stm32/gpio_pin.cpp index 11f841e..20e3208 100644 --- a/src/stm32/gpio_pin.cpp +++ b/src/stm32/gpio_pin.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_STM32_GPIO_ENABLE +#ifdef STA_STM32_GPIO_ENABLED #include #include @@ -80,4 +80,4 @@ namespace sta } // namespace sta -#endif // STA_STM32_GPIO_ENABLE +#endif // STA_STM32_GPIO_ENABLED diff --git a/src/stm32/spi.cpp b/src/stm32/spi.cpp index 90243aa..955be2c 100644 --- a/src/stm32/spi.cpp +++ b/src/stm32/spi.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_STM32_SPI_ENABLE +#ifdef STA_STM32_SPI_ENABLED #include #include @@ -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 " -# 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 diff --git a/src/stm32/uart.cpp b/src/stm32/uart.cpp index 3a99564..d530c7c 100644 --- a/src/stm32/uart.cpp +++ b/src/stm32/uart.cpp @@ -1,5 +1,5 @@ #include -#ifdef STA_STM32_UART_ENABLE +#ifdef STA_STM32_UART_ENABLED #include @@ -40,4 +40,4 @@ namespace sta #endif // STA_STM32_UART_DEBUG_SERIAL -#endif // STA_STM32_UART_ENABLE +#endif // STA_STM32_UART_ENABLED From c1edafa59edffc382586840070972c3a9e079608 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 20 Jan 2023 02:24:00 +0100 Subject: [PATCH 12/28] Remove debug serial logic from stm32/uart module --- include/sta/debug_serial.hpp | 64 +++++++++++++++++------------------- include/sta/stm32/uart.hpp | 10 ------ src/debug_serial.cpp | 30 +++++++++++++++++ src/stm32/uart.cpp | 18 ---------- 4 files changed, 60 insertions(+), 62 deletions(-) create mode 100644 src/debug_serial.cpp diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 68cb77d..470bfed 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -3,15 +3,10 @@ * @brief Debug output via UART. * * Configuration: - * STA_DEBUG_SERIAL_ENABLE: Enable module - * STA_DEBUG_SERIAL_FORCE: Ignore debug defines and always enable output - * DEBUG: Enables output when defined - * NDEBUG: Disables output when defined (overrides DEBUG) - * - * The `sta::DebugSerial` instance must be provided. - * NOTE: Include this header before the definition because - * the default internal linkage of const namespace variables - * will cause undefined reference errors otherwise. + * 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 @@ -24,50 +19,51 @@ #ifdef DOXYGEN /** - * @def STA_DEBUG_SERIAL_ENABLE - * @brief Enable module. - * - * Automatically defined if DEBUG is defined. - * Automatically disabled if NDEBUG is defined. + * @def STA_DEBUG_SERIAL_UART + * @brief UART interface for debug output. * * @ingroup staCoreBuildConfig */ -# define STA_DEBUG_SERIAL_ENABLE +# define STA_DEBUG_SERIAL_UART /** - * @def STA_DEBUG_SERIAL_DISABLE - * @brief Force disable module. + * @def STA_DEBUG_SERIAL_FORCE + * @brief Force enable module. * - * Overrides STA_DEBUG_SERIAL_ENABLE option. + * Enables debug output even if NDEBUG is defined. * * @ingroup staCoreBuildConfig */ -# define STA_DEBUG_SERIAL_DISABLE +# define STA_DEBUG_SERIAL_FORCE #endif // DOXYGEN #include -#ifdef DEBUG -# ifndef STA_DEBUG_SERIAL_ENABLE -# define STA_DEBUG_SERIAL_ENABLE -# endif // !STA_DEBUG_SERIAL_ENABLE -#endif // DEBUG - -#if defined(NDEBUG) || defined(STA_DEBUG_SERIAL_DISABLE) -# ifdef STA_DEBUG_SERIAL_ENABLE -# undef STA_DEBUG_SERIAL_ENABLE -# endif // STA_DEBUG_SERIAL_ENABLE -#endif // NDEBUG || STA_DEBUG_SERIAL_DISABLE +// Determine if module should be enabled +// Condition 1: STA_DEBUG_SERIAL_UART is defined +// Condition 2: +// STA_DEBUG_SERIAL_FORCE is defined +// or +// DEBUG is defined but not NDEBUG +#ifdef STA_DEBUG_SERIAL_UART +# ifdef STA_DEBUG_SERIAL_FORCE +# define STA_DEBUG_SERIAL_ENABLED +# else // !STA_DEBUG_SERIAL_FORCE +# if defined(DEBUG) && !defined(NDEBUG) +# define STA_DEBUG_SERIAL_ENABLED +# endif // DEBUG && !NDEBUG +# endif // !STA_DEBUG_SERIAL_FORCE +#endif // STA_DEBUG_SERIAL_UART // Show enabled module in doxygen output #ifdef DOXYGEN -# define STA_DEBUG_SERIAL_ENABLE +# define STA_DEBUG_SERIAL_ENABLED #endif // DOXYGEN -#ifdef STA_DEBUG_SERIAL_ENABLE +#ifdef STA_DEBUG_SERIAL_ENABLED #include @@ -99,10 +95,10 @@ namespace sta * @ingroup staCoreDebug */ # define STA_DEBUG_PRINTLN(...) sta::DebugSerial.println(__VA_ARGS__) -#else // !STA_DEBUG_SERIAL_ENABLE +#else // !STA_DEBUG_SERIAL_ENABLED # define STA_DEBUG_PRINT(...) ((void)0) # define STA_DEBUG_PRINTLN(...) ((void)0) -#endif // !STA_DEBUG_SERIAL_ENABLE +#endif // !STA_DEBUG_SERIAL_ENABLED #endif // STA_CORE_DEBUG_SERIAL_HPP diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index 45ab782..7669968 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -11,16 +11,6 @@ * @brief STM32 UART module. */ -#ifdef DOXYGEN -/** - * @def STA_STM32_UART_DEBUG_SERIAL - * @brief Create global sta::DebugSerial object using this HAL UART instance. - * - * @ingroup stm32BuildConfig - */ -# define STA_STM32_UART_DEBUG_SERIAL -#endif // DOXYGEN - // Only enable module on STM32 platform w/ HAL UART module enabled #include diff --git a/src/debug_serial.cpp b/src/debug_serial.cpp new file mode 100644 index 0000000..68bb98f --- /dev/null +++ b/src/debug_serial.cpp @@ -0,0 +1,30 @@ +#include +#ifdef STA_DEBUG_SERIAL_ENABLED + + +#ifdef STA_PLATFORM_STM32 + +#include + +#include + +// Set platform UART alias +using PlatformUART = sta::STM32UART; + +#endif // STA_PLATFORM_STM32 + + +namespace +{ + // Create platform specific serial interface + PlatformUART platformDebugSerial(&STA_DEBUG_SERIAL_UART); +} + +namespace sta +{ + // Create debug serial object using platform specific serial interface + PrintableUART DebugSerial(&platformDebugSerial); +} // namespace sta + + +#endif // STA_DEBUG_SERIAL_ENABLED diff --git a/src/stm32/uart.cpp b/src/stm32/uart.cpp index d530c7c..54d1eea 100644 --- a/src/stm32/uart.cpp +++ b/src/stm32/uart.cpp @@ -22,22 +22,4 @@ namespace sta } // namespace sta -#ifdef STA_STM32_UART_DEBUG_SERIAL - -// Get extern declaration for DebugSerial because const namespace level variables have internal linkage by default -#include - -#include - -namespace sta -{ - STM32UART gStm32DebugSerial(&STA_STM32_UART_DEBUG_SERIAL); - - // Used by - PrintableUART DebugSerial(&gStm32DebugSerial); -} // namespace sta - -#endif // STA_STM32_UART_DEBUG_SERIAL - - #endif // STA_STM32_UART_ENABLED From c63f5e0ffc2d5da540b8be2b3d2c615d2661d527 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 20 Jan 2023 02:25:58 +0100 Subject: [PATCH 13/28] Improve macro description --- include/sta/debug_serial.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 470bfed..8dd9904 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -30,7 +30,8 @@ * @def STA_DEBUG_SERIAL_FORCE * @brief Force enable module. * - * Enables debug output even if NDEBUG is defined. + * Enables debug output even if NDEBUG is defined + * or DEBUG is not defined. * * @ingroup staCoreBuildConfig */ From 326f56153800491cdd381c54bce02e5ce8afe641 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Fri, 20 Jan 2023 02:46:11 +0100 Subject: [PATCH 14/28] Enable STM32 platform in MCU config header --- include/sta/stm32/mcu/common.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/sta/stm32/mcu/common.hpp b/include/sta/stm32/mcu/common.hpp index f10bd2a..4ec69e8 100644 --- a/include/sta/stm32/mcu/common.hpp +++ b/include/sta/stm32/mcu/common.hpp @@ -9,4 +9,8 @@ #define STA_MCU_LITTLE_ENDIAN +// Enable STM32 platform +#define STA_PLATFORM_STM32 + + #endif // STA_CORE_STM32_MCU_COMMON_HPP From 3edfca7e79f80ae3d07514ab2b424438cf0e6e96 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Tue, 31 Jan 2023 19:45:56 +0100 Subject: [PATCH 15/28] Update to doxygen 1.9.6. Disable latex output --- docs/Doxyfile.in | 193 +++++++++++++++++++++++++++++------------------ 1 file changed, 120 insertions(+), 73 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 69c826a..b20091f 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.9.4 +# Doxyfile 1.9.6 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -19,7 +19,8 @@ # configuration file: # doxygen -x [configFile] # Use doxygen to compare the used configuration file with the template -# configuration file without replacing the environment variables: +# configuration file without replacing the environment variables or CMake type +# replacement variables: # doxygen -x_noenv [configFile] #--------------------------------------------------------------------------- @@ -41,19 +42,19 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "My Project" +PROJECT_NAME = "TODO: Add project name" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = "TODO: Add project version" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = "TODO: Add brief project description" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -85,7 +86,7 @@ CREATE_SUBDIRS = NO # level increment doubles the number of directories, resulting in 4096 # directories at level 8 which is the default and also the maximum value. The # sub-directories are organized in 2 levels, the first level always has a fixed -# numer of 16 directories. +# number of 16 directories. # Minimum value: 0, maximum value: 8, default value: 8. # This tag requires that the tag CREATE_SUBDIRS is set to YES. @@ -192,15 +193,15 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = App/include \ - Libs/BMP388/include \ - Libs/can_bus/include \ - Libs/cmsis_os2/include \ - Libs/hdlc/include \ - Libs/iso-tp/include \ - Libs/MCP2518FD/include \ - Libs/mpaland-printf \ - Libs/sta-core/include +STRIP_FROM_INC_PATH = \ + include \ + App/include \ + Libs/sta-core/include \ + Libs/mpaland-printf \ + Libs/rtos2/include \ + Libs/MCP2518FD/include \ + Libs/iso-tp/include \ + Libs/BMP388/include # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -349,7 +350,7 @@ OPTIMIZE_OUTPUT_SLICE = NO # # Note see also the list of default file extension mappings. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -575,7 +576,8 @@ HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO @@ -613,7 +615,8 @@ INTERNAL_DOCS = NO # Windows (including Cygwin) and MacOS, users should typically set this option # to NO, whereas on Linux or other Unix flavors it should typically be set to # YES. -# The default value is: system dependent. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. CASE_SENSE_NAMES = NO @@ -865,6 +868,14 @@ WARN_IF_INCOMPLETE_DOC = YES WARN_NO_PARAMDOC = NO +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS # then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but @@ -921,10 +932,21 @@ INPUT = # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: # https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING # The default value is: UTF-8. INPUT_ENCODING = UTF-8 +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. @@ -943,16 +965,14 @@ INPUT_ENCODING = UTF-8 # comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, # *.vhdl, *.ucf, *.qsf and *.ice. -FILE_PATTERNS = *.c \ - *.cpp \ - *.tpp \ - *.h \ - *.hpp \ - *.markdown \ - *.md \ - *.dox \ - *.py \ - *.pyw \ +FILE_PATTERNS = \ + *.c \ + *.cpp \ + *.h \ + *.hpp \ + *.tpp \ + *.py \ + *.pyw # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -967,7 +987,12 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = Core Drivers Middlewares Debug Release +EXCLUDE = \ + Core \ + Drivers \ + Middlewares \ + Debug \ + Release # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1037,6 +1062,11 @@ IMAGE_PATH = # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. @@ -1078,6 +1108,15 @@ FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- @@ -1215,10 +1254,11 @@ CLANG_DATABASE_PATH = ALPHABETICAL_INDEX = YES -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = @@ -1297,7 +1337,12 @@ HTML_STYLESHEET = # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = @@ -1312,6 +1357,19 @@ HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a color-wheel, see @@ -1675,17 +1733,6 @@ HTML_FORMULA_FORMAT = png FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANSPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. @@ -1861,7 +1908,7 @@ EXTRA_SEARCH_MAPPINGS = # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of @@ -2389,7 +2436,7 @@ HIDE_UNDOC_RELATIONS = YES # set to NO # The default value is: NO. -HAVE_DOT = YES +HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of @@ -2401,26 +2448,38 @@ HAVE_DOT = YES DOT_NUM_THREADS = 0 -# When you want a differently looking font in the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. +# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of +# subgraphs. When you want a differently looking font in the dot files that +# doxygen generates you can specify fontname, fontcolor and fontsize attributes. +# For details please see Node, +# Edge and Graph Attributes specification You need to make sure dot is able +# to find the font, which can be done by putting it in a standard location or by +# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. Default graphviz fontsize is 14. +# The default value is: fontname=Helvetica,fontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTNAME = Helvetica +DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. +# DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can +# add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. Complete documentation about +# arrows shapes. +# The default value is: labelfontname=Helvetica,labelfontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTSIZE = 10 +DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. +# DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes +# around nodes set 'shape=plain' or 'shape=plaintext' Shapes specification +# The default value is: shape=box,height=0.2,width=0.4. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" + +# You can set the path where dot can find font specified with fontname in +# DOT_COMMON_ATTR and others dot attributes. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTPATH = @@ -2663,18 +2722,6 @@ DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support From a7466d6417c1d1c777a3f17f5d5669386321651b Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Tue, 31 Jan 2023 19:49:09 +0100 Subject: [PATCH 16/28] Default to toggle for dark/light mode --- docs/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index b20091f..56a877c 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1368,7 +1368,7 @@ HTML_EXTRA_FILES = # The default value is: AUTO_LIGHT. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE = AUTO_LIGHT +HTML_COLORSTYLE = TOGGLE # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to From 4204c028a234d138a52f23c1851022e724a0fb13 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Tue, 31 Jan 2023 21:14:02 +0100 Subject: [PATCH 17/28] Cleanup doxygen --- include/sta/assert.hpp | 63 +++++++++------------------ include/sta/atomic/mutex.hpp | 11 +++-- include/sta/atomic/signal.hpp | 11 +++-- include/sta/can/iter.hpp | 4 ++ include/sta/debug_serial.hpp | 39 +++-------------- include/sta/gpio_pin.hpp | 1 + include/sta/mutex.hpp | 1 + include/sta/printf.hpp | 23 ++-------- include/sta/signal.hpp | 1 + include/sta/stm32/can.hpp | 19 +++----- include/sta/stm32/clocks.hpp | 2 +- include/sta/stm32/delay.hpp | 24 ++++------ include/sta/stm32/gpio_pin.hpp | 13 +----- include/sta/stm32/hal.hpp | 4 ++ include/sta/stm32/mcu/STM32F411xE.hpp | 1 + include/sta/stm32/mcu/STM32F413xx.hpp | 1 + include/sta/stm32/mcu/common.hpp | 1 + include/sta/stm32/spi.hpp | 3 +- include/sta/stm32/uart.hpp | 2 +- include/sta/time.hpp | 1 + src/assert.cpp | 4 +- src/atomic/mutex.cpp | 4 +- src/atomic/signal.cpp | 4 +- src/stm32/init.cpp | 6 +++ 24 files changed, 89 insertions(+), 154 deletions(-) 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 From fc4eed38d554fd5815570e6bc7e3e2cbf6078159 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 2 Feb 2023 22:13:40 +0100 Subject: [PATCH 18/28] Sort doxygen group names --- docs/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 56a877c..50b2997 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -697,7 +697,7 @@ SORT_MEMBERS_CTORS_1ST = NO # appear in their defined order. # The default value is: NO. -SORT_GROUP_NAMES = NO +SORT_GROUP_NAMES = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will From 59585b2ae50b94c6cbc07093783701e3233fd267 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 2 Feb 2023 22:22:14 +0100 Subject: [PATCH 19/28] Fix indentation. Update doxygen comments --- include/sta/arduino/.gitkeep | 0 include/sta/arduino/not_implemented.hpp | 12 + include/sta/assert.hpp | 63 ++--- include/sta/atomic/mutex.hpp | 26 +- include/sta/atomic/signal.hpp | 30 +- include/sta/can/controller.hpp | 165 ++++++----- include/sta/can/filter.hpp | 56 ++-- include/sta/can/headers.hpp | 54 ++-- include/sta/can/id.hpp | 152 +++++----- include/sta/can/iter.hpp | 91 +++--- include/sta/can/subscribable.hpp | 136 +++++---- include/sta/can/subscribable.tpp | 158 +++++------ include/sta/debug_serial.hpp | 29 +- include/sta/endian.hpp | 92 +++--- include/sta/enum_flags.hpp | 270 +++++++++--------- include/sta/enum_flags.tpp | 156 +++++------ include/sta/fifo_buffer.hpp | 186 ++++++------ include/sta/fifo_buffer.tpp | 134 ++++----- include/sta/gpio_pin.hpp | 53 ++-- include/sta/lang.hpp | 5 +- include/sta/mutex.hpp | 34 +-- include/sta/printable_uart.hpp | 358 ++++++++++++------------ include/sta/signal.hpp | 56 ++-- include/sta/stm32/can.hpp | 128 ++++----- include/sta/stm32/clocks.hpp | 37 +-- include/sta/stm32/delay.hpp | 46 +-- include/sta/stm32/gpio_pin.hpp | 132 +++++---- include/sta/stm32/hal.hpp | 7 + include/sta/stm32/init.hpp | 12 +- include/sta/stm32/uart.hpp | 45 +-- include/sta/time.hpp | 24 +- include/sta/uart.hpp | 73 ++--- src/assert.cpp | 32 +-- src/atomic/mutex.cpp | 22 +- src/atomic/signal.cpp | 38 +-- src/can/id.cpp | 32 +-- src/can/iter.cpp | 132 ++++----- src/debug_serial.cpp | 8 +- src/mutex.cpp | 22 +- src/printable_uart.cpp | 324 ++++++++++----------- src/stm32/can.cpp | 294 +++++++++---------- src/stm32/delay.cpp | 76 ++--- src/stm32/gpio_pin.cpp | 114 ++++---- src/stm32/init.cpp | 16 +- src/stm32/uart.cpp | 20 +- src/uart.cpp | 30 +- 46 files changed, 2020 insertions(+), 1960 deletions(-) delete mode 100644 include/sta/arduino/.gitkeep create mode 100644 include/sta/arduino/not_implemented.hpp diff --git a/include/sta/arduino/.gitkeep b/include/sta/arduino/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/include/sta/arduino/not_implemented.hpp b/include/sta/arduino/not_implemented.hpp new file mode 100644 index 0000000..5c8d8b3 --- /dev/null +++ b/include/sta/arduino/not_implemented.hpp @@ -0,0 +1,12 @@ +#ifndef STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP +#define STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP + + +/** + * @defgroup sta_core_arduino Arduino + * @ingroup sta_core_platforms + * @brief Modules implemented for the Arduino platform. + */ + + +#endif // STA_CORE_ARDUINO_NOT_IMPLEMENTED_HPP \ No newline at end of file diff --git a/include/sta/assert.hpp b/include/sta/assert.hpp index e7a3884..f6e82a9 100644 --- a/include/sta/assert.hpp +++ b/include/sta/assert.hpp @@ -11,20 +11,14 @@ #define STA_CORE_ASSERT_HPP /** - * @defgroup staCore Core + * @defgroup sta_core Core * @brief STA Core library */ /** - * @defgroup staCoreBuildConfig Build Config - * @ingroup staCore - * @brief Build configuration options - */ - -/** - * @defgroup staCoreAssert Assert - * @ingroup staCore - * @brief Assertion handling. + * @defgroup sta_core_platforms Platforms + * @ingroup sta_core + * @brief Platform specific implementations. */ @@ -49,8 +43,21 @@ #include +/** + * @defgroup sta_core_assert Assert + * @ingroup sta_core + * @brief Assertion handling. + */ + + namespace sta { + /** + * @ingroup sta_core_assert + * @{ + */ + + /** * @brief Handle failed assertions. * @@ -62,8 +69,6 @@ namespace sta * @param expr Asserted expression or message * @param file File name * @param line Line number - * - * @ingroup staCoreAssert */ void assert_failed(const char * expr, const char * file, uint32_t line); @@ -71,48 +76,38 @@ namespace sta * @brief Stop execution. * * Weak implementation can be overridden. - * - * @ingroup staCoreAssert */ void assert_halt(); + + + /** @} */ } // namespace sta /** - * @def STA_HALT - * @brief Set function called after failed asserts. - * - * @ingroup staCoreBuildConfig + * @ingroup sta_core_assert + * @{ */ -# ifndef STA_HALT -# define STA_HALT() sta::assert_halt() -# endif // !STA_HALT /** * @brief Assert expression. * * @param expr Expression - * - * @ingroup staCoreAssert */ -# define STA_ASSERT(expr) ( (void)( !(expr) && ( sta::assert_failed(#expr, __FILE__, __LINE__), 1 ) && ( STA_HALT(), 1 ) ) ) +# define STA_ASSERT(expr) ( (void)( !(expr) && ( sta::assert_failed(#expr, __FILE__, __LINE__), 1 ) && ( sta::assert_halt(), 1 ) ) ) /** * @brief Assert expression. * * @param expr Expression * @param msg Message shown on failure - * - * @ingroup staCoreAssert */ -# define STA_ASSERT_MSG(expr, msg) ( (void)( !(expr) && ( sta::assert_failed(msg, __FILE__, __LINE__), 1 ) && ( STA_HALT(), 1 ) ) ) +# define STA_ASSERT_MSG(expr, msg) ( (void)( !(expr) && ( sta::assert_failed(msg, __FILE__, __LINE__), 1 ) && ( sta::assert_halt(), 1 ) ) ) /** * @brief Assert expression if condition is true. * * @param cond Condition * @param expr Expression - * - * @ingroup staCoreAssert */ # define STA_ASSERT_COND(cond, expr) ( (void)( (cond) ? STA_ASSERT(expr) : 1 ) ) /** @@ -121,13 +116,17 @@ namespace sta * @param cond Condition * @param expr Expression * @param msg Message shown on failure - * - * @ingroup staCoreAssert */ # define STA_ASSERT_COND_MSG(cond, expr, msg) ( (void)( (cond) ? STA_ASSERT_MSG(expr, msg) ) ) +/** + * @brief Expression only evaluated when assertions are enabled. + * + * @param expr Expression + */ +# define STA_ASSERT_EXTRA(expr) expr -# define STA_ASSERT_EXTRA(expr) expr; +/** @} */ #else // !STA_ASSERT_ENABLED diff --git a/include/sta/atomic/mutex.hpp b/include/sta/atomic/mutex.hpp index ad1d7b7..a5fea79 100644 --- a/include/sta/atomic/mutex.hpp +++ b/include/sta/atomic/mutex.hpp @@ -8,11 +8,13 @@ #ifndef STA_CORE_ATOMIC_MUTEX_HPP #define STA_CORE_ATOMIC_MUTEX_HPP + #include #ifdef STA_STDLIB_HAS_ATOMIC # define STA_ATOMIC_ENABLED #endif // STA_STDLIB_HAS_ATOMIC + #if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN) #include @@ -22,20 +24,20 @@ namespace sta { - /** - * @brief Implementation of `Mutex` interface using `std::atomic_flag`. - */ - class AtomicMutex : public Mutex - { - public: - AtomicMutex(); + /** + * @brief Implementation of `Mutex` interface using `std::atomic_flag`. + */ + class AtomicMutex : public Mutex + { + public: + AtomicMutex(); - void acquire() override; - void release() override; + void acquire() override; + void release() override; - private: - std::atomic_flag lock_; /**< Atomic flag used as lock */ - }; + private: + std::atomic_flag lock_; /**< Atomic flag used as lock */ + }; } // namespace sta diff --git a/include/sta/atomic/signal.hpp b/include/sta/atomic/signal.hpp index 73c9645..1c65f2a 100644 --- a/include/sta/atomic/signal.hpp +++ b/include/sta/atomic/signal.hpp @@ -8,11 +8,13 @@ #ifndef STA_CORE_ATOMIC_SIGNAL_HPP #define STA_CORE_ATOMIC_SIGNAL_HPP + #include #ifdef STA_STDLIB_HAS_ATOMIC # define STA_ATOMIC_ENABLED #endif // STA_STDLIB_HAS_ATOMIC + #if defined(STA_ATOMIC_ENABLED) || defined(DOXYGEN) #include @@ -22,22 +24,22 @@ namespace sta { - /** - * @brief Implementation of `Signal` interface using `std::atomic`. - */ - class AtomicSignal : public Signal - { - public: - AtomicSignal(); + /** + * @brief Implementation of `Signal` interface using `std::atomic`. + */ + class AtomicSignal : public Signal + { + public: + AtomicSignal(); - void notify() override; - bool peek() override; - bool test() override; - void wait() override; + void notify() override; + bool peek() override; + bool test() override; + void wait() override; - private: - std::atomic signal_; /**< Atomic bool used as signal */ - }; + private: + std::atomic signal_; /**< Atomic bool used as signal */ + }; } // namespace sta diff --git a/include/sta/can/controller.hpp b/include/sta/can/controller.hpp index 305eeff..fbadb59 100644 --- a/include/sta/can/controller.hpp +++ b/include/sta/can/controller.hpp @@ -6,16 +6,11 @@ #define STA_CORE_CAN_CONTROLLER_HPP /** - * @defgroup can CAN + * @defgroup sta_core_can CAN + * @ingroup sta_core * @brief CAN controller driver interface. */ -/** - * @defgroup canAPI API - * @ingroup can - * @brief Public interface. - */ - #include #include @@ -24,96 +19,96 @@ namespace sta { - /** - * @brief CAN controller driver interface. - * - * @ingroup canAPI - */ - class CanController - { - public: - // RX/TX - // + /** + * @brief CAN controller driver interface. + * + * @ingroup sta_core_can + */ + class CanController + { + public: + // RX/TX + // - /** - * @brief Send frame to CAN controller for transmission. - * - * @param header CAN frame TX header - * @param payload CAN frame payload - * @return True on success - */ - virtual bool sendFrame(const CanTxHeader & header, const uint8_t * payload) = 0; + /** + * @brief Send frame to CAN controller for transmission. + * + * @param header CAN frame TX header + * @param payload CAN frame payload + * @return True on success + */ + virtual bool sendFrame(const CanTxHeader & header, const uint8_t * payload) = 0; - /** - * @brief Get received frame from the CAN controller. - * - * @param[in] fifo FIFO storing frame - * @param[out] header CAN frame RX header destination - * @param[out] payload CAN frame payload destination - * @return True on success - */ - virtual bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) = 0; + /** + * @brief Get received frame from the CAN controller. + * + * @param[in] fifo FIFO storing frame + * @param[out] header CAN frame RX header destination + * @param[out] payload CAN frame payload destination + * @return True on success + */ + virtual bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) = 0; - /** - * @brief Get RX FIFO flags. - * - * @return FIFO flags - */ - virtual uint32_t getRxFifoFlags() = 0; + /** + * @brief Get RX FIFO flags. + * + * @return FIFO flags + */ + virtual uint32_t getRxFifoFlags() = 0; - /** - * @brief Get list of RX FIFO indices with pending messages. - */ - virtual CanPendingRxFifos getPendingRxFifos() = 0; + /** + * @brief Get list of RX FIFO indices with pending messages. + */ + virtual CanPendingRxFifos getPendingRxFifos() = 0; - // RX filter - // + // RX filter + // - /** - * @brief Change filter settings. - * - * @param idx Filter index - * @param filter Filter configuration - * @param active Enable filter after applying settings - */ - virtual void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) = 0; - /** - * @brief Enable filter. - * - * @param idx Filter index - */ - virtual void enableFilter(uint8_t idx) = 0; - /** - * @brief Disable filter. - * - * @param idx Filter index - */ - virtual void disableFilter(uint8_t idx) = 0; - /** - * @brief Disable and clear all filters. - */ - virtual void clearFilters() = 0; + /** + * @brief Change filter settings. + * + * @param idx Filter index + * @param filter Filter configuration + * @param active Enable filter after applying settings + */ + virtual void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) = 0; + /** + * @brief Enable filter. + * + * @param idx Filter index + */ + virtual void enableFilter(uint8_t idx) = 0; + /** + * @brief Disable filter. + * + * @param idx Filter index + */ + virtual void disableFilter(uint8_t idx) = 0; + /** + * @brief Disable and clear all filters. + */ + virtual void clearFilters() = 0; - // Info - // + // Info + // - /** - * @brief Get number of available filters. - */ - virtual uint8_t maxFilterCount() const = 0; + /** + * @brief Get number of available filters. + */ + virtual uint8_t maxFilterCount() const = 0; - /** - * @brief Get number of available FIFOs. - */ - virtual uint8_t maxFifoCount() const = 0; + /** + * @brief Get number of available FIFOs. + */ + virtual uint8_t maxFifoCount() const = 0; - /** - * @brief Get maximum supported payload size. - */ - virtual uint8_t maxPayloadSize() const = 0; - }; + /** + * @brief Get maximum supported payload size. + */ + virtual uint8_t maxPayloadSize() const = 0; + }; } // namespace sta diff --git a/include/sta/can/filter.hpp b/include/sta/can/filter.hpp index f8a98a8..0071139 100644 --- a/include/sta/can/filter.hpp +++ b/include/sta/can/filter.hpp @@ -12,37 +12,37 @@ namespace sta { - /** - * @defgroup canFilter Filters - * @ingroup canAPI - * @brief CAN message filter types. - */ + /** + * @defgroup sta_core_can_filters Filters + * @ingroup sta_core_can + * @brief CAN message filter types. + * @{ + */ - /** - * @brief ID format matched by CAN filter. - * - * @ingroup canFilter - */ - enum class CanFilterIdFormat - { - ANY, /**< Match both ID formats */ - STD, /**< Match standard format IDs */ - EXT /**< Match extended format IDs */ - }; + /** + * @brief ID format matched by CAN filter. + */ + enum class CanFilterIdFormat + { + ANY, /**< Match both ID formats */ + STD, /**< Match standard format IDs */ + EXT /**< Match extended format IDs */ + }; - /** - * @brief CAN filter settings. - * - * @ingroup canFilter - */ - struct CanFilter - { - CanId obj; /**< ID object */ - CanId mask; /**< ID mask */ - CanFilterIdFormat type; /**< ID format to match */ - uint8_t fifo; /**< FIFO to store matches */ - }; + /** + * @brief CAN filter settings. + */ + struct CanFilter + { + CanId obj; /**< ID object */ + CanId mask; /**< ID mask */ + CanFilterIdFormat type; /**< ID format to match */ + uint8_t fifo; /**< FIFO to store matches */ + }; + + + /** @} */ } // namespace sta diff --git a/include/sta/can/headers.hpp b/include/sta/can/headers.hpp index 99f0d81..24536c5 100644 --- a/include/sta/can/headers.hpp +++ b/include/sta/can/headers.hpp @@ -12,36 +12,36 @@ namespace sta { - /** - * @defgroup canHeader Frame headers - * @ingroup canAPI - * @brief CAN header types for transmitted / received frames. - */ + /** + * @defgroup sta_core_can_headers Frame headers + * @ingroup sta_core_can + * @brief CAN header types for transmitted / received frames. + * @{ + */ - /** - * @brief CAN TX frame header. - * - * @ingroup canHeader - */ - struct CanTxHeader - { - CanFrameId id; /**< Frame ID */ - uint8_t payloadLength; /**< Size of data to send */ - }; + /** + * @brief CAN TX frame header. + */ + struct CanTxHeader + { + CanFrameId id; /**< Frame ID */ + uint8_t payloadLength; /**< Size of data to send */ + }; - /** - * @brief CAN RX frame header. - * - * @ingroup canHeader - */ - struct CanRxHeader - { - CanFrameId id; /**< Frame ID */ - uint8_t payloadLength; /**< Size of received data */ - uint32_t timestamp; /**< RX timestamp */ - uint8_t filter; /**< RX filter match */ - }; + /** + * @brief CAN RX frame header. + */ + struct CanRxHeader + { + CanFrameId id; /**< Frame ID */ + uint8_t payloadLength; /**< Size of received data */ + uint32_t timestamp; /**< RX timestamp */ + uint8_t filter; /**< RX filter match */ + }; + + + /** @} */ } // namespace sta diff --git a/include/sta/can/id.hpp b/include/sta/can/id.hpp index 0cd9f57..a832998 100644 --- a/include/sta/can/id.hpp +++ b/include/sta/can/id.hpp @@ -10,107 +10,99 @@ namespace sta { - /** - * @defgroup canID Frame IDs - * @ingroup canAPI - * @brief Types for working with CAN ID values and formats. - */ + /** + * @defgroup sta_core_can_ids Frame IDs + * @ingroup sta_core_can + * @brief Types for working with CAN ID values and formats. + */ - /** - * @brief CAN frame ID format. - * - * @ingroup canID - */ - enum class CanIdFormat : uint8_t - { - STD, /**< Standard format */ - EXT /**< Extended format */ - }; + /** + * @brief CAN frame ID format. + * + * @ingroup sta_core_can_ids + */ + enum class CanIdFormat : uint8_t + { + STD, /**< Standard format */ + EXT /**< Extended format */ + }; - /** - * @brief CAN frame ID. - * - * @ingroup canID - */ - struct CanId - { - uint32_t sid; /**< Standard ID field (11 bits) */ - uint32_t eid; /**< Extended ID field (18 bits) */ - }; + /** + * @brief CAN frame ID. + * + * @ingroup sta_core_can_ids + */ + struct CanId + { + uint32_t sid; /**< Standard ID field (11 bits) */ + uint32_t eid; /**< Extended ID field (18 bits) */ + }; - /** - * @brief CAN frame ID and format. - * - * @ingroup canID - */ - struct CanFrameId - { - CanIdFormat format; /**< ID format */ - uint32_t sid; /**< Standard ID field (11 bits) */ - uint32_t eid; /**< Extended ID field (18 bits) */ - }; + /** + * @brief CAN frame ID and format. + * + * @ingroup sta_core_can_ids + */ + struct CanFrameId + { + CanIdFormat format; /**< ID format */ + uint32_t sid; /**< Standard ID field (11 bits) */ + uint32_t eid; /**< Extended ID field (18 bits) */ + }; - // Comparison operators - // + // Comparison operators + // - /** - * @brief Equal to operator. - * - * @param lhs Left hand side CAN ID - * @param rhs Right hand side CAN ID - * @return True if CAN IDs are equal - * - * @ingroup canID - */ - bool operator ==(const CanId & lhs, const CanId & rhs); - /** - * @brief Not equal to operator. - * - * @param lhs Left hand side CAN ID - * @param rhs Right hand side CAN ID - * @return True if CAN IDs are not equal - * - * @ingroup canID - */ - bool operator !=(const CanId & lhs, const CanId & rhs); + /** + * @brief Equal to operator. + * + * @param lhs Left hand side CAN ID + * @param rhs Right hand side CAN ID + * @return True if CAN IDs are equal + */ + bool operator ==(const CanId & lhs, const CanId & rhs); + /** + * @brief Not equal to operator. + * + * @param lhs Left hand side CAN ID + * @param rhs Right hand side CAN ID + * @return True if CAN IDs are not equal + */ + bool operator !=(const CanId & lhs, const CanId & rhs); - /** - * @brief Equal to operator. - * - * @param lhs Left hand side CAN Frame ID - * @param rhs Right hand side CAN Frame ID - * @return True if CAN Frame IDs are equal - * - * @ingroup canID - */ - bool operator ==(const CanFrameId & lhs, const CanFrameId & rhs); - /** - * @brief Not equal to operator. - * - * @param lhs Left hand side CAN Frame ID - * @param rhs Right hand side CAN Frame ID - * @return True if CAN Frame IDs are not equal - * - * @ingroup canID - */ - bool operator !=(const CanFrameId & lhs, const CanFrameId & rhs); + /** + * @brief Equal to operator. + * + * @param lhs Left hand side CAN Frame ID + * @param rhs Right hand side CAN Frame ID + * @return True if CAN Frame IDs are equal + */ + bool operator ==(const CanFrameId & lhs, const CanFrameId & rhs); + /** + * @brief Not equal to operator. + * + * @param lhs Left hand side CAN Frame ID + * @param rhs Right hand side CAN Frame ID + * @return True if CAN Frame IDs are not equal + */ + bool operator !=(const CanFrameId & lhs, const CanFrameId & rhs); } // namespace sta /** * @brief Maximum CAN standard ID value. * - * @ingroup canID + * @ingroup sta_core_can_ids */ #define CAN_SID_MAX UINT32_C(0x7FF) /** * @brief Maximum CAN extended ID value. * - * @ingroup canID + * @ingroup sta_core_can_ids */ #define CAN_EID_MAX UINT32_C(0x3FFFF) diff --git a/include/sta/can/iter.hpp b/include/sta/can/iter.hpp index 32a924a..95fd187 100644 --- a/include/sta/can/iter.hpp +++ b/include/sta/can/iter.hpp @@ -10,57 +10,72 @@ namespace sta { - class CanPendingRxFifos - { - public: - using value_type = uint8_t; - using reference = value_type &; - using const_reference = const value_type &; - using size_type = uint8_t; + /** + * @brief Iterable container interface for CAN RX flags. + * + * @ingroup sta_core_can_ids + */ + class CanPendingRxFifos + { + public: + using value_type = uint8_t; + using reference = value_type &; + using const_reference = const value_type &; + using size_type = uint8_t; - class const_iterator - { - public: - using value_type = CanPendingRxFifos::value_type; - using reference = const_reference; - using pointer = const value_type *; + /** + * @brief Custom iterator for active RX queues. + */ + class const_iterator + { + public: + using value_type = CanPendingRxFifos::value_type; + using reference = const_reference; + using pointer = const value_type *; - public: - const_iterator(const const_iterator & iter); + public: + const_iterator(const const_iterator & iter); - const_iterator & operator=(const const_iterator & iter); + const_iterator & operator=(const const_iterator & iter); - bool operator==(const const_iterator & iter) const; - bool operator!=(const const_iterator & iter) const; + bool operator==(const const_iterator & iter) const; + bool operator!=(const const_iterator & iter) const; - const_iterator & operator++(); - const_iterator operator++(int); + const_iterator & operator++(); + const_iterator operator++(int); - reference operator*() const; + reference operator*() const; - private: - const_iterator(uint32_t rxFlags, uint8_t idx, uint8_t endIdx); + private: + const_iterator(uint32_t rxFlags, uint8_t idx, uint8_t endIdx); - bool isRxPending() const; + /** + * @brief Check if current RX queue has pending data. + */ + bool isRxPending() const; - friend class CanPendingRxFifos; + friend class CanPendingRxFifos; - private: - uint32_t rxFlags_; - uint8_t idx_; - uint8_t endIdx_; - }; + private: + uint32_t rxFlags_; /**< RX flag bits */ + uint8_t idx_; /**< Current flag index */ + uint8_t endIdx_; /**< Iterator end index */ + }; - public: - CanPendingRxFifos(uint32_t rxFlags, uint8_t numFifos); + public: + /** + * @param rxFlags RX flag bits + * @param numFifos Number of RX FIFOs + */ + CanPendingRxFifos(uint32_t rxFlags, uint8_t numFifos); - const_iterator begin() const; - const_iterator end() const; + const_iterator begin() const; + const_iterator end() const; - private: - uint32_t rxFlags_; - uint8_t numFifos_; - }; + private: + uint32_t rxFlags_; /**< RX flag bits */ + uint8_t numFifos_; /**< Number of RX FIFOs */ + }; } // namespace sta diff --git a/include/sta/can/subscribable.hpp b/include/sta/can/subscribable.hpp index 0251cc6..1d84080 100644 --- a/include/sta/can/subscribable.hpp +++ b/include/sta/can/subscribable.hpp @@ -11,90 +11,88 @@ namespace sta { - /** - * @defgroup canSub Subscription - * @ingroup canAPI - * @brief Subscription interface for CAN controller drivers. - */ + /** + * @defgroup sta_core_can_sub Subscription + * @ingroup sta_core_can + * @brief Subscription interface for CAN controller drivers. + * @{ + */ - /** - * @brief Callback for handling received frames. - * - * @param header Frame header - * @param buffer Frame payload buffer - * - * @ingroup canSub - */ - using CanRxCallback = void (*) (const CanRxHeader & header, const uint8_t * buffer); + /** + * @brief Callback for handling received frames. + * + * @param header Frame header + * @param buffer Frame payload buffer + */ + using CanRxCallback = void (*) (const CanRxHeader & header, const uint8_t * buffer); - /** - * @brief Filter configuration and message handler. - * - * @ingroup canSub - */ - struct CanFilterConfig - { - CanFilter filter; /**< Filter handled by callback */ - CanRxCallback callback; /**< Callback for message handling */ - }; + /** + * @brief Filter configuration and message handler. + */ + struct CanFilterConfig + { + CanFilter filter; /**< Filter handled by callback */ + CanRxCallback callback; /**< Callback for message handling */ + }; - /** - * @brief CAN controller with subscriptions. - * - * @tparam T Implementation of CanController interface - * - * @ingroup canSub - */ - template - class SubscribableCanController : public T - { - public: - using T::T; + /** + * @brief CAN controller with subscriptions. + * + * @tparam T Implementation of CanController interface + */ + template + class SubscribableCanController : public T + { + public: + using T::T; - // Subscriptions - // + // Subscriptions + // - /** - * @brief Subscribe to specific message types. - * - * @param subscriptions Array of message filters and handlers - * @param num Number of array entries - */ - bool subscribe(const CanFilterConfig * subscriptions, uint8_t num); + /** + * @brief Subscribe to specific message types. + * + * @param subscriptions Array of message filters and handlers + * @param num Number of array entries + */ + bool subscribe(const CanFilterConfig * subscriptions, uint8_t num); - /** - * @brief Subscribe to all messages. - * - * @param callback Called when message is received - * @param fifo FIFO used for received messages - */ - void subscribeAll(CanRxCallback callback, uint8_t fifo); + /** + * @brief Subscribe to all messages. + * + * @param callback Called when message is received + * @param fifo FIFO used for received messages + */ + void subscribeAll(CanRxCallback callback, uint8_t fifo); - /** - * @brief Unsubscribe from all messages. - * - * No more messages will be received. - */ - void unsubscribeAll(); + /** + * @brief Unsubscribe from all messages. + * + * No more messages will be received. + */ + void unsubscribeAll(); - /** - * @brief Read message from RX FIFO and notify subscriber. - */ - void receiveAndNotify(uint8_t fifo); + /** + * @brief Read message from RX FIFO and notify subscriber. + */ + void receiveAndNotify(uint8_t fifo); - /** - * @brief Process pending frames from RX FIFOs. - */ - void processMessages(); + /** + * @brief Process pending frames from RX FIFOs. + */ + void processMessages(); - private: - CanRxCallback filterCallbacks_[T::MAX_FILTER_COUNT]; /**< Callbacks for RX filters */ - }; + private: + CanRxCallback filterCallbacks_[T::MAX_FILTER_COUNT]; /**< Callbacks for RX filters */ + }; + + + /** @} */ } // namespace sta diff --git a/include/sta/can/subscribable.tpp b/include/sta/can/subscribable.tpp index d05fc9c..be103e3 100644 --- a/include/sta/can/subscribable.tpp +++ b/include/sta/can/subscribable.tpp @@ -15,105 +15,105 @@ namespace sta { - template - bool SubscribableCanController::subscribe(const CanFilterConfig * subscriptions, uint8_t num) - { - // Check bounds - if (num > T::MAX_FILTER_COUNT) - return false; + template + bool SubscribableCanController::subscribe(const CanFilterConfig * subscriptions, uint8_t num) + { + // Check bounds + if (num > T::MAX_FILTER_COUNT) + return false; - // Clear previous subscriptions - unsubscribeAll(); + // Clear previous subscriptions + unsubscribeAll(); - for (uint8_t i = 0; i < num; ++i) - { - // Save handler callback - filterCallbacks_[i] = subscriptions[i].callback; + for (uint8_t i = 0; i < num; ++i) + { + // Save handler callback + filterCallbacks_[i] = subscriptions[i].callback; - // Configure and enable filter - T::configureFilter(i, subscriptions[i].filter, true); - } + // Configure and enable filter + T::configureFilter(i, subscriptions[i].filter, true); + } - return true; - } + return true; + } - template - void SubscribableCanController::subscribeAll(CanRxCallback callback, uint8_t fifo) - { - uint8_t filterIdx = 0; + template + void SubscribableCanController::subscribeAll(CanRxCallback callback, uint8_t fifo) + { + uint8_t filterIdx = 0; - // Clear previous subscriptions - unsubscribeAll(); + // Clear previous subscriptions + unsubscribeAll(); - // Setup default filter - CanFilter filter{}; - filter.type = CanFilterIdFormat::ANY; - filter.fifo = fifo; + // Setup default filter + CanFilter filter{}; + filter.type = CanFilterIdFormat::ANY; + filter.fifo = fifo; - // Store callback - filterCallbacks_[filterIdx] = callback; + // Store callback + filterCallbacks_[filterIdx] = callback; - // Configure and enable default filter - T::configureFilter(filterIdx, filter, true); - } + // Configure and enable default filter + T::configureFilter(filterIdx, filter, true); + } - template - void SubscribableCanController::unsubscribeAll() - { - // Disable all filters - T::clearFilters(); + template + void SubscribableCanController::unsubscribeAll() + { + // Disable all filters + T::clearFilters(); - // Clear filter callbacks + // Clear filter callbacks #ifndef STA_STDLIB_DISABLE - std::fill_n(filterCallbacks_, T::MAX_FILTER_COUNT, nullptr); + std::fill_n(filterCallbacks_, T::MAX_FILTER_COUNT, nullptr); #else // STA_STDLIB_DISABLE - for (uint8_t i = 0; i < T::MAX_FILTER_COUNT; ++i) - { - filterCallbacks_[i] = nullptr; - } + for (uint8_t i = 0; i < T::MAX_FILTER_COUNT; ++i) + { + filterCallbacks_[i] = nullptr; + } #endif // STA_STDLIB_DISABLE - } + } - template - void SubscribableCanController::receiveAndNotify(uint8_t fifo) - { - CanRxHeader header; - uint8_t payload[T::MAX_PAYLOAD_SIZE]; + template + void SubscribableCanController::receiveAndNotify(uint8_t fifo) + { + CanRxHeader header; + uint8_t payload[T::MAX_PAYLOAD_SIZE]; - if (T::receiveFrame(fifo, &header, payload)) - { - //displayFrameUART(frame); + if (T::receiveFrame(fifo, &header, payload)) + { + //displayFrameUART(frame); - // Forward frame to filter callback - if (fifo <= T::MAX_FILTER_COUNT && filterCallbacks_[header.filter]) - { - filterCallbacks_[header.filter](header, payload); - } - } - } + // Forward frame to filter callback + if (fifo <= T::MAX_FILTER_COUNT && filterCallbacks_[header.filter]) + { + filterCallbacks_[header.filter](header, payload); + } + } + } - template - void SubscribableCanController::processMessages() - { - // Read RX interrupt flags - uint32_t RFIF = T::getRxFifoFlags(); + template + void SubscribableCanController::processMessages() + { + // Read RX interrupt flags + uint32_t RFIF = T::getRxFifoFlags(); - if (RFIF != 0) - { - // Check all flags - for (uint8_t fifo = 0; fifo < T::MAX_FIFO_COUNT; ++fifo) - { - // Process messages if flag is set - if (RFIF & 0x1) - { - receiveAndNotify(fifo); - } + if (RFIF != 0) + { + // Check all flags + for (uint8_t fifo = 0; fifo < T::MAX_FIFO_COUNT; ++fifo) + { + // Process messages if flag is set + if (RFIF & 0x1) + { + receiveAndNotify(fifo); + } - // Shift next RX flag to LSB - RFIF >>= 1; - } - } - } + // Shift next RX flag to LSB + RFIF >>= 1; + } + } + } } // namespace sta diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 325130a..ee3bd11 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -11,11 +11,6 @@ #ifndef STA_CORE_DEBUG_SERIAL_HPP #define STA_CORE_DEBUG_SERIAL_HPP -/** - * @defgroup staCoreDebug Debug Serial - * @ingroup staCore - * @brief Debug serial output. - */ #include @@ -35,19 +30,27 @@ # endif // !STA_DEBUG_SERIAL_FORCE #endif // STA_DEBUG_SERIAL_UART + #if defined(STA_DEBUG_SERIAL_ENABLED) || defined(DOXYGEN) #include +/** + * @defgroup sta_core_debug Debug Serial + * @ingroup sta_core + * @brief Debug serial output. + */ + + namespace sta { - /** - * @brief %UART print object for debug serial output. - * - * @ingroup staCoreDebug - */ - extern PrintableUART DebugSerial; + /** + * @brief %UART print object for debug serial output. + * + * @ingroup sta_core_debug + */ + extern PrintableUART DebugSerial; } // namespace sta @@ -56,7 +59,7 @@ namespace sta * * @param ... See @ref sta::PrintableUART::print * - * @ingroup staCoreDebug + * @ingroup sta_core_debug */ # define STA_DEBUG_PRINT(...) sta::DebugSerial.print(__VA_ARGS__) /** @@ -64,7 +67,7 @@ namespace sta * * @param ... See @ref sta::PrintableUART::println * - * @ingroup staCoreDebug + * @ingroup sta_core_debug */ # define STA_DEBUG_PRINTLN(...) sta::DebugSerial.println(__VA_ARGS__) #else // !STA_DEBUG_SERIAL_ENABLED diff --git a/include/sta/endian.hpp b/include/sta/endian.hpp index 7abf201..03ab300 100644 --- a/include/sta/endian.hpp +++ b/include/sta/endian.hpp @@ -5,11 +5,6 @@ #ifndef STA_CORE_ENDIAN_HPP #define STA_CORE_ENDIAN_HPP -/** - * @defgroup staCoreEndian Endian - * @ingroup staCore - * @brief Endian handling. - */ #include @@ -18,99 +13,95 @@ #endif // !STA_MCU_BIG_ENDIAN && !STA_MCU_LITTLE_ENDIAN +/** + * @defgroup sta_core_endian Endian + * @ingroup sta_core + * @brief Endian handling. + * @{ + */ + + /** * @brief Get 16-bit value with swapped byte order. * * @param u16 16-bit input value * @return 16-bit value w/ swapped byte order - * - * @ingroup staCoreEndian */ #define STA_UINT16_SWAP_BYTE_ORDER(u16) \ - ( \ - ((u16 & 0x00FF) << 8) \ - | ((u16 & 0xFF00) >> 8) \ - ) + ( \ + ((u16 & 0x00FF) << 8) \ + | ((u16 & 0xFF00) >> 8) \ + ) /** * @brief Get 32-bit value with swapped byte order. * * @param u32 32-bit input value * @return 32-bit value w/ swapped byte order - * - * @ingroup staCoreEndian */ #define STA_UINT32_SWAP_BYTE_ORDER(u32) \ - ( \ - ((u32 & 0x000000FF) << 24) \ - | ((u32 & 0x0000FF00) << 8) \ - | ((u32 & 0x00FF0000) >> 8) \ - | ((u32 & 0xFF000000) >> 24) \ - ) + ( \ + ((u32 & 0x000000FF) << 24) \ + | ((u32 & 0x0000FF00) << 8) \ + | ((u32 & 0x00FF0000) >> 8) \ + | ((u32 & 0xFF000000) >> 24) \ + ) /** * @brief Get initializer list for byte array with big-endian byte order from 16-bit value. * * @param u16 16-bit input value * @return Initializer list for uint8_t[2] - * - * @ingroup staCoreEndian */ #define STA_UINT16_TO_BYTES_BE(u16) \ - { \ - static_cast(u16 >> 8), \ - static_cast(u16) \ - } + { \ + static_cast(u16 >> 8), \ + static_cast(u16) \ + } /** * @brief Get initializer list for byte array with little-endian byte order from 16-bit value. * * @param u16 16-bit input value * @return Initializer list for uint8_t[2] - * - * @ingroup staCoreEndian */ #define STA_UINT16_TO_BYTES_LE(u16) \ - { \ - static_cast(u16), \ - static_cast(u16 >> 8) \ - } + { \ + static_cast(u16), \ + static_cast(u16 >> 8) \ + } /** * @brief Get initializer list for byte array with big-endian byte order from 32-bit value. * * @param u32 32-bit input value * @return Initializer list for uint8_t[4] - * - * @ingroup staCoreEndian */ #define STA_UINT32_TO_BYTES_BE(u32) \ - { \ - static_cast(u32 >> 24), \ - static_cast(u32 >> 16), \ - static_cast(u32 >> 8), \ - static_cast(u32) \ - } + { \ + static_cast(u32 >> 24), \ + static_cast(u32 >> 16), \ + static_cast(u32 >> 8), \ + static_cast(u32) \ + } /** * @brief Get initializer list for byte array with little-endian byte order from 32-bit value. * * @param u32 32-bit input value * @return Initializer list for uint8_t[4] - * - * @ingroup staCoreEndian */ #define STA_UINT32_TO_BYTES_LE(u32) \ - { \ - static_cast(u32), \ - static_cast(u32 >> 8), \ - static_cast(u32 >> 16), \ - static_cast(u32 >> 24) \ - } + { \ + static_cast(u32), \ + static_cast(u32 >> 8), \ + static_cast(u32 >> 16), \ + static_cast(u32 >> 24) \ + } /** - * @defe STA_UINT16_TO_BE(u16) + * @def STA_UINT16_TO_BE(u16) * @brief Convert 16-bit value to big-endian byte order. * * @param u16 16-bit input value @@ -174,6 +165,9 @@ */ +/** @} */ + + #ifdef STA_MCU_LITTLE_ENDIAN # define STA_UINT16_TO_BE(u16) STA_UINT16_SWAP_BYTE_ORDER(u16) @@ -186,7 +180,7 @@ # define STA_UINT32_TO_BYTES(u32) STA_UINT32_TO_BYTES_LE(u32) # define STA_UINT32_TO_BYTES_SWAP(u32) STA_UINT32_TO_BYTES_BE(u32) -#elif STA_MCU_BIG_ENDIAN +#else // STA_MCU_BIG_ENDIAN # define STA_UINT16_TO_BE(u16) (u16) # define STA_UINT16_TO_LE(u16) STA_UINT16_SWAP_BYTE_ORDER(u16) diff --git a/include/sta/enum_flags.hpp b/include/sta/enum_flags.hpp index f7704e6..61d18ed 100644 --- a/include/sta/enum_flags.hpp +++ b/include/sta/enum_flags.hpp @@ -10,143 +10,143 @@ namespace sta { - /** - * @brief 32-bit flag register with enum type representing single flag bits. - * - * @tparam F Enum type used for flag bits - * - * @ingroup staCore - */ - template - class EnumFlags - { - public: - using flag_type = F; /**< Enum type used for flag bits */ + /** + * @brief 32-bit flag register with enum type representing single flag bits. + * + * @tparam F Enum type used for flag bits + * + * @ingroup sta_core + */ + template + class EnumFlags + { + public: + using flag_type = F; /**< Enum type used for flag bits */ - public: - /** - * @brief Default constructor. - */ - EnumFlags(); - /** - * @brief Copy constructor. - * - * @param other Flags to copy - */ - EnumFlags(const EnumFlags & other); - /** - * @brief Construct from single flag. - * - * @param flag Single flag bit to set - */ - EnumFlags(flag_type flag); + public: + /** + * @brief Default constructor. + */ + EnumFlags(); + /** + * @brief Copy constructor. + * + * @param other Flags to copy + */ + EnumFlags(const EnumFlags & other); + /** + * @brief Construct from single flag. + * + * @param flag Single flag bit to set + */ + EnumFlags(flag_type flag); - // Modification - // + // Modification + // - /** - * @brief Set bits from flags register. - * - * @param flags Flag bits to set - */ - void set(const EnumFlags & flags); - /** - * @brief Clear flag bits. - * - * @param flags Flag bits to clear - */ - void clear(const EnumFlags & flags); - /** - * @brief Clear all flag bits. - */ - void clear(); + /** + * @brief Set bits from flags register. + * + * @param flags Flag bits to set + */ + void set(const EnumFlags & flags); + /** + * @brief Clear flag bits. + * + * @param flags Flag bits to clear + */ + void clear(const EnumFlags & flags); + /** + * @brief Clear all flag bits. + */ + void clear(); - // Inspection - // + // Inspection + // - /** - * @brief Test if all flags are set. - * - * @param flags Flag bits to check - * @return True if all checked flag bits are set - */ - bool isSet(const EnumFlags & flags) const; + /** + * @brief Test if all flags are set. + * + * @param flags Flag bits to check + * @return True if all checked flag bits are set + */ + bool isSet(const EnumFlags & flags) const; - /** - * @brief Test if any flag is set. - * - * @param flags Flag bits to check - * @return True if any checked flag bit is set - */ - bool isAnySet(const EnumFlags & flags) const; + /** + * @brief Test if any flag is set. + * + * @param flags Flag bits to check + * @return True if any checked flag bit is set + */ + bool isAnySet(const EnumFlags & flags) const; - // Operator overloads - // + // Operator overloads + // - /** - * @brief Equal to operator. - * - * @param rhs Flags to compare - * @return True if flags are equal - */ - bool operator ==(const EnumFlags & rhs) const; - /** - * @brief Not equal to operator. - * - * @param rhs Flags to compare - * @return True if flags are not equal - */ - bool operator !=(const EnumFlags & rhs) const; + /** + * @brief Equal to operator. + * + * @param rhs Flags to compare + * @return True if flags are equal + */ + bool operator ==(const EnumFlags & rhs) const; + /** + * @brief Not equal to operator. + * + * @param rhs Flags to compare + * @return True if flags are not equal + */ + bool operator !=(const EnumFlags & rhs) const; - /** - * @brief Bitwise AND operator. - * - * @param rhs Other flags - * @return Result of bitwise AND - */ - EnumFlags operator &(const EnumFlags & rhs) const; - /** - * @brief Bitwise OR operator. - * - * @param rhs Other flags - * @return Result of bitwise OR - */ - EnumFlags operator |(const EnumFlags & rhs) const; + /** + * @brief Bitwise AND operator. + * + * @param rhs Other flags + * @return Result of bitwise AND + */ + EnumFlags operator &(const EnumFlags & rhs) const; + /** + * @brief Bitwise OR operator. + * + * @param rhs Other flags + * @return Result of bitwise OR + */ + EnumFlags operator |(const EnumFlags & rhs) const; - /** - * @brief Bitwise AND assignment operator. - * - * @param rhs Other flags - * @return Reference to this - */ - EnumFlags & operator &=(const EnumFlags & rhs); - /** - * @brief Bitwise OR assignment operator. - * - * @param rhs Other flags - * @return Reference to this - */ - EnumFlags & operator |=(const EnumFlags & rhs); + /** + * @brief Bitwise AND assignment operator. + * + * @param rhs Other flags + * @return Reference to this + */ + EnumFlags & operator &=(const EnumFlags & rhs); + /** + * @brief Bitwise OR assignment operator. + * + * @param rhs Other flags + * @return Reference to this + */ + EnumFlags & operator |=(const EnumFlags & rhs); - /** - * @brief Explicitly convert flags to uint32_t. - */ - explicit operator uint32_t(); + /** + * @brief Explicitly convert flags to uint32_t. + */ + explicit operator uint32_t(); - private: - /** - * @brief Construct from uint32_t flags. - * - * @param flags Flags - */ - EnumFlags(uint32_t flags); + private: + /** + * @brief Construct from uint32_t flags. + * + * @param flags Flags + */ + EnumFlags(uint32_t flags); - private: - uint32_t flags_; /**< Flags register */ - }; + private: + uint32_t flags_; /**< Flags register */ + }; } // namespace sta @@ -155,23 +155,23 @@ namespace sta * * @param enumType Enum type to overload * - * @ingroup staCore + * @ingroup sta_core */ #define STA_ENUM_FLAGS_OVERLOAD(enumType) \ - sta::EnumFlags operator |(enumType lhs, enumType rhs) \ - { \ - return sta::EnumFlags{lhs} | rhs; \ - } + sta::EnumFlags operator |(enumType lhs, enumType rhs) \ + { \ + return sta::EnumFlags{lhs} | rhs; \ + } /** * @brief Declare alias for sta::EnumFlags specialization. * * @param enumType Enum type for specialization * - * @ingroup staCore + * @ingroup sta_core */ #define STA_ENUM_FLAGS_ALIAS(enumType) \ - using enumType ## Flags = sta::EnumFlags + using enumType ## Flags = sta::EnumFlags /** * @brief Declare enum and create sta::EnumFlags alias and overloads. @@ -180,15 +180,15 @@ namespace sta * @param value1 First enum value * @param ... Enum values 2 - 32 * - * @ingroup staCore + * @ingroup sta_core */ #define STA_ENUM_FLAGS_DECL(enumType, value1, ...) \ - enum class enumType \ - { \ - value1, ##__VA_ARGS__ \ - }; \ - STA_ENUM_FLAGS_ALIAS(enumType); \ - STA_ENUM_FLAGS_OVERLOAD(enumType) + enum class enumType \ + { \ + value1, ##__VA_ARGS__ \ + }; \ + STA_ENUM_FLAGS_ALIAS(enumType); \ + STA_ENUM_FLAGS_OVERLOAD(enumType) // Include template implementation diff --git a/include/sta/enum_flags.tpp b/include/sta/enum_flags.tpp index 9251b05..7571c61 100644 --- a/include/sta/enum_flags.tpp +++ b/include/sta/enum_flags.tpp @@ -11,105 +11,105 @@ namespace sta { - template - EnumFlags::EnumFlags() - : flags_{0} - {} + template + EnumFlags::EnumFlags() + : flags_{0} + {} - template - EnumFlags::EnumFlags(const EnumFlags & other) - : flags_{other.flags_} - {} + template + EnumFlags::EnumFlags(const EnumFlags & other) + : flags_{other.flags_} + {} - template - EnumFlags::EnumFlags(flag_type flag) - : flags_{1U << static_cast(flag)} - {} + template + EnumFlags::EnumFlags(flag_type flag) + : flags_{1U << static_cast(flag)} + {} - template - EnumFlags::EnumFlags(uint32_t flags) - : flags_{flags} - {} + template + EnumFlags::EnumFlags(uint32_t flags) + : flags_{flags} + {} - template - void EnumFlags::set(const EnumFlags & flags) - { - flags_ |= flags.flags_; - } + template + void EnumFlags::set(const EnumFlags & flags) + { + flags_ |= flags.flags_; + } - template - void EnumFlags::clear(const EnumFlags & flags) - { - flags_ &= ~(flags.flags_); - } + template + void EnumFlags::clear(const EnumFlags & flags) + { + flags_ &= ~(flags.flags_); + } - template - void EnumFlags::clear() - { - flags_ = 0; - } + template + void EnumFlags::clear() + { + flags_ = 0; + } - template - bool EnumFlags::isSet(const EnumFlags & flags) const - { - return (flags_ & flags.flags_) == flags.flags_; - } + template + bool EnumFlags::isSet(const EnumFlags & flags) const + { + return (flags_ & flags.flags_) == flags.flags_; + } - template - bool EnumFlags::isAnySet(const EnumFlags & flags) const - { - return (flags_ & flags.flags_) != 0; - } + template + bool EnumFlags::isAnySet(const EnumFlags & flags) const + { + return (flags_ & flags.flags_) != 0; + } - template - bool EnumFlags::operator ==(const EnumFlags & rhs) const - { - return (flags_ == rhs.flags_); - } + template + bool EnumFlags::operator ==(const EnumFlags & rhs) const + { + return (flags_ == rhs.flags_); + } - template - bool EnumFlags::operator !=(const EnumFlags & rhs) const - { - return (flags_ != rhs.flags_); - } + template + bool EnumFlags::operator !=(const EnumFlags & rhs) const + { + return (flags_ != rhs.flags_); + } - template - EnumFlags EnumFlags::operator &(const EnumFlags & rhs) const - { - return EnumFlags(flags_ & rhs.flags_); - } + template + EnumFlags EnumFlags::operator &(const EnumFlags & rhs) const + { + return EnumFlags(flags_ & rhs.flags_); + } - template - EnumFlags EnumFlags::operator |(const EnumFlags & rhs) const - { - return EnumFlags(flags_ | rhs.flags_); - } + template + EnumFlags EnumFlags::operator |(const EnumFlags & rhs) const + { + return EnumFlags(flags_ | rhs.flags_); + } - template - EnumFlags & EnumFlags::operator &=(const EnumFlags & rhs) - { - flags_ &= rhs.flags_; - return *this; - } + template + EnumFlags & EnumFlags::operator &=(const EnumFlags & rhs) + { + flags_ &= rhs.flags_; + return *this; + } - template - EnumFlags & EnumFlags::operator |=(const EnumFlags & rhs) - { - flags_ |= rhs.flags_; - return *this; - } + template + EnumFlags & EnumFlags::operator |=(const EnumFlags & rhs) + { + flags_ |= rhs.flags_; + return *this; + } - template - EnumFlags::operator uint32_t() - { - return flags_; - } + template + EnumFlags::operator uint32_t() + { + return flags_; + } } // namespace sta diff --git a/include/sta/fifo_buffer.hpp b/include/sta/fifo_buffer.hpp index 646aff3..7c66fb1 100644 --- a/include/sta/fifo_buffer.hpp +++ b/include/sta/fifo_buffer.hpp @@ -8,107 +8,107 @@ namespace sta { - /** - * @brief FIFO buffer. - * - * @tparam Size Size type - * @tparam N Buffer size - * - * @ingroup staCore - */ - template - class FifoBuffer - { - public: - /** - * @brief FIFO size type. - */ - using size_type = Size; - /** - * @brief Max number of bytes in FIFO. - */ - static constexpr size_type MAX_SIZE = N; + /** + * @brief FIFO buffer. + * + * @tparam Size Size type + * @tparam N Buffer size + * + * @ingroup sta_core + */ + template + class FifoBuffer + { + public: + /** + * @brief FIFO size type. + */ + using size_type = Size; + /** + * @brief Max number of bytes in FIFO. + */ + static constexpr size_type MAX_SIZE = N; - public: - /** - * @brief Construct empty FIFO buffer. - */ - FifoBuffer(); - /** - * @brief Construct FIFO buffer with initial data. - * - * @param buffer Source buffer - * @param size Buffer size - */ - FifoBuffer(const uint8_t * buffer, Size size); + public: + /** + * @brief Construct empty FIFO buffer. + */ + FifoBuffer(); + /** + * @brief Construct FIFO buffer with initial data. + * + * @param buffer Source buffer + * @param size Buffer size + */ + FifoBuffer(const uint8_t * buffer, Size size); - /** - * @brief Clear buffer content. - */ - void clear(); + /** + * @brief Clear buffer content. + */ + void clear(); - /** - * @brief Set data in buffer. - * - * @param buffer Source buffer - * @param size Number of bytes to write - */ - void set(const uint8_t * buffer, size_type size); + /** + * @brief Set data in buffer. + * + * @param buffer Source buffer + * @param size Number of bytes to write + */ + void set(const uint8_t * buffer, size_type size); - /** - * @brief Append value to end of buffer. - * - * @param value Value - */ - void pushBack(uint8_t value); - /** - * @brief Append data to end of buffer. - * - * @param buffer Source buffer - * @param size Number of bytes to write - */ - void pushBack(const uint8_t * buffer, size_type size); - /** - * @brief Append value repeatedly to end of buffer. - * - * @param value Fill value - * @param count Repeat count - */ - void pushBack(uint8_t value, size_type count); + /** + * @brief Append value to end of buffer. + * + * @param value Value + */ + void pushBack(uint8_t value); + /** + * @brief Append data to end of buffer. + * + * @param buffer Source buffer + * @param size Number of bytes to write + */ + void pushBack(const uint8_t * buffer, size_type size); + /** + * @brief Append value repeatedly to end of buffer. + * + * @param value Fill value + * @param count Repeat count + */ + void pushBack(uint8_t value, size_type count); - /** - * @brief Take data from start of buffer. - * - * @param buffer Destination buffer - * @param size Number of bytes to read - */ - void popFront(uint8_t * buffer, size_type size); + /** + * @brief Take data from start of buffer. + * + * @param buffer Destination buffer + * @param size Number of bytes to read + */ + void popFront(uint8_t * buffer, size_type size); - /** - * @brief Get size of data in buffer. - * - * @return Data size - */ - size_type size() const; + /** + * @brief Get size of data in buffer. + * + * @return Data size + */ + size_type size() const; - /** - * @brief Check if buffer is full. - * - * @return True if buffer is full - */ - bool isFull() const; - /** - * @brief Check if buffer is empty. - * - * @return True if buffer is empty - */ - bool isEmpty() const; + /** + * @brief Check if buffer is full. + * + * @return True if buffer is full + */ + bool isFull() const; + /** + * @brief Check if buffer is empty. + * + * @return True if buffer is empty + */ + bool isEmpty() const; - private: - uint8_t * head_; /**< Read position */ - uint8_t * tail_; /**< Write position */ - uint8_t buffer_[N]; /**< Buffer data */ - }; + private: + uint8_t * head_; /**< Read position */ + uint8_t * tail_; /**< Write position */ + uint8_t buffer_[N]; /**< Buffer data */ + }; } // namespace sta diff --git a/include/sta/fifo_buffer.tpp b/include/sta/fifo_buffer.tpp index c02db2e..c5395f8 100644 --- a/include/sta/fifo_buffer.tpp +++ b/include/sta/fifo_buffer.tpp @@ -10,93 +10,93 @@ namespace sta { - template - FifoBuffer::FifoBuffer() - : head_{buffer_}, tail_{buffer_} - {} + template + FifoBuffer::FifoBuffer() + : head_{buffer_}, tail_{buffer_} + {} - template - FifoBuffer::FifoBuffer(const uint8_t * buffer, size_type size) - { - set(buffer, size); - } + template + FifoBuffer::FifoBuffer(const uint8_t * buffer, size_type size) + { + set(buffer, size); + } - template - void FifoBuffer::set(const uint8_t * buffer, size_type bsize) - { - STA_ASSERT(bsize <= sizeof(buffer_)); - STA_ASSERT(buffer != nullptr); + template + void FifoBuffer::set(const uint8_t * buffer, size_type bsize) + { + STA_ASSERT(bsize <= sizeof(buffer_)); + STA_ASSERT(buffer != nullptr); - head_ = buffer_; - tail_ = buffer_ + bsize; - memcpy(buffer_, buffer, bsize); - } + head_ = buffer_; + tail_ = buffer_ + bsize; + memcpy(buffer_, buffer, bsize); + } - template - void FifoBuffer::clear() - { - head_ = tail_ = buffer_; - } + template + void FifoBuffer::clear() + { + head_ = tail_ = buffer_; + } - template - void FifoBuffer::pushBack(uint8_t value) - { - STA_ASSERT_MSG(tail_ < buffer_ + sizeof(buffer_), "Buffer overflow"); + template + void FifoBuffer::pushBack(uint8_t value) + { + STA_ASSERT_MSG(tail_ < buffer_ + sizeof(buffer_), "Buffer overflow"); - *tail_++ = value; - } + *tail_++ = value; + } - template - void FifoBuffer::pushBack(const uint8_t * buffer, size_type bsize) - { - STA_ASSERT_MSG(size() + bsize <= sizeof(buffer_), "Buffer overflow"); - STA_ASSERT(buffer != nullptr); + template + void FifoBuffer::pushBack(const uint8_t * buffer, size_type bsize) + { + STA_ASSERT_MSG(size() + bsize <= sizeof(buffer_), "Buffer overflow"); + STA_ASSERT(buffer != nullptr); - memcpy(tail_, buffer, bsize); - tail_ += bsize; - } + memcpy(tail_, buffer, bsize); + tail_ += bsize; + } - template - void FifoBuffer::pushBack(uint8_t value, size_type count) - { - STA_ASSERT_MSG(size() + count <= sizeof(buffer_), "Buffer overflow"); + template + void FifoBuffer::pushBack(uint8_t value, size_type count) + { + STA_ASSERT_MSG(size() + count <= sizeof(buffer_), "Buffer overflow"); - memset(tail_, value, count); - tail_ += count; - } + memset(tail_, value, count); + tail_ += count; + } - template - void FifoBuffer::popFront(uint8_t * buffer, size_type bsize) - { - STA_ASSERT_MSG(size() >= bsize, "Not enough data"); - STA_ASSERT(buffer != nullptr); + template + void FifoBuffer::popFront(uint8_t * buffer, size_type bsize) + { + STA_ASSERT_MSG(size() >= bsize, "Not enough data"); + STA_ASSERT(buffer != nullptr); - memcpy(buffer, head_, bsize); - head_ += bsize; - } + memcpy(buffer, head_, bsize); + head_ += bsize; + } - template - typename FifoBuffer::size_type FifoBuffer::size() const - { - return (tail_ - head_); - } + template + typename FifoBuffer::size_type FifoBuffer::size() const + { + return (tail_ - head_); + } - template - bool FifoBuffer::isFull() const - { - return (tail_ == buffer_ + sizeof(buffer_)); - } + template + bool FifoBuffer::isFull() const + { + return (tail_ == buffer_ + sizeof(buffer_)); + } - template - bool FifoBuffer::isEmpty() const - { - return (head_ == tail_); - } + template + bool FifoBuffer::isEmpty() const + { + return (head_ == tail_); + } } // namespace sta diff --git a/include/sta/gpio_pin.hpp b/include/sta/gpio_pin.hpp index 84cc974..82ce7ec 100644 --- a/include/sta/gpio_pin.hpp +++ b/include/sta/gpio_pin.hpp @@ -8,28 +8,39 @@ namespace sta { - /** - * @brief GPIO pin state. - */ - enum class GpioPinState - { - LOW, - HIGH - }; + /** + * @defgroup sta_core_gpio GPIO + * @ingroup sta_core + * @brief GPIO pins. + * @{ + */ - /** - * @brief Interface for GPIO pins. - */ - class GpioPin - { - public: - /** - * @brief Set pin output state. - * - * @param state Output state - */ - virtual void setState(GpioPinState state) = 0; - }; + + /** + * @brief GPIO pin state. + */ + enum class GpioPinState + { + LOW, + HIGH + }; + + /** + * @brief Interface for GPIO pins. + */ + class GpioPin + { + public: + /** + * @brief Set pin output state. + * + * @param state Output state + */ + virtual void setState(GpioPinState state) = 0; + }; + + + /** @} */ } // namespace sta diff --git a/include/sta/lang.hpp b/include/sta/lang.hpp index 6f83b4b..109860b 100644 --- a/include/sta/lang.hpp +++ b/include/sta/lang.hpp @@ -5,9 +5,10 @@ #ifndef STA_CORE_LANG_HPP #define STA_CORE_LANG_HPP + /** - * @defgroup staCoreLang Lang - * @ingroup staCore + * @defgroup sta_core_lang Lang + * @ingroup sta_core * @brief Compiler instructions. * @{ */ diff --git a/include/sta/mutex.hpp b/include/sta/mutex.hpp index fb8edea..1147f75 100644 --- a/include/sta/mutex.hpp +++ b/include/sta/mutex.hpp @@ -8,23 +8,25 @@ namespace sta { - /** - * @brief Interface for mutex objects. - */ - class Mutex - { - public: - /** - * @brief Block until mutex has been acquired. - */ - virtual void acquire() = 0; - /** - * @brief Release mutex. - */ - virtual void release() = 0; + /** + * @brief Interface for mutex objects. + * + * @ingroup sta_core + */ + class Mutex + { + public: + /** + * @brief Block until mutex has been acquired. + */ + virtual void acquire() = 0; + /** + * @brief Release mutex. + */ + virtual void release() = 0; - static Mutex * ALWAYS_FREE; /**< Fake mutex that can always be acquired */ - }; + static Mutex * ALWAYS_FREE; /**< Fake mutex that can always be acquired */ + }; } // namespace sta diff --git a/include/sta/printable_uart.hpp b/include/sta/printable_uart.hpp index a5e2843..d5473fc 100644 --- a/include/sta/printable_uart.hpp +++ b/include/sta/printable_uart.hpp @@ -13,191 +13,191 @@ namespace sta { - /** - * @brief Integer representation. - * - * @ingroup staCore - */ - enum class IntegerBase - { - DEC, /**< Decimal */ - BIN, /**< Binary */ - HEX /**< Hexadecimal */ - }; + /** + * @brief Integer representation. + * + * @ingroup sta_core + */ + enum class IntegerBase + { + DEC, /**< Decimal */ + BIN, /**< Binary */ + HEX /**< Hexadecimal */ + }; - /** - * @brief Printable interface for UART. - * - * @ingroup staCore - */ - class PrintableUART - { - public: - /** - * @param intf UART instance - */ - PrintableUART(UART * intf); + /** + * @brief Printable interface for UART. + * + * @ingroup sta_core + */ + class PrintableUART + { + public: + /** + * @param intf UART instance + */ + PrintableUART(UART * intf); - /** - * @brief Print single character. - * - * @param c Character to print - */ - void print(char c); - /** - * @brief Print boolean value. - * - * @param b Boolean value - */ - void print(bool b); - /** - * @brief Print floating point value. - * - * @param d Floating point value - */ - void print(double d); - /** - * @brief Print integer in selected base. - * - * @param num 8-bit unsigned integer - * @param base Integer base - */ - void print(uint8_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base. - * - * @param num 16-bit unsigned integer - * @param base Integer base - */ - void print(uint16_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base. - * - * @param num 32-bit unsigned integer - * @param base Integer base - */ - void print(uint32_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base. - * - * @param num Integer - * @param base Integer base - */ - void print(size_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print c-string. - * - * @param str Null terminated string - */ - void print(const char * str); - /** - * @brief Print string. - * - * @param str String buffer - * @param length String length - */ - void print(const char * str, size_t length); + /** + * @brief Print single character. + * + * @param c Character to print + */ + void print(char c); + /** + * @brief Print boolean value. + * + * @param b Boolean value + */ + void print(bool b); + /** + * @brief Print floating point value. + * + * @param d Floating point value + */ + void print(double d); + /** + * @brief Print integer in selected base. + * + * @param num 8-bit unsigned integer + * @param base Integer base + */ + void print(uint8_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base. + * + * @param num 16-bit unsigned integer + * @param base Integer base + */ + void print(uint16_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base. + * + * @param num 32-bit unsigned integer + * @param base Integer base + */ + void print(uint32_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base. + * + * @param num Integer + * @param base Integer base + */ + void print(size_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print c-string. + * + * @param str Null terminated string + */ + void print(const char * str); + /** + * @brief Print string. + * + * @param str String buffer + * @param length String length + */ + void print(const char * str, size_t length); - /** - * @brief Print new-line. - */ - void println(); - /** - * @brief Print single character followed by a new-line. - * - * @param c Character to print - */ - void println(char c); - /** - * @brief Print boolean value followed by a new-line. - * - * @param b Boolean value - */ - void println(bool b); - /** - * @brief Print floating point value followed by a new-line. - * - * @param d Floating point value - */ - void println(double d); - /** - * @brief Print integer in selected base followed by a new-line. - * - * @param num 8-bit unsigned integer - * @param base Integer base - */ - void println(uint8_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base followed by a new-line. - * - * @param num 16-bit unsigned integer - * @param base Integer base - */ - void println(uint16_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base followed by a new-line. - * - * @param num 32-bit unsigned integer - * @param base Integer base - */ - void println(uint32_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print integer in selected base followed by a new-line. - * - * @param num Integer - * @param base Integer base - */ - void println(size_t num, IntegerBase base = IntegerBase::DEC); - /** - * @brief Print c-string followed by a new-line. - * - * @param str Null terminated string - */ - void println(const char * str); - /** - * @brief Print string followed by a new-line. - * - * @param str String buffer - * @param length String length - */ - void println(const char * str, size_t length); + /** + * @brief Print new-line. + */ + void println(); + /** + * @brief Print single character followed by a new-line. + * + * @param c Character to print + */ + void println(char c); + /** + * @brief Print boolean value followed by a new-line. + * + * @param b Boolean value + */ + void println(bool b); + /** + * @brief Print floating point value followed by a new-line. + * + * @param d Floating point value + */ + void println(double d); + /** + * @brief Print integer in selected base followed by a new-line. + * + * @param num 8-bit unsigned integer + * @param base Integer base + */ + void println(uint8_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base followed by a new-line. + * + * @param num 16-bit unsigned integer + * @param base Integer base + */ + void println(uint16_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base followed by a new-line. + * + * @param num 32-bit unsigned integer + * @param base Integer base + */ + void println(uint32_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print integer in selected base followed by a new-line. + * + * @param num Integer + * @param base Integer base + */ + void println(size_t num, IntegerBase base = IntegerBase::DEC); + /** + * @brief Print c-string followed by a new-line. + * + * @param str Null terminated string + */ + void println(const char * str); + /** + * @brief Print string followed by a new-line. + * + * @param str String buffer + * @param length String length + */ + void println(const char * str, size_t length); - private: - /** - * @brief Print unsigned integer in selected base. - * - * @param value Unsigned integer value - * @param base Integer base - * @param fmt printf format string for base 10 - * @param size Size of value in bytes - */ - void printBase(uintmax_t value, IntegerBase base, const char * fmt, size_t size); - /** - * @brief Print unsigned integer in base 10. - * - * @param value Unsigned integer value - * @param fmt printf format string - */ - void printDec(uintmax_t value, const char * fmt); - /** - * @brief Print unsigned integer in base 2. - * - * @param value Unsigned integer value - * @param digits Number of digits to print - */ - void printBin(uintmax_t value, size_t digits); - /** - * @brief Print unsigned integer in base 16. - * - * @param value Unsigned integer value - * @param digits Number of digits to print - */ - void printHex(uintmax_t value, size_t digits); + private: + /** + * @brief Print unsigned integer in selected base. + * + * @param value Unsigned integer value + * @param base Integer base + * @param fmt printf format string for base 10 + * @param size Size of value in bytes + */ + void printBase(uintmax_t value, IntegerBase base, const char * fmt, size_t size); + /** + * @brief Print unsigned integer in base 10. + * + * @param value Unsigned integer value + * @param fmt printf format string + */ + void printDec(uintmax_t value, const char * fmt); + /** + * @brief Print unsigned integer in base 2. + * + * @param value Unsigned integer value + * @param digits Number of digits to print + */ + void printBin(uintmax_t value, size_t digits); + /** + * @brief Print unsigned integer in base 16. + * + * @param value Unsigned integer value + * @param digits Number of digits to print + */ + void printHex(uintmax_t value, size_t digits); - private: - UART * intf_; - }; + private: + UART * intf_; + }; } // namespace sta diff --git a/include/sta/signal.hpp b/include/sta/signal.hpp index 1005290..dd9d1b3 100644 --- a/include/sta/signal.hpp +++ b/include/sta/signal.hpp @@ -8,33 +8,35 @@ namespace sta { - /** - * @brief Interface for signal objects. - */ - class Signal - { - public: - /** - * @brief Enter signaled state. - */ - virtual void notify() = 0; - /** - * @brief Check signal state w/o changing it. - * - * @return True if in signaled state - */ - virtual bool peek() = 0; - /** - * @brief Check signal state. - * - * @return True if in signaled state - */ - virtual bool test() = 0; - /** - * @brief Wait until signaled state is entered. - */ - virtual void wait() = 0; - }; + /** + * @brief Interface for signal objects. + * + * @ingroup sta_core + */ + class Signal + { + public: + /** + * @brief Enter signaled state. + */ + virtual void notify() = 0; + /** + * @brief Check signal state w/o changing it. + * + * @return True if in signaled state + */ + virtual bool peek() = 0; + /** + * @brief Check signal state. + * + * @return True if in signaled state + */ + virtual bool test() = 0; + /** + * @brief Wait until signaled state is entered. + */ + virtual void wait() = 0; + }; } // namespace sta diff --git a/include/sta/stm32/can.hpp b/include/sta/stm32/can.hpp index 32fefe8..2bf910c 100644 --- a/include/sta/stm32/can.hpp +++ b/include/sta/stm32/can.hpp @@ -9,8 +9,8 @@ #define STA_CORE_STM32_CAN_HPP /** - * @defgroup stm32CAN CAN - * @ingroup stm32 + * @defgroup sta_core_stm32_can CAN + * @ingroup sta_core_stm32 * @brief STM32 CAN module. * * Check @ref stm32BuildConfig for configuration options. @@ -33,84 +33,84 @@ namespace sta { - /** - * @brief Implementation of CanController interface using HAL. - * - * @ingroup stm32CAN - */ - class STM32CanController : public CanController - { - public: - static constexpr uint8_t MAX_FILTER_COUNT = 14; /**< Max number of filters */ - static constexpr uint8_t MAX_FIFO_COUNT = 2; /**< Max number of FIFOs */ - static constexpr uint8_t MAX_PAYLOAD_SIZE = 8; /**< Maximum payload size */ + /** + * @brief Implementation of CanController interface using HAL. + * + * @ingroup sta_core_stm32_can + */ + class STM32CanController : public CanController + { + public: + static constexpr uint8_t MAX_FILTER_COUNT = 14; /**< Max number of filters */ + static constexpr uint8_t MAX_FIFO_COUNT = 2; /**< Max number of FIFOs */ + static constexpr uint8_t MAX_PAYLOAD_SIZE = 8; /**< Maximum payload size */ - public: - /** - * @param handle CAN handle - */ - STM32CanController(CAN_HandleTypeDef * handle); + public: + /** + * @param handle CAN handle + */ + STM32CanController(CAN_HandleTypeDef * handle); - /** - * @brief Enable RX pending interrupts. - */ - void enableRxInterrupts(); + /** + * @brief Enable RX pending interrupts. + */ + void enableRxInterrupts(); - /** - * @brief Start CAN controller. - */ - void start(); - /** - * @brief Stop CAN controller. - */ - void stop(); + /** + * @brief Start CAN controller. + */ + void start(); + /** + * @brief Stop CAN controller. + */ + void stop(); - // RX/TX - // + // RX/TX + // - bool sendFrame(const CanTxHeader & header, const uint8_t * payload) override; - bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) override; + bool sendFrame(const CanTxHeader & header, const uint8_t * payload) override; + bool receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) override; - uint32_t getRxFifoFlags() override; + uint32_t getRxFifoFlags() override; - // RX Filter - // + // RX Filter + // - void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) override; - void enableFilter(uint8_t idx) override; - void disableFilter(uint8_t idx) override; - void clearFilters() override; + void configureFilter(uint8_t idx, const CanFilter & filter, bool active = false) override; + void enableFilter(uint8_t idx) override; + void disableFilter(uint8_t idx) override; + void clearFilters() override; - private: - /** - * @brief Initialize filter settings. - */ - void initFilters(); + private: + /** + * @brief Initialize filter settings. + */ + void initFilters(); - private: - CAN_HandleTypeDef * handle_; /**< CAN handle */ - CAN_FilterTypeDef filters_[MAX_FILTER_COUNT]; /**< Filter settings */ - }; + private: + CAN_HandleTypeDef * handle_; /**< CAN handle */ + CAN_FilterTypeDef filters_[MAX_FILTER_COUNT]; /**< Filter settings */ + }; #if defined(STA_STM32_CAN_GLOBAL) || DOXYGEN - /** - * @brief Global CAN instance. - * - * @ingroup stm32CAN - */ - extern STM32CanController CanBus; + /** + * @brief Global CAN instance. + * + * @ingroup sta_core_stm32_can + */ + extern STM32CanController CanBus; - /** - * @brief Interrupt handler for pending RX frames. - * - * May be implemented by application. - * - * @ingroup stm32CAN - */ - void CanBus_RxPendingCallback(); + /** + * @brief Interrupt handler for pending RX frames. + * + * May be implemented by application. + * + * @ingroup sta_core_stm32_can + */ + void CanBus_RxPendingCallback(); #endif // STA_STM32_CAN_GLOBAL } // namespace sta diff --git a/include/sta/stm32/clocks.hpp b/include/sta/stm32/clocks.hpp index 3168f51..a556fb5 100644 --- a/include/sta/stm32/clocks.hpp +++ b/include/sta/stm32/clocks.hpp @@ -5,30 +5,33 @@ #ifndef STA_CORE_STM32_CLOCKS_HPP #define STA_CORE_STM32_CLOCKS_HPP -/** - * @defgroup stm32 STM32 - * @brief Modules implemented for STM32 MCUs. - */ + +// Only enable module on STM32 platform +#include + + +#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN) + +#include + /** - * @defgroup stm32BuildConfig Build config - * @ingroup stm32 - * @brief Build configuration options. - */ - -/** - * @defgroup stm32Clocks Clocks - * @ingroup stm32 + * @defgroup sta_core_stm32_clocks Clocks + * @ingroup sta_core_stm32 * @brief STM32 Clock queries. * @{ */ -// Only enable module on STM32 platform -#include -#if defined(STA_PLATFORM_STM32) || defined(DOXYGEN) - -#include +namespace sta +{ + /** + * @brief Get peripheral clock frequency. + * + * @return Clock frequency + */ + using PCLKFreqFn = uint32_t (*)(); +} // namespace sta /** diff --git a/include/sta/stm32/delay.hpp b/include/sta/stm32/delay.hpp index df7f6e7..6fbd3c5 100644 --- a/include/sta/stm32/delay.hpp +++ b/include/sta/stm32/delay.hpp @@ -11,14 +11,11 @@ #ifndef STA_CORE_STM32_DELAY_HPP #define STA_CORE_STM32_DELAY_HPP -/** - * @defgroup stm32Delay Delay - * @ingroup stm32 - * @brief STM32 Delay module. - */ // Only enable module on STM32 platform #include + + #if defined(STA_PLATFORM_STM32) || defined(DOXYGEN) #include @@ -26,25 +23,32 @@ namespace sta { - /** - * @brief Millisecond delay. - * - * @param ms Milliseconds - * - * @ingroup stm32Delay - */ - void delayMs(uint32_t ms); + /** + * @defgroup sta_core_stm32_delay Delay + * @ingroup sta_core_stm32 + * @brief STM32 Delay module. + * @{ + */ + + + /** + * @brief Millisecond delay. + * + * @param ms Milliseconds + */ + void delayMs(uint32_t ms); #if defined(STA_STM32_DELAY_US_TIM) || defined(DOXYGEN) - /** - * @brief Microsecond delay. - * - * @param us Microseconds - * - * @ingroup stm32Delay - */ - void delayUs(uint32_t us); + /** + * @brief Microsecond delay. + * + * @param us Microseconds + */ + void delayUs(uint32_t us); #endif // STA_STM32_DELAY_US_TIM + + + /** @} */ } // namespace sta diff --git a/include/sta/stm32/gpio_pin.hpp b/include/sta/stm32/gpio_pin.hpp index b112d7e..f6f355e 100644 --- a/include/sta/stm32/gpio_pin.hpp +++ b/include/sta/stm32/gpio_pin.hpp @@ -5,11 +5,6 @@ #ifndef STA_CORE_STM32_GPIO_PIN_HPP #define STA_CORE_STM32_GPIO_PIN_HPP -/** - * @defgroup stm32GPIO GPIO - * @ingroup stm32 - * @brief STM32 GPIO module. - */ // Only enable module on STM32 platform w/ HAL GPIO module enabled #include @@ -26,68 +21,81 @@ #include +/** + * @defgroup sta_core_stm32_gpio GPIO + * @ingroup sta_core_stm32 + * @brief STM32 GPIO module. + */ + namespace sta { - /** - * @brief Container for STM GPIO Pin data. - * - * @ingroup stm32GPIO - */ - class STM32GpioPin : public GpioPin - { - public: - /** - * @param port GPIO port - * @param pin Pin index - */ - STM32GpioPin(GPIO_TypeDef * port, uint16_t pin); - - void setState(GpioPinState state) override; - - /** - * @brief Get GPIO port for pin. - * - * @return GPIO port - */ - GPIO_TypeDef * getPort() const; - /** - * @brief Get pin index for pin. - * - * @return Pin index - */ - uint16_t getPin() const; - /** - * @brief Get GPIO port index for pin. - * - * @return GPIO port index - */ - uint8_t getPortIndex() const; - - private: - GPIO_TypeDef * port_; /**< GPIO port */ - uint16_t pin_; /**< GPIO pin */ - }; + /** + * @ingroup sta_core_stm32_gpio + * @{ + */ - /** - * @brief Interrupt trigger edge. - */ - enum class InterruptEdge - { - RISING, /**< Rising edge */ - FALLING, /**< Falling edge */ - BOTH /**< Rising and falling edge */ - }; + /** + * @brief Container for STM GPIO Pin data. + */ + class STM32GpioPin : public GpioPin + { + public: + /** + * @param port GPIO port + * @param pin Pin index + */ + STM32GpioPin(GPIO_TypeDef * port, uint16_t pin); - /** - * @brief Check pin EXIT pin configuration. - * - * @param pin GPIO pin - * @param edge Interrupt trigger edge - * @return True if EXIT pin and trigger edge matches - */ - bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge); + void setState(GpioPinState state) override; + + /** + * @brief Get GPIO port for pin. + * + * @return GPIO port + */ + GPIO_TypeDef * getPort() const; + /** + * @brief Get pin index for pin. + * + * @return Pin index + */ + uint16_t getPin() const; + /** + * @brief Get GPIO port index for pin. + * + * @return GPIO port index + */ + uint8_t getPortIndex() const; + + private: + GPIO_TypeDef * port_; /**< GPIO port */ + uint16_t pin_; /**< GPIO pin */ + }; + + + /** + * @brief Interrupt trigger edge. + */ + enum class InterruptEdge + { + RISING, /**< Rising edge */ + FALLING, /**< Falling edge */ + BOTH /**< Rising and falling edge */ + }; + + /** + * @brief Check pin EXIT pin configuration. + * + * @param pin GPIO pin + * @param edge Interrupt trigger edge + * @return True if EXIT pin and trigger edge matches + */ + bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge); + + + /** @} */ } // namespace sta /** @@ -95,7 +103,7 @@ namespace sta * * @param label Pin label * - * @ingroup stm32GPIO + * @ingroup sta_core_stm32_gpio */ #define STA_STM32_GPIO_PIN(label) sta::STM32GpioPin{label##_GPIO_Port, label##_Pin} diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp index 2aacf3c..c6f1c33 100644 --- a/include/sta/stm32/hal.hpp +++ b/include/sta/stm32/hal.hpp @@ -6,6 +6,13 @@ #define STA_CORE_STM32_HAL_HPP +/** + * @defgroup sta_core_stm32 STM32 + * @ingroup sta_core_platforms + * @brief Modules implemented for the STM32 platform. + */ + + // Include STM32 HAL headers #include diff --git a/include/sta/stm32/init.hpp b/include/sta/stm32/init.hpp index fcff1c1..7fee75f 100644 --- a/include/sta/stm32/init.hpp +++ b/include/sta/stm32/init.hpp @@ -8,12 +8,12 @@ namespace sta { - /** - * @brief Initialize global HAL objects. - * - * @ingroup stm32 - */ - void initHAL(); + /** + * @brief Initialize global HAL objects. + * + * @ingroup sta_core_stm32 + */ + void initHAL(); } // namespace sta diff --git a/include/sta/stm32/uart.hpp b/include/sta/stm32/uart.hpp index 58f90c2..fb1a10e 100644 --- a/include/sta/stm32/uart.hpp +++ b/include/sta/stm32/uart.hpp @@ -5,12 +5,6 @@ #ifndef STA_CORE_STM32_UART_HPP #define STA_CORE_STM32_UART_HPP -/** - * @defgroup stm32UART UART - * @ingroup stm32 - * @brief STM32 UART module. - */ - // Only enable module on STM32 platform w/ HAL UART module enabled #include @@ -27,26 +21,33 @@ #include +/** + * @defgroup sta_core_stm32_uart UART + * @ingroup sta_core_stm32 + * @brief STM32 UART module. + */ + + namespace sta { - /** - * @brief Implementation of UART interface using HAL. - * - * @ingroup stm32UART - */ - class STM32UART : public UART - { - public: - /** - * @param handle UART handle - */ - STM32UART(UART_HandleTypeDef * handle); + /** + * @brief Implementation of UART interface using HAL. + * + * @ingroup sta_core_stm32_uart + */ + class STM32UART : public UART + { + public: + /** + * @param handle STM32 HAL handle + */ + STM32UART(UART_HandleTypeDef * handle); - void write(const uint8_t * buffer, size_t size) override; + void write(const uint8_t * buffer, size_t size) override; - private: - UART_HandleTypeDef * handle_; /**< UART handle */ - }; + private: + UART_HandleTypeDef * handle_; /**< STM32 HAL handle */ + }; } // namespace sta diff --git a/include/sta/time.hpp b/include/sta/time.hpp index a86cacc..6495952 100644 --- a/include/sta/time.hpp +++ b/include/sta/time.hpp @@ -10,18 +10,18 @@ namespace sta { - /** - * @brief Signature for millisecond precision time. - * - * @return Time in milliseconds - */ - using TimeMsFn = uint32_t (*)(); - /** - * @brief Signature for microseconds precision time. - * - * @return Time in microseconds - */ - using TimeUsFn = uint32_t (*)(); + /** + * @brief Signature for millisecond precision time. + * + * @return Time in milliseconds + */ + using TimeMsFn = uint32_t (*)(); + /** + * @brief Signature for microseconds precision time. + * + * @return Time in microseconds + */ + using TimeUsFn = uint32_t (*)(); } // namespace sta diff --git a/include/sta/uart.hpp b/include/sta/uart.hpp index 765216e..9667623 100644 --- a/include/sta/uart.hpp +++ b/include/sta/uart.hpp @@ -9,41 +9,50 @@ #include +/** + * @defgroup sta_core_uart UART + * @ingroup sta_core + * @brief UART interface. + */ + + namespace sta { - /** - * @brief Interface for %UART. - */ - class UART - { - public: - /** - * @brief Write buffer to %UART. - * - * @param buffer Source buffer - * @param size Number of bytes in buffer - */ - virtual void write(const uint8_t * buffer, size_t size) = 0; + /** + * @brief Interface for %UART. + * + * @ingroup sta_core_uart + */ + class UART + { + public: + /** + * @brief Write buffer to %UART. + * + * @param buffer Source buffer + * @param size Number of bytes in buffer + */ + virtual void write(const uint8_t * buffer, size_t size) = 0; - /** - * @brief Write unsigned integer to %UART. - * - * @param value Unsigned integer value - */ - void write(uint8_t value); - /** - * @brief Write unsigned integer to %UART. - * - * @param value Unsigned integer value - */ - void write(uint16_t value); - /** - * @brief Write unsigned integer to %UART. - * - * @param value Unsigned integer value - */ - void write(uint32_t value); - }; + /** + * @brief Write unsigned integer to %UART. + * + * @param value Unsigned integer value + */ + void write(uint8_t value); + /** + * @brief Write unsigned integer to %UART. + * + * @param value Unsigned integer value + */ + void write(uint16_t value); + /** + * @brief Write unsigned integer to %UART. + * + * @param value Unsigned integer value + */ + void write(uint32_t value); + }; } // namespace sta diff --git a/src/assert.cpp b/src/assert.cpp index fc34e2a..5ba23b2 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -7,23 +7,23 @@ namespace sta { - STA_WEAK - void assert_failed(const char * expr, const char * file, uint32_t line) - { - // printf("%s:%d: Assertion failed: %s", file, line, expr) - STA_DEBUG_PRINT(file); - STA_DEBUG_PRINT(':'); - STA_DEBUG_PRINT(line); - STA_DEBUG_PRINT(": Assertion failed: "); - STA_DEBUG_PRINTLN(expr); - } + STA_WEAK + void assert_failed(const char * expr, const char * file, uint32_t line) + { + // printf("%s:%d: Assertion failed: %s", file, line, expr) + STA_DEBUG_PRINT(file); + STA_DEBUG_PRINT(':'); + STA_DEBUG_PRINT(line); + STA_DEBUG_PRINT(": Assertion failed: "); + STA_DEBUG_PRINTLN(expr); + } - STA_WEAK - void assert_halt() - { - STA_BKPT(); - while (true); - } + STA_WEAK + void assert_halt() + { + STA_BKPT(); + while (true); + } } // namespace sta diff --git a/src/atomic/mutex.cpp b/src/atomic/mutex.cpp index f427656..7a74f81 100644 --- a/src/atomic/mutex.cpp +++ b/src/atomic/mutex.cpp @@ -4,19 +4,19 @@ namespace sta { - AtomicMutex::AtomicMutex() - : lock_{ATOMIC_FLAG_INIT} - {} + AtomicMutex::AtomicMutex() + : lock_{ATOMIC_FLAG_INIT} + {} - void AtomicMutex::acquire() - { - while (lock_.test_and_set()); - } + void AtomicMutex::acquire() + { + while (lock_.test_and_set()); + } - void AtomicMutex::release() - { - lock_.clear(); - } + void AtomicMutex::release() + { + lock_.clear(); + } } // namespace sta diff --git a/src/atomic/signal.cpp b/src/atomic/signal.cpp index 96a80db..32d715f 100644 --- a/src/atomic/signal.cpp +++ b/src/atomic/signal.cpp @@ -4,29 +4,29 @@ namespace sta { - AtomicSignal::AtomicSignal() - : signal_{false} - {} + AtomicSignal::AtomicSignal() + : signal_{false} + {} - void AtomicSignal::notify() - { - signal_.store(true); - } + void AtomicSignal::notify() + { + signal_.store(true); + } - bool AtomicSignal::peek() - { - return signal_.load(); - } + bool AtomicSignal::peek() + { + return signal_.load(); + } - bool AtomicSignal::test() - { - return signal_.exchange(false); - } + bool AtomicSignal::test() + { + return signal_.exchange(false); + } - void AtomicSignal::wait() - { - while (!signal_.exchange(false)); - } + void AtomicSignal::wait() + { + while (!signal_.exchange(false)); + } } // namespace sta diff --git a/src/can/id.cpp b/src/can/id.cpp index 829d4a4..8ba0fd9 100644 --- a/src/can/id.cpp +++ b/src/can/id.cpp @@ -3,24 +3,24 @@ namespace sta { - bool operator ==(const CanId & lhs, const CanId & rhs) - { - return (lhs.sid == rhs.sid && lhs.eid == rhs.eid); - } + bool operator ==(const CanId & lhs, const CanId & rhs) + { + return (lhs.sid == rhs.sid && lhs.eid == rhs.eid); + } - bool operator !=(const CanId & lhs, const CanId & rhs) - { - return !(lhs == rhs); - } + bool operator !=(const CanId & lhs, const CanId & rhs) + { + return !(lhs == rhs); + } - bool operator ==(const CanFrameId & lhs, const CanFrameId & rhs) - { - return (lhs.format == rhs.format && lhs.sid == rhs.sid && lhs.eid == rhs.eid); - } + bool operator ==(const CanFrameId & lhs, const CanFrameId & rhs) + { + return (lhs.format == rhs.format && lhs.sid == rhs.sid && lhs.eid == rhs.eid); + } - bool operator !=(const CanFrameId & lhs, const CanFrameId & rhs) - { - return !(lhs == rhs); - } + bool operator !=(const CanFrameId & lhs, const CanFrameId & rhs) + { + return !(lhs == rhs); + } } // namespace sta diff --git a/src/can/iter.cpp b/src/can/iter.cpp index 82472cb..b7a7b06 100644 --- a/src/can/iter.cpp +++ b/src/can/iter.cpp @@ -5,91 +5,91 @@ namespace sta { - CanPendingRxFifos::const_iterator::const_iterator(uint32_t rxFlags, uint8_t idx, uint8_t endIdx) - : rxFlags_{rxFlags}, idx_{idx}, endIdx_{endIdx} - {} + CanPendingRxFifos::const_iterator::const_iterator(uint32_t rxFlags, uint8_t idx, uint8_t endIdx) + : rxFlags_{rxFlags}, idx_{idx}, endIdx_{endIdx} + {} - CanPendingRxFifos::const_iterator::const_iterator(const const_iterator & iter) - : rxFlags_{iter.rxFlags_}, idx_{iter.idx_}, endIdx_{iter.endIdx_} - {} + CanPendingRxFifos::const_iterator::const_iterator(const const_iterator & iter) + : rxFlags_{iter.rxFlags_}, idx_{iter.idx_}, endIdx_{iter.endIdx_} + {} - CanPendingRxFifos::const_iterator & CanPendingRxFifos::const_iterator::operator=(const const_iterator & iter) - { - rxFlags_ = iter.rxFlags_; - idx_ = iter.idx_; - endIdx_ = iter.endIdx_; + CanPendingRxFifos::const_iterator & CanPendingRxFifos::const_iterator::operator=(const const_iterator & iter) + { + rxFlags_ = iter.rxFlags_; + idx_ = iter.idx_; + endIdx_ = iter.endIdx_; - return *this; - } + return *this; + } - bool CanPendingRxFifos::const_iterator::operator==(const const_iterator & iter) const - { - return (rxFlags_ == iter.rxFlags_) && (idx_ == iter.idx_) && (endIdx_ == iter.endIdx_); - } + bool CanPendingRxFifos::const_iterator::operator==(const const_iterator & iter) const + { + return (rxFlags_ == iter.rxFlags_) && (idx_ == iter.idx_) && (endIdx_ == iter.endIdx_); + } - bool CanPendingRxFifos::const_iterator::operator!=(const const_iterator & iter) const - { - return !(*this == iter); - } + bool CanPendingRxFifos::const_iterator::operator!=(const const_iterator & iter) const + { + return !(*this == iter); + } - CanPendingRxFifos::const_iterator & CanPendingRxFifos::const_iterator::operator++() - { - while (idx_ < endIdx_) - { - ++idx_; - if (isRxPending()) - { - break; - } - } + CanPendingRxFifos::const_iterator & CanPendingRxFifos::const_iterator::operator++() + { + while (idx_ < endIdx_) + { + ++idx_; + if (isRxPending()) + { + break; + } + } - return *this; - } + return *this; + } - CanPendingRxFifos::const_iterator CanPendingRxFifos::const_iterator::operator++(int) - { - uint8_t oldIdx = idx_; + CanPendingRxFifos::const_iterator CanPendingRxFifos::const_iterator::operator++(int) + { + uint8_t oldIdx = idx_; - while (idx_ < endIdx_) - { - ++idx_; - if (isRxPending()) - { - break; - } - } + while (idx_ < endIdx_) + { + ++idx_; + if (isRxPending()) + { + break; + } + } - return const_iterator(rxFlags_, oldIdx, endIdx_); - } + return const_iterator(rxFlags_, oldIdx, endIdx_); + } - CanPendingRxFifos::const_iterator::reference CanPendingRxFifos::const_iterator::operator*() const - { - STA_ASSERT_MSG(idx_ != endIdx_, "Dereferencing out-of-bounds iterator"); + CanPendingRxFifos::const_iterator::reference CanPendingRxFifos::const_iterator::operator*() const + { + STA_ASSERT_MSG(idx_ != endIdx_, "Dereferencing out-of-bounds iterator"); - return idx_; - } + return idx_; + } - bool CanPendingRxFifos::const_iterator::isRxPending() const - { - return ( (rxFlags_ >> idx_) & 0x1 ); - } + bool CanPendingRxFifos::const_iterator::isRxPending() const + { + return ( (rxFlags_ >> idx_) & 0x1 ); + } - CanPendingRxFifos::CanPendingRxFifos(uint32_t rxFlags, uint8_t numFifos) - : rxFlags_{rxFlags}, numFifos_{numFifos} - {} + CanPendingRxFifos::CanPendingRxFifos(uint32_t rxFlags, uint8_t numFifos) + : rxFlags_{rxFlags}, numFifos_{numFifos} + {} - CanPendingRxFifos::const_iterator CanPendingRxFifos::begin() const - { - return const_iterator(rxFlags_, 0, numFifos_); - } + CanPendingRxFifos::const_iterator CanPendingRxFifos::begin() const + { + return const_iterator(rxFlags_, 0, numFifos_); + } - CanPendingRxFifos::const_iterator CanPendingRxFifos::end() const - { - return const_iterator(rxFlags_, numFifos_, numFifos_); - } + CanPendingRxFifos::const_iterator CanPendingRxFifos::end() const + { + return const_iterator(rxFlags_, numFifos_, numFifos_); + } } // namespace sta diff --git a/src/debug_serial.cpp b/src/debug_serial.cpp index 68bb98f..80a0db5 100644 --- a/src/debug_serial.cpp +++ b/src/debug_serial.cpp @@ -16,14 +16,14 @@ using PlatformUART = sta::STM32UART; namespace { - // Create platform specific serial interface - PlatformUART platformDebugSerial(&STA_DEBUG_SERIAL_UART); + // Create platform specific serial interface + PlatformUART platformDebugSerial(&STA_DEBUG_SERIAL_UART); } namespace sta { - // Create debug serial object using platform specific serial interface - PrintableUART DebugSerial(&platformDebugSerial); + // Create debug serial object using platform specific serial interface + PrintableUART DebugSerial(&platformDebugSerial); } // namespace sta diff --git a/src/mutex.cpp b/src/mutex.cpp index b861ebd..2472911 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -3,18 +3,18 @@ namespace sta { - /** - * @brief Dummy mutex implementation with no access control. - */ - class DummyMutex : public Mutex - { - public: - void acquire() override {} - void release() override {} - }; + /** + * @brief Dummy mutex implementation with no access control. + */ + class DummyMutex : public Mutex + { + public: + void acquire() override {} + void release() override {} + }; - static DummyMutex dummyMutex; + static DummyMutex dummyMutex; - Mutex * Mutex::ALWAYS_FREE = &dummyMutex; + Mutex * Mutex::ALWAYS_FREE = &dummyMutex; } // namespace sta diff --git a/src/printable_uart.cpp b/src/printable_uart.cpp index 5ff9920..4462ac9 100644 --- a/src/printable_uart.cpp +++ b/src/printable_uart.cpp @@ -10,202 +10,202 @@ namespace sta { - PrintableUART::PrintableUART(UART * intf) - : intf_{intf} - { - STA_ASSERT(intf != nullptr); - } + PrintableUART::PrintableUART(UART * intf) + : intf_{intf} + { + STA_ASSERT(intf != nullptr); + } - void PrintableUART::print(char c) - { - print(&c, 1); - } + void PrintableUART::print(char c) + { + print(&c, 1); + } - void PrintableUART::print(bool b) - { - print(b ? "true" : "false"); - } + void PrintableUART::print(bool b) + { + print(b ? "true" : "false"); + } - void PrintableUART::print(double d) - { - char buffer[64]; - snprintf(buffer, sizeof(buffer), "%f", d); - print(buffer); - } + void PrintableUART::print(double d) + { + char buffer[64]; + snprintf(buffer, sizeof(buffer), "%f", d); + print(buffer); + } - void PrintableUART::print(uint8_t num, IntegerBase base /* = IntegerBase::DEC */) - { - printBase(num, base, "%" PRIu8, sizeof(num)); - } + void PrintableUART::print(uint8_t num, IntegerBase base /* = IntegerBase::DEC */) + { + printBase(num, base, "%" PRIu8, sizeof(num)); + } - void PrintableUART::print(uint16_t num, IntegerBase base /* = IntegerBase::DEC */) - { - printBase(num, base, "%" PRIu16, sizeof(num)); - } + void PrintableUART::print(uint16_t num, IntegerBase base /* = IntegerBase::DEC */) + { + printBase(num, base, "%" PRIu16, sizeof(num)); + } - void PrintableUART::print(uint32_t num, IntegerBase base /* = IntegerBase::DEC */) - { - printBase(num, base, "%" PRIu32, sizeof(num)); - } + void PrintableUART::print(uint32_t num, IntegerBase base /* = IntegerBase::DEC */) + { + printBase(num, base, "%" PRIu32, sizeof(num)); + } - void PrintableUART::print(size_t num, IntegerBase base /* = IntegerBase::DEC */) - { - printBase(num, base, "%z", sizeof(num)); - } + void PrintableUART::print(size_t num, IntegerBase base /* = IntegerBase::DEC */) + { + printBase(num, base, "%z", sizeof(num)); + } - void PrintableUART::print(const char * str) - { - print(str, strlen(str)); - } + void PrintableUART::print(const char * str) + { + print(str, strlen(str)); + } - void PrintableUART::print(const char * str, size_t length) - { - intf_->write(reinterpret_cast(str), length); - } + void PrintableUART::print(const char * str, size_t length) + { + intf_->write(reinterpret_cast(str), length); + } - void PrintableUART::println() - { - print("\r\n", 2); - } + void PrintableUART::println() + { + print("\r\n", 2); + } - void PrintableUART::println(char c) - { - print(&c, 1); - println(); - } + void PrintableUART::println(char c) + { + print(&c, 1); + println(); + } - void PrintableUART::println(bool b) - { - print(b); - println(); - } + void PrintableUART::println(bool b) + { + print(b); + println(); + } - void PrintableUART::println(double d) - { - print(d); - println(); - } + void PrintableUART::println(double d) + { + print(d); + println(); + } - void PrintableUART::println(uint8_t num, IntegerBase base /* = IntegerBase::DEC */) - { - print(num, base); - println(); - } + void PrintableUART::println(uint8_t num, IntegerBase base /* = IntegerBase::DEC */) + { + print(num, base); + println(); + } - void PrintableUART::println(uint16_t num, IntegerBase base /* = IntegerBase::DEC */) - { - print(num, base); - println(); - } + void PrintableUART::println(uint16_t num, IntegerBase base /* = IntegerBase::DEC */) + { + print(num, base); + println(); + } - void PrintableUART::println(uint32_t num, IntegerBase base /* = IntegerBase::DEC */) - { - print(num, base); - println(); - } + void PrintableUART::println(uint32_t num, IntegerBase base /* = IntegerBase::DEC */) + { + print(num, base); + println(); + } - void PrintableUART::println(size_t num, IntegerBase base /* = IntegerBase::DEC */) - { - print(num, base); - println(); - } + void PrintableUART::println(size_t num, IntegerBase base /* = IntegerBase::DEC */) + { + print(num, base); + println(); + } - void PrintableUART::println(const char * str) - { - println(str, strlen(str)); - } + void PrintableUART::println(const char * str) + { + println(str, strlen(str)); + } - void PrintableUART::println(const char * str, size_t length) - { - print(str, length); - println(); - } + void PrintableUART::println(const char * str, size_t length) + { + print(str, length); + println(); + } - void PrintableUART::printBase(uintmax_t num, IntegerBase base, const char * fmt, size_t size) - { - switch (base) - { - case IntegerBase::DEC: - printDec(num, fmt); - break; + void PrintableUART::printBase(uintmax_t num, IntegerBase base, const char * fmt, size_t size) + { + switch (base) + { + case IntegerBase::DEC: + printDec(num, fmt); + break; - case IntegerBase::BIN: - // Digits in base 2 = size in bytes * 8 - printBin(num, size * 8); - break; + case IntegerBase::BIN: + // Digits in base 2 = size in bytes * 8 + printBin(num, size * 8); + break; - case IntegerBase::HEX: - // Digits in base 16 = size in bytes * 2 - printHex(num, size * 2); - break; + case IntegerBase::HEX: + // Digits in base 16 = size in bytes * 2 + printHex(num, size * 2); + break; - default: - print(""); - } - } + default: + print(""); + } + } - void PrintableUART::printDec(uintmax_t num, const char * fmt) - { - char buffer[64]; - snprintf(buffer, sizeof(buffer), fmt, static_cast(num)); - print(buffer); - } + void PrintableUART::printDec(uintmax_t num, const char * fmt) + { + char buffer[64]; + snprintf(buffer, sizeof(buffer), fmt, static_cast(num)); + print(buffer); + } - void PrintableUART::printBin(uintmax_t value, size_t digits) - { - // Need 8 digits for every byte - char buffer[sizeof(value) * 8]; + void PrintableUART::printBin(uintmax_t value, size_t digits) + { + // Need 8 digits for every byte + char buffer[sizeof(value) * 8]; - // Check bounds - if (digits > sizeof(buffer)) - { - print(""); - return; - } - // Nothing to do - if (digits == 0) - return; + // Check bounds + if (digits > sizeof(buffer)) + { + print(""); + return; + } + // Nothing to do + if (digits == 0) + return; - for (size_t i = 0; i < digits; ++i) - { - // Convert bit to '0' or '1' - // First digit in buffer is MSB in value, so shift from high to low - buffer[i] = '0' + ((value >> (digits - 1 - i)) & 0x1); - } + for (size_t i = 0; i < digits; ++i) + { + // Convert bit to '0' or '1' + // First digit in buffer is MSB in value, so shift from high to low + buffer[i] = '0' + ((value >> (digits - 1 - i)) & 0x1); + } - print(buffer, digits); - } + print(buffer, digits); + } - void PrintableUART::printHex(uintmax_t value, size_t digits) - { - // Need 2 digits for every byte - char buffer[sizeof(value) * 2]; + void PrintableUART::printHex(uintmax_t value, size_t digits) + { + // Need 2 digits for every byte + char buffer[sizeof(value) * 2]; - // Check bounds - if (digits > sizeof(buffer)) - { - print(""); - return; - } - // Nothing to do - if (digits == 0) - return; + // Check bounds + if (digits > sizeof(buffer)) + { + print(""); + return; + } + // Nothing to do + if (digits == 0) + return; - for (size_t i = 0; i < digits; ++i) - { - // Convert 4 bits to hex - // First digit in buffer is 4 MSBs in value, so shift from high to low - uint8_t hex = ((value >> ((digits - 1 - i) * 4)) & 0xF); - if (hex > 9) - buffer[i] = 'A' + (hex - 10); - else - buffer[i] = '0' + hex; - } + for (size_t i = 0; i < digits; ++i) + { + // Convert 4 bits to hex + // First digit in buffer is 4 MSBs in value, so shift from high to low + uint8_t hex = ((value >> ((digits - 1 - i) * 4)) & 0xF); + if (hex > 9) + buffer[i] = 'A' + (hex - 10); + else + buffer[i] = '0' + hex; + } - print(buffer, digits); - } + print(buffer, digits); + } } // namespace sta diff --git a/src/stm32/can.cpp b/src/stm32/can.cpp index 0e0379c..5c39fc7 100644 --- a/src/stm32/can.cpp +++ b/src/stm32/can.cpp @@ -7,167 +7,167 @@ namespace sta { - STM32CanController::STM32CanController(CAN_HandleTypeDef * handle) - : handle_{handle} - { - initFilters(); - } + STM32CanController::STM32CanController(CAN_HandleTypeDef * handle) + : handle_{handle} + { + initFilters(); + } - void STM32CanController::enableRxInterrupts() - { - HAL_CAN_ActivateNotification(handle_, - CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_RX_FIFO1_MSG_PENDING - ); - } + void STM32CanController::enableRxInterrupts() + { + HAL_CAN_ActivateNotification(handle_, + CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_RX_FIFO1_MSG_PENDING + ); + } - void STM32CanController::start() - { - HAL_CAN_Start(handle_); - } + void STM32CanController::start() + { + HAL_CAN_Start(handle_); + } - void STM32CanController::stop() - { - HAL_CAN_Stop(handle_); - } + void STM32CanController::stop() + { + HAL_CAN_Stop(handle_); + } - bool STM32CanController::sendFrame(const CanTxHeader & header, const uint8_t * payload) - { - STA_ASSERT_MSG(header.payloadLength <= 8, "CAN 2.0B payload size exceeded"); + bool STM32CanController::sendFrame(const CanTxHeader & header, const uint8_t * payload) + { + STA_ASSERT_MSG(header.payloadLength <= 8, "CAN 2.0B payload size exceeded"); - CAN_TxHeaderTypeDef halHeader; + CAN_TxHeaderTypeDef halHeader; - if (header.id.format == CanIdFormat::STD) - { - halHeader.StdId = header.id.sid & 0x7FF; - halHeader.IDE = CAN_ID_STD; - } - else - { - // Combine SID and EID - halHeader.ExtId = ((header.id.sid & 0x7FF) << 18) | (header.id.eid & 0x3FFFF); - halHeader.IDE = CAN_ID_EXT; - } + if (header.id.format == CanIdFormat::STD) + { + halHeader.StdId = header.id.sid & 0x7FF; + halHeader.IDE = CAN_ID_STD; + } + else + { + // Combine SID and EID + halHeader.ExtId = ((header.id.sid & 0x7FF) << 18) | (header.id.eid & 0x3FFFF); + halHeader.IDE = CAN_ID_EXT; + } - halHeader.DLC = header.payloadLength; + halHeader.DLC = header.payloadLength; - uint32_t mailbox; // Don't care - return (HAL_OK == HAL_CAN_AddTxMessage(handle_, &halHeader, const_cast(payload), &mailbox)); - } + uint32_t mailbox; // Don't care + return (HAL_OK == HAL_CAN_AddTxMessage(handle_, &halHeader, const_cast(payload), &mailbox)); + } - bool STM32CanController::receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) - { - // Check if message is available - if (HAL_CAN_GetRxFifoFillLevel(handle_, fifo) == 0) - return false; + bool STM32CanController::receiveFrame(uint8_t fifo, CanRxHeader * header, uint8_t * payload) + { + // Check if message is available + if (HAL_CAN_GetRxFifoFillLevel(handle_, fifo) == 0) + return false; - // Retrieve message - CAN_RxHeaderTypeDef halHeader; - HAL_CAN_GetRxMessage(handle_, fifo, &halHeader, payload); + // Retrieve message + CAN_RxHeaderTypeDef halHeader; + HAL_CAN_GetRxMessage(handle_, fifo, &halHeader, payload); - if (halHeader.IDE == CAN_ID_STD) - { - header->id.format = CanIdFormat::STD; - header->id.sid = halHeader.StdId; - header->id.eid = 0; - } - else - { - header->id.format = CanIdFormat::EXT; - // Separate SID and EID - header->id.sid = (halHeader.ExtId >> 18); - header->id.eid = halHeader.ExtId & 0x3FFFF; - } - // No conversion required for CAN 2B standard - header->payloadLength = halHeader.DLC; - header->timestamp = halHeader.Timestamp; - header->filter = halHeader.FilterMatchIndex; + if (halHeader.IDE == CAN_ID_STD) + { + header->id.format = CanIdFormat::STD; + header->id.sid = halHeader.StdId; + header->id.eid = 0; + } + else + { + header->id.format = CanIdFormat::EXT; + // Separate SID and EID + header->id.sid = (halHeader.ExtId >> 18); + header->id.eid = halHeader.ExtId & 0x3FFFF; + } + // No conversion required for CAN 2B standard + header->payloadLength = halHeader.DLC; + header->timestamp = halHeader.Timestamp; + header->filter = halHeader.FilterMatchIndex; - return true; - } + return true; + } - uint32_t STM32CanController::getRxFifoFlags() - { - // - return (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0) - | (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0) << 1; - } + uint32_t STM32CanController::getRxFifoFlags() + { + // + return (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0) + | (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0) << 1; + } - void STM32CanController::configureFilter(uint8_t idx, const CanFilter & filter, bool active /* = false */) - { - CAN_FilterTypeDef * config = &filters_[idx]; + void STM32CanController::configureFilter(uint8_t idx, const CanFilter & filter, bool active /* = false */) + { + CAN_FilterTypeDef * config = &filters_[idx]; - if (filter.type == CanFilterIdFormat::STD) - { - config->FilterIdHigh = 0; - config->FilterIdLow = filter.obj.sid & 0x7FF; - config->FilterMaskIdHigh = 0; - config->FilterMaskIdLow = filter.mask.sid & 0x7FF; - } - else - { - config->FilterIdHigh = ((filter.obj.sid & 0x7FF) << 2) | ((filter.obj.eid >> 16) & 0x3); - config->FilterIdLow = filter.obj.eid & 0xFFFF; - config->FilterMaskIdHigh = ((filter.mask.sid & 0x7FF) << 2) | ((filter.mask.eid >> 16) & 0x3); - config->FilterMaskIdLow = filter.mask.eid & 0xFFFF; - } + if (filter.type == CanFilterIdFormat::STD) + { + config->FilterIdHigh = 0; + config->FilterIdLow = filter.obj.sid & 0x7FF; + config->FilterMaskIdHigh = 0; + config->FilterMaskIdLow = filter.mask.sid & 0x7FF; + } + else + { + config->FilterIdHigh = ((filter.obj.sid & 0x7FF) << 2) | ((filter.obj.eid >> 16) & 0x3); + config->FilterIdLow = filter.obj.eid & 0xFFFF; + config->FilterMaskIdHigh = ((filter.mask.sid & 0x7FF) << 2) | ((filter.mask.eid >> 16) & 0x3); + config->FilterMaskIdLow = filter.mask.eid & 0xFFFF; + } - config->FilterFIFOAssignment = filter.fifo; - config->FilterActivation = (active ? CAN_FILTER_ENABLE : CAN_FILTER_DISABLE); + config->FilterFIFOAssignment = filter.fifo; + config->FilterActivation = (active ? CAN_FILTER_ENABLE : CAN_FILTER_DISABLE); - HAL_CAN_ConfigFilter(handle_, config); - } + HAL_CAN_ConfigFilter(handle_, config); + } - void STM32CanController::enableFilter(uint8_t idx) - { - CAN_FilterTypeDef * config = &filters_[idx]; + void STM32CanController::enableFilter(uint8_t idx) + { + CAN_FilterTypeDef * config = &filters_[idx]; - config->FilterActivation = CAN_FILTER_ENABLE; + config->FilterActivation = CAN_FILTER_ENABLE; - HAL_CAN_ConfigFilter(handle_, config); - } + HAL_CAN_ConfigFilter(handle_, config); + } - void STM32CanController::disableFilter(uint8_t idx) - { - CAN_FilterTypeDef * config = &filters_[idx]; + void STM32CanController::disableFilter(uint8_t idx) + { + CAN_FilterTypeDef * config = &filters_[idx]; - config->FilterActivation = CAN_FILTER_DISABLE; + config->FilterActivation = CAN_FILTER_DISABLE; - HAL_CAN_ConfigFilter(handle_, config); - } + HAL_CAN_ConfigFilter(handle_, config); + } - void STM32CanController::clearFilters() - { - for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) - { - CAN_FilterTypeDef * config = &filters_[i]; + void STM32CanController::clearFilters() + { + for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) + { + CAN_FilterTypeDef * config = &filters_[i]; - // Only disable active filters - if (config->FilterActivation == CAN_FILTER_ENABLE) - { - config->FilterActivation = CAN_FILTER_DISABLE; - HAL_CAN_ConfigFilter(handle_, config); - } - } - } + // Only disable active filters + if (config->FilterActivation == CAN_FILTER_ENABLE) + { + config->FilterActivation = CAN_FILTER_DISABLE; + HAL_CAN_ConfigFilter(handle_, config); + } + } + } - void STM32CanController::initFilters() - { - for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) - { - CAN_FilterTypeDef * config = &filters_[i]; + void STM32CanController::initFilters() + { + for (uint32_t i = 0; i < MAX_FILTER_COUNT; ++i) + { + CAN_FilterTypeDef * config = &filters_[i]; - config->FilterBank = i; - config->FilterMode = CAN_FILTERMODE_IDMASK; - config->FilterScale = CAN_FILTERSCALE_32BIT; - config->FilterActivation = CAN_FILTER_DISABLE; - config->SlaveStartFilterBank = MAX_FILTER_COUNT; - } - } + config->FilterBank = i; + config->FilterMode = CAN_FILTERMODE_IDMASK; + config->FilterScale = CAN_FILTERSCALE_32BIT; + config->FilterActivation = CAN_FILTER_DISABLE; + config->SlaveStartFilterBank = MAX_FILTER_COUNT; + } + } } // namespace sta @@ -177,31 +177,31 @@ namespace sta namespace sta { - STM32CanController CanBus(&STA_STM32_CAN_GLOBAL); + STM32CanController CanBus(&STA_STM32_CAN_GLOBAL); - STA_WEAK - void CanBus_RxPendingCallback() - {} + STA_WEAK + void CanBus_RxPendingCallback() + {} } // namespace sta extern "C" { - void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) - { - if (hcan == &STA_STM32_CAN_GLOBAL) - { - sta::CanBus_RxPendingCallback(); - } - } + void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) + { + if (hcan == &STA_STM32_CAN_GLOBAL) + { + sta::CanBus_RxPendingCallback(); + } + } - void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan) - { - if (hcan == &STA_STM32_CAN_GLOBAL) - { - sta::CanBus_RxPendingCallback(); - } - } + void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan) + { + if (hcan == &STA_STM32_CAN_GLOBAL) + { + sta::CanBus_RxPendingCallback(); + } + } } #endif // STA_STM32_CAN_GLOBAL diff --git a/src/stm32/delay.cpp b/src/stm32/delay.cpp index d9c58fc..a3b9a98 100644 --- a/src/stm32/delay.cpp +++ b/src/stm32/delay.cpp @@ -10,10 +10,10 @@ namespace sta { - void delayMs(uint32_t ms) - { - HAL_Delay(ms); - } + void delayMs(uint32_t ms) + { + HAL_Delay(ms); + } } // namespace sta @@ -27,46 +27,46 @@ namespace sta namespace sta { - uint32_t gDelayUsMul = 1; + uint32_t gDelayUsMul = 1; - void delayUs(uint32_t us) - { - __HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0); - while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us * gDelayUsMul); - } + void delayUs(uint32_t us) + { + __HAL_TIM_SET_COUNTER(&STA_STM32_DELAY_US_TIM, 0); + while (__HAL_TIM_GET_COUNTER(&STA_STM32_DELAY_US_TIM) < us * gDelayUsMul); + } - bool isValidDelayUsTIM() - { - // Get PCLK multiplier for TIM clock - uint32_t pclkMul = 1; - switch (STA_STM32_DELAY_US_TIM.Init.ClockDivision) - { - case TIM_CLOCKDIVISION_DIV1: - pclkMul = 1; - break; - case TIM_CLOCKDIVISION_DIV2: - pclkMul = 2; - break; - case TIM_CLOCKDIVISION_DIV4: - pclkMul = 4; - break; - default: - STA_ASSERT(false); - STA_UNREACHABLE(); - } + bool isValidDelayUsTIM() + { + // Get PCLK multiplier for TIM clock + uint32_t pclkMul = 1; + switch (STA_STM32_DELAY_US_TIM.Init.ClockDivision) + { + case TIM_CLOCKDIVISION_DIV1: + pclkMul = 1; + break; + case TIM_CLOCKDIVISION_DIV2: + pclkMul = 2; + break; + case TIM_CLOCKDIVISION_DIV4: + pclkMul = 4; + break; + default: + STA_ASSERT(false); + STA_UNREACHABLE(); + } - // Calculate TIM clock frequency - uint32_t clkFreq = pclkMul * STA_STM32_GET_HANDLE_PCLK_FREQ_FN(STA_STM32_DELAY_US_TIM)(); - // Calculate update frequency based on prescaler value - uint32_t prescaler = (STA_STM32_DELAY_US_TIM.Init.Prescaler) ? STA_STM32_DELAY_US_TIM.Init.Prescaler : 1; - uint32_t updateFreq = clkFreq / prescaler; + // Calculate TIM clock frequency + uint32_t clkFreq = pclkMul * STA_STM32_GET_HANDLE_PCLK_FREQ_FN(STA_STM32_DELAY_US_TIM)(); + // Calculate update frequency based on prescaler value + uint32_t prescaler = (STA_STM32_DELAY_US_TIM.Init.Prescaler) ? STA_STM32_DELAY_US_TIM.Init.Prescaler : 1; + uint32_t updateFreq = clkFreq / prescaler; - gDelayUsMul = updateFreq / 1000000; + gDelayUsMul = updateFreq / 1000000; - // TIM must have at least microsecond precision (>= 1 MHz frequency) - return (updateFreq >= 1000000); - } + // TIM must have at least microsecond precision (>= 1 MHz frequency) + return (updateFreq >= 1000000); + } } // namespace sta #endif // STA_STM32_DELAY_US_TIM diff --git a/src/stm32/gpio_pin.cpp b/src/stm32/gpio_pin.cpp index 20e3208..c0d6a67 100644 --- a/src/stm32/gpio_pin.cpp +++ b/src/stm32/gpio_pin.cpp @@ -7,76 +7,76 @@ namespace sta { - STM32GpioPin::STM32GpioPin(GPIO_TypeDef * port, uint16_t pin) - : port_{port}, pin_{pin} - { - STA_ASSERT(port != nullptr); - } + STM32GpioPin::STM32GpioPin(GPIO_TypeDef * port, uint16_t pin) + : port_{port}, pin_{pin} + { + STA_ASSERT(port != nullptr); + } - void STM32GpioPin::setState(GpioPinState state) - { - HAL_GPIO_WritePin(port_, pin_, (state == GpioPinState::LOW) ? GPIO_PIN_RESET : GPIO_PIN_SET); - } + void STM32GpioPin::setState(GpioPinState state) + { + HAL_GPIO_WritePin(port_, pin_, (state == GpioPinState::LOW) ? GPIO_PIN_RESET : GPIO_PIN_SET); + } - GPIO_TypeDef * STM32GpioPin::getPort() const - { - return port_; - } + GPIO_TypeDef * STM32GpioPin::getPort() const + { + return port_; + } - uint16_t STM32GpioPin::getPin() const - { - return pin_; - } + uint16_t STM32GpioPin::getPin() const + { + return pin_; + } - uint8_t STM32GpioPin::getPortIndex() const - { - return GPIO_GET_INDEX(port_); - } + uint8_t STM32GpioPin::getPortIndex() const + { + return GPIO_GET_INDEX(port_); + } - bool isInterruptEdge(const STM32GpioPin & gpioPin, InterruptEdge edge) - { - uint32_t pin = gpioPin.getPin(); + bool isInterruptEdge(const STM32GpioPin & gpioPin, InterruptEdge edge) + { + uint32_t pin = gpioPin.getPin(); - for (uint32_t i = 0; i < 8 * sizeof(pin); ++i) - { - uint32_t ioPos = 1U << i; - if (pin & ioPos) - { - // Check input mode - uint32_t mode = (gpioPin.getPort()->MODER >> (2U * i)) & GPIO_MODE; - if (mode != MODE_INPUT) - { - return false; - } + for (uint32_t i = 0; i < 8 * sizeof(pin); ++i) + { + uint32_t ioPos = 1U << i; + if (pin & ioPos) + { + // Check input mode + uint32_t mode = (gpioPin.getPort()->MODER >> (2U * i)) & GPIO_MODE; + if (mode != MODE_INPUT) + { + return false; + } - // Is EXTI configured? - if (EXTI->IMR & ioPos) - { - bool rising = (EXTI->RTSR & ioPos); - bool falling = (EXTI->FTSR & ioPos); + // Is EXTI configured? + if (EXTI->IMR & ioPos) + { + bool rising = (EXTI->RTSR & ioPos); + bool falling = (EXTI->FTSR & ioPos); - switch (edge) - { - case InterruptEdge::RISING: - return rising; + switch (edge) + { + case InterruptEdge::RISING: + return rising; - case InterruptEdge::FALLING: - return falling; + case InterruptEdge::FALLING: + return falling; - case InterruptEdge::BOTH: - return rising && falling; + case InterruptEdge::BOTH: + return rising && falling; - default: - STA_ASSERT(false); - STA_UNREACHABLE(); - } - } - } - } + default: + STA_ASSERT(false); + STA_UNREACHABLE(); + } + } + } + } - return false; - } + return false; + } } // namespace sta diff --git a/src/stm32/init.cpp b/src/stm32/init.cpp index b02627f..fed0f3c 100644 --- a/src/stm32/init.cpp +++ b/src/stm32/init.cpp @@ -15,14 +15,14 @@ namespace sta { - void initHAL() - { + void initHAL() + { #ifdef STA_STM32_DELAY_US_TIM - // Validate TIM used for delayUs - extern bool isValidDelayUsTIM(); - STA_ASSERT(isValidDelayUsTIM()); - // Start timer base - HAL_TIM_Base_Start(&STA_STM32_DELAY_US_TIM); + // Validate TIM used for delayUs + extern bool isValidDelayUsTIM(); + STA_ASSERT(isValidDelayUsTIM()); + // Start timer base + HAL_TIM_Base_Start(&STA_STM32_DELAY_US_TIM); #endif // STA_STM32_DELAY_US_TIM - } + } } // namespace sta diff --git a/src/stm32/uart.cpp b/src/stm32/uart.cpp index 54d1eea..094b34e 100644 --- a/src/stm32/uart.cpp +++ b/src/stm32/uart.cpp @@ -6,19 +6,19 @@ namespace sta { - STM32UART::STM32UART(UART_HandleTypeDef * handle) - : handle_{handle} - { - STA_ASSERT(handle != nullptr); - } + STM32UART::STM32UART(UART_HandleTypeDef * handle) + : handle_{handle} + { + STA_ASSERT(handle != nullptr); + } - void STM32UART::write(const uint8_t * buffer, size_t size) - { - STA_ASSERT(buffer != nullptr); + void STM32UART::write(const uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); - HAL_UART_Transmit(handle_, const_cast(buffer), size, HAL_MAX_DELAY); - } + HAL_UART_Transmit(handle_, const_cast(buffer), size, HAL_MAX_DELAY); + } } // namespace sta diff --git a/src/uart.cpp b/src/uart.cpp index e4eaa35..87eadef 100644 --- a/src/uart.cpp +++ b/src/uart.cpp @@ -9,21 +9,21 @@ namespace sta { - void UART::write(uint8_t value) - { - // TODO Handle endian-ness - write(&value, 1); - } + void UART::write(uint8_t value) + { + // TODO Handle endian-ness + write(&value, 1); + } - void UART::write(uint16_t value) - { - // TODO Handle endian-ness - write(reinterpret_cast(&value), sizeof(value)); - } + void UART::write(uint16_t value) + { + // TODO Handle endian-ness + write(reinterpret_cast(&value), sizeof(value)); + } - void UART::write(uint32_t value) - { - // TODO Handle endian-ness - write(reinterpret_cast(&value), sizeof(value)); - } + void UART::write(uint32_t value) + { + // TODO Handle endian-ness + write(reinterpret_cast(&value), sizeof(value)); + } } // namespace sta From fdf5b4890deac9a8e86624fc5be3bbd23246c513 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Thu, 2 Feb 2023 22:23:44 +0100 Subject: [PATCH 20/28] Rename SPI classes --- include/sta/spi/device.hpp | 172 +++++++++++------------ include/sta/spi/interface.hpp | 103 -------------- include/sta/spi/settings.hpp | 165 +++++++++++----------- include/sta/spi/spi.hpp | 107 ++++++++++++++ include/sta/stm32/spi.hpp | 158 +++++++++++---------- src/spi/device.cpp | 122 ++++++++-------- src/spi/interface.cpp | 21 --- src/spi/settings.cpp | 114 +++++++-------- src/spi/spi.cpp | 26 ++++ src/stm32/spi.cpp | 257 +++++++++++++++++----------------- 10 files changed, 630 insertions(+), 615 deletions(-) delete mode 100644 include/sta/spi/interface.hpp create mode 100644 include/sta/spi/spi.hpp delete mode 100644 src/spi/interface.cpp create mode 100644 src/spi/spi.cpp diff --git a/include/sta/spi/device.hpp b/include/sta/spi/device.hpp index 80c0dce..7821bff 100644 --- a/include/sta/spi/device.hpp +++ b/include/sta/spi/device.hpp @@ -1,12 +1,12 @@ /** * @file - * @brief SPI device interface. + * @brief SPI bus peripheral device. */ #ifndef STA_CORE_SPI_DEVICE_HPP #define STA_CORE_SPI_DEVICE_HPP #include -#include +#include #include #include @@ -14,101 +14,101 @@ namespace sta { - /** - * @brief Interface for SPI devices. - * - * @ingroup staCoreSPI - */ - class SpiDevice - { - public: - /** - * @param intf SPI hardware interface - * @param csPin Chip select pin - */ - SpiDevice(SpiInterface * intf, GpioPin * csPin); + /** + * @brief Peripheral device connected via SPI. + * + * @ingroup sta_core_spi + */ + class SPIDevice + { + public: + /** + * @param intf %SPI hardware interface + * @param csPin Chip select pin + */ + SPIDevice(SPI * intf, GpioPin * csPin); - /** - * @brief Start transmission with device. - * - * Must be called before any I/O operations. - */ - void beginTransmission(); - /** - * @brief End transmission with device. - * - * Must be called after last I/O operation. - */ - void endTransmission(); + /** + * @brief Start transmission with device. + * + * Must be called before any I/O operations. + */ + void beginTransmission(); + /** + * @brief End transmission with device. + * + * Must be called after last I/O operation. + */ + void endTransmission(); - /** - * @brief Send single byte of data. - * - * @param value 8-bit value - */ - void transfer(uint8_t value); - /** - * @brief Send two bytes of data. - * - * @param value 16-bit value - */ - void transfer16(uint16_t value); - /** - * @brief Send data from buffer. - * - * @param buffer Source buffer - * @param size Number of bytes to transfer - */ - void transfer(const uint8_t * buffer, size_t size); - /** - * @brief Send and receive data simultaneously. - * - * @param txBuffer Send buffer - * @param rxBuffer Receive buffer - * @param size Number of bytes to transfer - */ - void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size); - /** - * @brief Read incoming data to buffer. - * - * @param buffer Destination buffer - * @param size Number of bytes to read - */ - void receive(uint8_t * buffer, size_t size); + /** + * @brief Send single byte of data. + * + * @param value 8-bit value + */ + void transfer(uint8_t value); + /** + * @brief Send two bytes of data. + * + * @param value 16-bit value + */ + void transfer16(uint16_t value); + /** + * @brief Send data from buffer. + * + * @param buffer Source buffer + * @param size Number of bytes to transfer + */ + void transfer(const uint8_t * buffer, size_t size); + /** + * @brief Send and receive data simultaneously. + * + * @param txBuffer Send buffer + * @param rxBuffer Receive buffer + * @param size Number of bytes to transfer + */ + void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size); + /** + * @brief Read incoming data to buffer. + * + * @param buffer Destination buffer + * @param size Number of bytes to read + */ + void receive(uint8_t * buffer, size_t size); - /** - * @brief Send byte value repeatedly. - * - * @param value 8-bit value to repeat - * @param count Number of repetitions - */ - void fill(uint8_t value, size_t count); + /** + * @brief Send byte value repeatedly. + * + * @param value 8-bit value to repeat + * @param count Number of repetitions + */ + void fill(uint8_t value, size_t count); - /** - * @brief Get SPI interface settings. - * - * @return SPI settings - */ - const SpiSettings & settings() const; + /** + * @brief Get %SPI interface settings. + * + * @return SPI settings + */ + const SpiSettings & settings() const; - /** - * @brief Activate device via CS pin. - */ - void select(); - /** - * @brief Deactivate device via CS pin. - */ - void deselect(); + /** + * @brief Activate device via CS pin. + */ + void select(); + /** + * @brief Deactivate device via CS pin. + */ + void deselect(); - private: - SpiInterface * intf_; /**< SPI hardware interface */ - GpioPin * csPin_; /**< Chip select pin */ - }; + private: + SPI * intf_; /**< %SPI hardware interface */ + GpioPin * csPin_; /**< Chip select pin */ + }; } // namespace sta diff --git a/include/sta/spi/interface.hpp b/include/sta/spi/interface.hpp deleted file mode 100644 index b830526..0000000 --- a/include/sta/spi/interface.hpp +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file - * @brief SPI interface definition. - */ -#ifndef STA_CORE_SPI_INTERFACE_HPP -#define STA_CORE_SPI_INTERFACE_HPP - -#include -#include - -#include -#include - - -namespace sta -{ - /** - * @brief Interface for SPI hardware. - * - * @ingroup staCoreSPI - */ - class SpiInterface - { - public: - /** - * @param mutex Mutex object for managing shared access. Pass nullptr for no access control - */ - SpiInterface(Mutex * mutex = nullptr); - - - /** - * @brief Send single byte of data. - * - * @param value 8-bit value - */ - virtual void transfer(uint8_t value) = 0; - /** - * @brief Send two bytes of data. - * - * @param value 16-bit value - */ - virtual void transfer16(uint16_t value) = 0; - /** - * @brief Send data from buffer. - * - * @param buffer Source buffer - * @param size Number of bytes to transfer - */ - virtual void transfer(const uint8_t * buffer, size_t size) = 0; - /** - * @brief Send and receive data simultaneously. - * - * @param txBuffer Send buffer - * @param rxBuffer Receive buffer - * @param size Number of bytes to transfer - */ - virtual void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) = 0; - /** - * @brief Read incoming data to buffer. - * - * @param buffer Destination buffer - * @param size Number of bytes to read - */ - virtual void receive(uint8_t * buffer, size_t size) = 0; - - - /** - * @brief Send byte value repeatedly. - * - * @param value 8-bit value to repeat - * @param count Number of repetitions - */ - virtual void fill(uint8_t value, size_t count) = 0; - - - /** - * @brief Get SPI interface settings. - * - * @return SPI settings - */ - virtual const SpiSettings & settings() const = 0; - - - /** - * @brief Acquire usage rights to use the interface. - * - * Must be called before any I/O operations are executed. - */ - virtual void acquire(); - /** - * @brief Release usage rights for interface. - * - * Must be called after last I/O operation. - */ - virtual void release(); - - private: - Mutex * mutex_; /**< Mutex object */ - }; -} // namespace sta - - -#endif // STA_CORE_SPI_INTERFACE_HPP diff --git a/include/sta/spi/settings.hpp b/include/sta/spi/settings.hpp index bbd0e35..35b7433 100644 --- a/include/sta/spi/settings.hpp +++ b/include/sta/spi/settings.hpp @@ -1,13 +1,14 @@ /** * @file - * @brief SPI settings. + * @brief SPI bus settings. */ #ifndef STA_CORE_SPI_SETTINGS_HPP #define STA_CORE_SPI_SETTINGS_HPP + /** - * @defgroup staCoreSPI SPI - * @ingroup staCore + * @defgroup sta_core_spi SPI + * @ingroup sta_core * @brief SPI interface. */ @@ -17,97 +18,97 @@ namespace sta { - /** - * @ingroup staCoreSPI - * @{ - */ + /** + * @ingroup sta_core_spi + * @{ + */ - /** - * @brief SPI clock polarity. - */ - enum class SpiClkPolarity - { - LOW, /**< Low idle clock */ - HIGH /**< High idle clock */ - }; + /** + * @brief %SPI clock polarity. + */ + enum class SPIClkPolarity + { + LOW, /**< Low idle clock */ + HIGH /**< High idle clock */ + }; - /** - * @brief SPI clock phase. - */ - enum class SpiClkPhase - { - EDGE_1, /**< Sample on first edge, shift out on second edge */ - EDGE_2 /**< Shift out on first edge, sample on second edge */ - }; + /** + * @brief %SPI clock phase. + */ + enum class SPIClkPhase + { + EDGE_1, /**< Sample on first edge, shift out on second edge */ + EDGE_2 /**< Shift out on first edge, sample on second edge */ + }; - /** - * @brief SPI clock mode. - */ - enum class SpiMode - { - MODE_0, /**< Low idle clock, sample on rising edge, shift out on falling edge */ - MODE_1, /**< Low idle clock, sample on falling edge, shift out on rising edge */ - MODE_2, /**< High idle clock, sample on rising edge, shift out on falling edge */ - MODE_3 /**< High idle clock, sample on falling edge, shift out on rising edge */ - }; + /** + * @brief %SPI clock mode. + */ + enum class SPIMode + { + MODE_0, /**< Low idle clock, sample on rising edge, shift out on falling edge */ + MODE_1, /**< Low idle clock, sample on falling edge, shift out on rising edge */ + MODE_2, /**< High idle clock, sample on rising edge, shift out on falling edge */ + MODE_3 /**< High idle clock, sample on falling edge, shift out on rising edge */ + }; - /** - * @brief SPI data size. - */ - enum class SpiDataSize - { - SIZE_8, /**< 8-bit data size */ - SIZE_16 /**< 16-bit data size */ - }; + /** + * @brief %SPI data size. + */ + enum class SPIDataSize + { + SIZE_8, /**< 8-bit data size */ + SIZE_16 /**< 16-bit data size */ + }; - /** - * @brief SPI bit order. - */ - enum class SpiBitOrder - { - MSB, /**< Send most significant bit first */ - LSB /**< Send least significant bit first */ - }; + /** + * @brief %SPI bit order. + */ + enum class SPIBitOrder + { + MSB, /**< Send most significant bit first */ + LSB /**< Send least significant bit first */ + }; - /** - * @brief SPI settings. - */ - struct SpiSettings - { - SpiMode mode; /**< SPI clock mode */ - SpiDataSize dataSize; /**< SPI data size */ - SpiBitOrder bitOrder; /**< SPI bit order */ - uint32_t clkSpeed; /**< SPI clock speed */ - }; + /** + * @brief %SPI settings. + */ + struct SPISettings + { + SPIMode mode; /**< %SPI clock mode */ + SPIDataSize dataSize; /**< %SPI data size */ + SPIBitOrder bitOrder; /**< %SPI bit order */ + uint32_t clkSpeed; /**< %SPI clock speed */ + }; - /** - * @brief Get SPI clock polarity from clock mode. - * - * @param mode SPI clock mode - * @return SPI clock polarity - */ - SpiClkPolarity getSpiClkPolarity(SpiMode mode); - /** - * @brief Get SPI clock phase from clock mode. - * - * @param mode SPI clock mode - * @return SPI clock phase - */ - SpiClkPhase getSpiClkPhase(SpiMode mode); - /** - * @brief Get SPI clock mode from clock phase and polarity. - * - * @param polarity SPI clock polarity - * @param phase SPI clock phase - * @return SPI clock mode - */ - SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase); + /** + * @brief Get %SPI clock polarity from clock mode. + * + * @param mode %SPI clock mode + * @return %SPI clock polarity + */ + SPIClkPolarity getSPIClkPolarity(SPIMode mode); + /** + * @brief Get %SPI clock phase from clock mode. + * + * @param mode %SPI clock mode + * @return %SPI clock phase + */ + SPIClkPhase getSPIClkPhase(SPIMode mode); + /** + * @brief Get %SPI clock mode from clock phase and polarity. + * + * @param polarity %SPI clock polarity + * @param phase %SPI clock phase + * @return %SPI clock mode + */ + SPIMode getSPIMode(SPIClkPolarity polarity, SPIClkPhase phase); - /** @} */ + /** @} */ } // namespace sta diff --git a/include/sta/spi/spi.hpp b/include/sta/spi/spi.hpp new file mode 100644 index 0000000..5186cbe --- /dev/null +++ b/include/sta/spi/spi.hpp @@ -0,0 +1,107 @@ +/** + * @file + * @brief SPI bus software interface. + */ +#ifndef STA_CORE_SPI_SPI_HPP +#define STA_CORE_SPI_SPI_HPP + +#include +#include + +#include +#include + + +namespace sta +{ + /** + * @brief Interface class for %SPI hardware. + * + * Represents a single %SPI bus that can be shared by multiple devices. + * + * @ingroup sta_core_spi + */ + class SPI + { + public: + /** + * @param settings %SPI bus settings + * @param mutex Mutex object for managing shared access. Pass nullptr for no access control + */ + SPI(const SPISettings & settings, Mutex * mutex = nullptr); + + + /** + * @brief Send single byte of data. + * + * @param value 8-bit value + */ + virtual void transfer(uint8_t value) = 0; + /** + * @brief Send two bytes of data. + * + * @param value 16-bit value + */ + virtual void transfer16(uint16_t value) = 0; + /** + * @brief Send data from buffer. + * + * @param buffer Source buffer + * @param size Number of bytes to transfer + */ + virtual void transfer(const uint8_t * buffer, size_t size) = 0; + /** + * @brief Send and receive data simultaneously. + * + * @param txBuffer Send buffer + * @param rxBuffer Receive buffer + * @param size Number of bytes to transfer + */ + virtual void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) = 0; + /** + * @brief Read incoming data to buffer. + * + * @param buffer Destination buffer + * @param size Number of bytes to read + */ + virtual void receive(uint8_t * buffer, size_t size) = 0; + + + /** + * @brief Send byte value repeatedly. + * + * @param value 8-bit value to repeat + * @param count Number of repetitions + */ + virtual void fill(uint8_t value, size_t count) = 0; + + + /** + * @brief Get %SPI interface settings. + * + * @return %SPI settings + */ + const SPISettings & settings() const; + + + /** + * @brief Acquire usage rights to use the interface. + * + * Must be called before any I/O operations are executed. + */ + virtual void acquire(); + /** + * @brief Release usage rights for interface. + * + * Must be called after last I/O operation. + */ + virtual void release(); + + private: + SPISettings settings_; /**< %SPI settings */ + Mutex * mutex_; /**< Mutex object */ + }; +} // namespace sta + + +#endif // STA_CORE_SPI_SPI_HPP diff --git a/include/sta/stm32/spi.hpp b/include/sta/stm32/spi.hpp index 88515d0..0e477bf 100644 --- a/include/sta/stm32/spi.hpp +++ b/include/sta/stm32/spi.hpp @@ -1,16 +1,10 @@ /** * @file - * @brief Implementations for SpiInterface and SpiDevice using STM32 HAL. + * @brief SPI bus implementation using STM32 HAL. */ #ifndef STA_CORE_STM32_SPI_HPP #define STA_CORE_STM32_SPI_HPP -/** - * @defgroup stm32SPI SPI - * @ingroup stm32 - * @brief STM32 SPI module. - */ - // Only enable module on STM32 platform w/ HAL SPI module enabled #include @@ -24,102 +18,120 @@ # endif // HAL_SPI_MODULE_ENABLED #endif // STA_PLATFORM_STM32 + #if defined(STA_STM32_SPI_ENABLED) || defined(DOXYGEN) #include -#include +#include #include #include +/** + * @defgroup sta_core_stm32_spi SPI + * @ingroup sta_core_stm32 + * @brief STM32 %SPI module. + */ + + namespace sta { - /** - * @ingroup stm32SPI - * @{ - */ + /** + * @addtogroup sta_core_stm32_spi + * @{ + */ - /** - * @brief Get peripheral clock frequency. - * - * @return Clock frequency - */ - using STM32SpiPCLKFreqFn = uint32_t (*)(); + /** + * @brief STM32 HAL implementation of the `SPI` interface class. + */ + class STM32SPI : public SPI + { + public: + struct Info + { + SPI_HandleTypeDef * handle; /**< STM32 HAL handle */ + uint32_t pclkFreq; /**< Peripheral clock frequency used by interface */ + }; - /** - * @brief Info related to STM SPI interface. - */ - struct STM32SpiInterfaceInfo - { - SPI_HandleTypeDef * handle; /**< Interface handle */ - STM32SpiPCLKFreqFn getPCLKFreq; /**< Getter for peripheral clock used by interface */ - }; + public: + /** + * @param handle STM32 HAL handle + * @param pclkFreq Peripheral clock frequency used by %SPI interface + * @param mutex Mutex object for managing access. Pass nullptr for no access control + */ + STM32SPI(SPI_HandleTypeDef * handle, uint32_t pclkFreq, Mutex * mutex = nullptr); + + /** + * @param info Interface info + * @param mutex Mutex object for managing access. Pass nullptr for no access control + */ + STM32SPI(const Info & info, Mutex * mutex = nullptr); + + void transfer(uint8_t value) override; + void transfer16(uint16_t value) override; + void transfer(const uint8_t * buffer, size_t size) override; + void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override; + void receive(uint8_t * buffer, size_t size) override; + + void fill(uint8_t value, size_t count) override; + + private: + SPI_HandleTypeDef * handle_; /**< STM32 HAL handle */ + }; - /** - * @brief Implementation of SpiInterface interface using STM32 HAL. - */ - class STM32SpiInterface : public SpiInterface - { - public: - /** - * @param info SPI interface info - * @param mutex Mutex object for managing access. Pass nullptr for no access control - */ - STM32SpiInterface(const STM32SpiInterfaceInfo & info, Mutex * mutex = nullptr); + /** + * @brief STM32 HAL implementation of the `SPIDevice` class. + */ + class STM32SPIDevice : public SPIDevice + { + public: + /** + * @param intf %SPI interface + * @param csPin Device CS pin + */ + STM32SPIDevice(STM32SPI * intf, STM32GpioPin csPin); - void transfer(uint8_t value) override; - void transfer16(uint16_t value) override; - void transfer(const uint8_t * buffer, size_t size) override; - void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override; - void receive(uint8_t * buffer, size_t size) override; - - void fill(uint8_t value, size_t count) override; - - const SpiSettings & settings() const override; - - private: - STM32SpiInterfaceInfo info_; /**< SPI interface info */ - }; + private: + STM32GpioPin csPin_; /**< Device CS pin */ + }; - /** - * @brief Implementation of SpiDevice interface using STM32 HAL. - */ - class STM32SpiDevice : public SpiDevice - { - public: - /** - * @param intf SPI interface - * @param csPin Device CS pin - */ - STM32SpiDevice(STM32SpiInterface * intf, STM32GpioPin csPin); - - private: - STM32GpioPin csPin_; /**< Device CS pin */ - }; - - - /** @} */ + /** @} */ } // namespace sta /** - * @brief Get SPI interface info struct for STM32 HAL handle. + * @brief Get bus info for STM32 %SPI interface via HAL handle. * * Requires STA_STM32__PCLK_IDX to be defined for the MCU. - * MCU mappings are found in `core` -> sta/mcu/.hpp files. + * MCU mappings are found in the sta/stm32/mcu/.hpp files. * * Check the MCUs Reference Manual RCC register documentation to see which * peripheral clock is used. * - * @param handle SPI interface handle + * @param handle STM32 HAL %SPI handle * - * @ingroup halSPI + * @ingroup sta_core_stm32_spi */ -#define STA_STM32_SPI_INFO(handle) sta::STM32SpiInterfaceInfo{&handle, STA_STM32_GET_HANDLE_PCLK_FREQ_FN(handle)} +#define STA_STM32_SPI_INFO(handle) sta::STM32SPI::Info{&handle, STA_STM32_GET_HANDLE_PCLK_FREQ_FN(handle)()} + +/** + * @brief Get bus info for STM32 %SPI interface via index. + * + * Requires STA_STM32_SPI__PCLK_IDX to be defined for the MCU. + * MCU mappings are found in the sta/stm32/mcu/.hpp files. + * + * Check the MCUs Reference Manual RCC register documentation to see which + * peripheral clock is used. + * + * @param n STM32 %SPI interface index + * + * @ingroup sta_core_stm32_spi + */ +#define STA_STM32_SPI_INFO_N(n) sta::STM32SPI::Info{&handle, STA_STM32_GET_SPI_PCLK_FREQ_FN(n)()} #endif // STA_STM32_SPI_ENABLED diff --git a/src/spi/device.cpp b/src/spi/device.cpp index 1c3f95d..cced053 100644 --- a/src/spi/device.cpp +++ b/src/spi/device.cpp @@ -5,84 +5,84 @@ namespace sta { - SpiDevice::SpiDevice(SpiInterface * intf, GpioPin * csPin) - : intf_{intf}, csPin_{csPin} - { - STA_ASSERT(intf != nullptr); - STA_ASSERT(csPin != nullptr); - } + SPIDevice::SPIDevice(SPI * intf, GpioPin * csPin) + : intf_{intf}, csPin_{csPin} + { + STA_ASSERT(intf != nullptr); + STA_ASSERT(csPin != nullptr); + } - void SpiDevice::beginTransmission() - { - // Acquire SPI access and activate device - intf_->acquire(); - select(); - } + void SPIDevice::beginTransmission() + { + // Acquire SPI access and activate device + intf_->acquire(); + select(); + } - void SpiDevice::endTransmission() - { - // Deactivate device and release SPI access - deselect(); - intf_->release(); - } + void SPIDevice::endTransmission() + { + // Deactivate device and release SPI access + deselect(); + intf_->release(); + } - // Forward I/O operations to SPI interface + // Forward I/O operations to SPI interface - void SpiDevice::transfer(uint8_t data) - { - intf_->transfer(data); - } + void SPIDevice::transfer(uint8_t data) + { + intf_->transfer(data); + } - void SpiDevice::transfer16(uint16_t data) - { - intf_->transfer16(data); - } + void SPIDevice::transfer16(uint16_t data) + { + intf_->transfer16(data); + } - void SpiDevice::transfer(const uint8_t * buffer, size_t size) - { - STA_ASSERT(buffer != nullptr); + void SPIDevice::transfer(const uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); - intf_->transfer(buffer, size); - } + intf_->transfer(buffer, size); + } - void SpiDevice::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) - { - STA_ASSERT(txBuffer != nullptr); - STA_ASSERT(rxBuffer != nullptr); - STA_ASSERT(size != 0); + void SPIDevice::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) + { + STA_ASSERT(txBuffer != nullptr); + STA_ASSERT(rxBuffer != nullptr); + STA_ASSERT(size != 0); - intf_->transfer(txBuffer, rxBuffer, size); - } + intf_->transfer(txBuffer, rxBuffer, size); + } - void SpiDevice::receive(uint8_t * buffer, size_t size) - { - STA_ASSERT(buffer != nullptr); + void SPIDevice::receive(uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); - intf_->receive(buffer, size); - } + intf_->receive(buffer, size); + } - void SpiDevice::fill(uint8_t value, size_t count) - { - STA_ASSERT(count != 0); + void SPIDevice::fill(uint8_t value, size_t count) + { + STA_ASSERT(count != 0); - intf_->fill(value, count); - } + intf_->fill(value, count); + } - const SpiSettings & SpiDevice::settings() const - { - return intf_->settings(); - } + const SpiSettings & SPIDevice::settings() const + { + return intf_->settings(); + } - void SpiDevice::select() - { - csPin_->setState(GpioPinState::LOW); - } + void SPIDevice::select() + { + csPin_->setState(GpioPinState::LOW); + } - void SpiDevice::deselect() - { - csPin_->setState(GpioPinState::HIGH); - } + void SPIDevice::deselect() + { + csPin_->setState(GpioPinState::HIGH); + } } // namespace sta diff --git a/src/spi/interface.cpp b/src/spi/interface.cpp deleted file mode 100644 index a50da61..0000000 --- a/src/spi/interface.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - - -namespace sta -{ - SpiInterface::SpiInterface(Mutex * mutex /* = nullptr */) - : mutex_{mutex} - {} - - void SpiInterface::acquire() - { - if (mutex_ != nullptr) - mutex_->acquire(); - } - - void SpiInterface::release() - { - if (mutex_ != nullptr) - mutex_->release(); - } -} // namespace sta diff --git a/src/spi/settings.cpp b/src/spi/settings.cpp index 5d29a0a..7d76aa0 100644 --- a/src/spi/settings.cpp +++ b/src/spi/settings.cpp @@ -6,67 +6,67 @@ namespace sta { - SpiClkPolarity getSpiClkPolarity(SpiMode mode) - { - switch (mode) - { - case SpiMode::MODE_0: - case SpiMode::MODE_1: - return SpiClkPolarity::LOW; + SPIClkPolarity getSPIClkPolarity(SPIMode mode) + { + switch (mode) + { + case SPIMode::MODE_0: + case SPIMode::MODE_1: + return SPIClkPolarity::LOW; - case SpiMode::MODE_2: - case SpiMode::MODE_3: - return SpiClkPolarity::HIGH; + case SPIMode::MODE_2: + case SPIMode::MODE_3: + return SPIClkPolarity::HIGH; - default: - // Unreachable case - STA_ASSERT_MSG(false, "Case for SpiMode enum not handled"); - STA_UNREACHABLE(); - } - } + default: + // Unreachable case + STA_ASSERT_MSG(false, "Case for SPIMode enum not handled"); + STA_UNREACHABLE(); + } + } - SpiClkPhase getSpiClkPhase(SpiMode mode) - { - switch (mode) - { - case SpiMode::MODE_0: - case SpiMode::MODE_2: - return SpiClkPhase::EDGE_1; + SPIClkPhase getSPIClkPhase(SPIMode mode) + { + switch (mode) + { + case SPIMode::MODE_0: + case SPIMode::MODE_2: + return SPIClkPhase::EDGE_1; - case SpiMode::MODE_1: - case SpiMode::MODE_3: - return SpiClkPhase::EDGE_2; + case SPIMode::MODE_1: + case SPIMode::MODE_3: + return SPIClkPhase::EDGE_2; - default: - // Unreachable case - STA_ASSERT_MSG(false, "Case for SpiMode enum not handled"); - STA_UNREACHABLE(); - } - } + default: + // Unreachable case + STA_ASSERT_MSG(false, "Case for SPIMode enum not handled"); + STA_UNREACHABLE(); + } + } - SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase) - { - if (polarity == SpiClkPolarity::LOW) - { - if (phase == SpiClkPhase::EDGE_1) - { - return SpiMode::MODE_0; - } - else - { - return SpiMode::MODE_1; - } - } - else - { - if (phase == SpiClkPhase::EDGE_1) - { - return SpiMode::MODE_2; - } - else - { - return SpiMode::MODE_3; - } - } - } + SPIMode getSPIMode(SPIClkPolarity polarity, SPIClkPhase phase) + { + if (polarity == SPIClkPolarity::LOW) + { + if (phase == SPIClkPhase::EDGE_1) + { + return SPIMode::MODE_0; + } + else + { + return SPIMode::MODE_1; + } + } + else + { + if (phase == SPIClkPhase::EDGE_1) + { + return SPIMode::MODE_2; + } + else + { + return SPIMode::MODE_3; + } + } + } } // namespace sta diff --git a/src/spi/spi.cpp b/src/spi/spi.cpp new file mode 100644 index 0000000..56d38db --- /dev/null +++ b/src/spi/spi.cpp @@ -0,0 +1,26 @@ +#include + + +namespace sta +{ + SPI::SPI(const SPISettings & settings, Mutex * mutex /* = nullptr */) + : settings_{settings}, mutex_{mutex} + {} + + const SPISettings & SPI::settings() const + { + return settings_; + } + + void SPI::acquire() + { + if (mutex_ != nullptr) + mutex_->acquire(); + } + + void SPI::release() + { + if (mutex_ != nullptr) + mutex_->release(); + } +} // namespace sta diff --git a/src/stm32/spi.cpp b/src/stm32/spi.cpp index 955be2c..ec5af2a 100644 --- a/src/stm32/spi.cpp +++ b/src/stm32/spi.cpp @@ -7,168 +7,161 @@ #ifdef STA_MCU_LITTLE_ENDIAN -# define STA_STM32_SPI_REVERSE_BIT_ORDER SpiBitOrder::MSB +# define STA_STM32_SPI_REVERSE_BIT_ORDER SPIBitOrder::MSB #elif STA_MCU_BIG_ENDIAN -# define STA_STM32_SPI_REVERSE_BIT_ORDER SpiBitOrder::LSB +# define STA_STM32_SPI_REVERSE_BIT_ORDER SPIBitOrder::LSB #endif namespace sta { - static SpiSettings getSpiSettings(SPI_HandleTypeDef * handle, uint32_t pclkFreq) - { - SpiSettings settings; + static SPISettings getSPISettings(SPI_HandleTypeDef * handle, uint32_t pclkFreq) + { + SPISettings settings; - settings.mode = getSpiMode( - (handle->Init.CLKPolarity == SPI_POLARITY_LOW) ? SpiClkPolarity::LOW : SpiClkPolarity::HIGH, - (handle->Init.CLKPhase == SPI_PHASE_1EDGE) ? SpiClkPhase::EDGE_1 : SpiClkPhase::EDGE_2 - ); - settings.dataSize = (handle->Init.DataSize == SPI_DATASIZE_8BIT) ? SpiDataSize::SIZE_8 : SpiDataSize::SIZE_16; - settings.bitOrder = (handle->Init.FirstBit == SPI_FIRSTBIT_MSB) ? SpiBitOrder::MSB : SpiBitOrder::LSB; + settings.mode = getSPIMode( + (handle->Init.CLKPolarity == SPI_POLARITY_LOW) ? SPIClkPolarity::LOW : SPIClkPolarity::HIGH, + (handle->Init.CLKPhase == SPI_PHASE_1EDGE) ? SPIClkPhase::EDGE_1 : SPIClkPhase::EDGE_2 + ); + settings.dataSize = (handle->Init.DataSize == SPI_DATASIZE_8BIT) ? SPIDataSize::SIZE_8 : SPIDataSize::SIZE_16; + settings.bitOrder = (handle->Init.FirstBit == SPI_FIRSTBIT_MSB) ? SPIBitOrder::MSB : SPIBitOrder::LSB; - uint32_t prescaler = 1; - switch (handle->Init.BaudRatePrescaler) - { - case SPI_BAUDRATEPRESCALER_2: - prescaler = 2; - break; - case SPI_BAUDRATEPRESCALER_4: - prescaler = 4; - break; - case SPI_BAUDRATEPRESCALER_8: - prescaler = 8; - break; - case SPI_BAUDRATEPRESCALER_16: - prescaler = 16; - break; - case SPI_BAUDRATEPRESCALER_32: - prescaler = 32; - break; - case SPI_BAUDRATEPRESCALER_64: - prescaler = 64; - break; - case SPI_BAUDRATEPRESCALER_128: - prescaler = 128; - break; - case SPI_BAUDRATEPRESCALER_256: - prescaler = 256; - break; - default: - // Unreachable case - STA_ASSERT_MSG(false, "Case for SPI_BAUDRATEPRESCALER not handled"); - STA_UNREACHABLE(); - } + uint32_t prescaler = 1; + switch (handle->Init.BaudRatePrescaler) + { + case SPI_BAUDRATEPRESCALER_2: + prescaler = 2; + break; + case SPI_BAUDRATEPRESCALER_4: + prescaler = 4; + break; + case SPI_BAUDRATEPRESCALER_8: + prescaler = 8; + break; + case SPI_BAUDRATEPRESCALER_16: + prescaler = 16; + break; + case SPI_BAUDRATEPRESCALER_32: + prescaler = 32; + break; + case SPI_BAUDRATEPRESCALER_64: + prescaler = 64; + break; + case SPI_BAUDRATEPRESCALER_128: + prescaler = 128; + break; + case SPI_BAUDRATEPRESCALER_256: + prescaler = 256; + break; + default: + // Unreachable case + STA_ASSERT_MSG(false, "Case for SPI_BAUDRATEPRESCALER not handled"); + STA_UNREACHABLE(); + } - // SPI clock speed is based of PCLK - settings.clkSpeed = pclkFreq / prescaler; + // SPI clock speed is based of PCLK + settings.clkSpeed = pclkFreq / prescaler; - return settings; - } + return settings; + } - STM32SpiInterface::STM32SpiInterface(const STM32SpiInterfaceInfo & info, Mutex * mutex /* = nullptr */) - : SpiInterface(mutex), info_{info} - { - STA_ASSERT(info.handle != nullptr); - STA_ASSERT(info.getPCLKFreq != nullptr); - } + STM32SPI::STM32SPI(SPI_HandleTypeDef * handle, uint32_t pclkFreq, Mutex * mutex = nullptr) + : SPI(getSPISettings(handle, pclkFreq), mutex), handle_{handle} + { + STA_ASSERT(handle != nullptr); + } + + STM32SPI::STM32SPI(const Info & info, Mutex * mutex /* = nullptr */) + : STM32SPI(info.handle, info.pclkFreq, mutex) + {} - void STM32SpiInterface::transfer(uint8_t value) - { - if (settings().dataSize == SpiDataSize::SIZE_8) - { - HAL_SPI_Transmit(info_.handle, &value, 1, HAL_MAX_DELAY); - } - else - { - // Required since tx buffer is cast to uint16_t * internally - uint16_t dummy = value; - HAL_SPI_Transmit(info_.handle, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); - } - } + void STM32SPI::transfer(uint8_t value) + { + if (settings().dataSize == SPIDataSize::SIZE_8) + { + HAL_SPI_Transmit(handle_, &value, 1, HAL_MAX_DELAY); + } + else + { + // Required since tx buffer is cast to uint16_t * internally + uint16_t dummy = value; + HAL_SPI_Transmit(handle_, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); + } + } - void STM32SpiInterface::transfer16(uint16_t value) - { - uint16_t size = 1; + void STM32SPI::transfer16(uint16_t value) + { + uint16_t size = 1; - // Send as two bytes if data size is 8-bit - if (settings().dataSize == SpiDataSize::SIZE_8) - { - size = 2; + // Send as two bytes if data size is 8-bit + if (settings().dataSize == SPIDataSize::SIZE_8) + { + size = 2; - if (settings().bitOrder == STA_STM32_SPI_REVERSE_BIT_ORDER) - { - // Reverse byte order from internal representation - value = STA_UINT16_SWAP_BYTE_ORDER(value); - } - } + if (settings().bitOrder == STA_STM32_SPI_REVERSE_BIT_ORDER) + { + // Reverse byte order from internal representation + value = STA_UINT16_SWAP_BYTE_ORDER(value); + } + } - HAL_SPI_Transmit(info_.handle, reinterpret_cast(&value), size, HAL_MAX_DELAY); - } + HAL_SPI_Transmit(handle_, reinterpret_cast(&value), size, HAL_MAX_DELAY); + } - void STM32SpiInterface::transfer(const uint8_t * buffer, size_t size) - { - STA_ASSERT(buffer != nullptr); - STA_ASSERT(size != 0); + void STM32SPI::transfer(const uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); + STA_ASSERT(size != 0); - HAL_SPI_Transmit(info_.handle, const_cast(buffer), size, HAL_MAX_DELAY); - } + HAL_SPI_Transmit(handle_, const_cast(buffer), size, HAL_MAX_DELAY); + } - void STM32SpiInterface::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) - { - STA_ASSERT(txBuffer != nullptr); - STA_ASSERT(rxBuffer != nullptr); - STA_ASSERT(size != 0); + void STM32SPI::transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) + { + STA_ASSERT(txBuffer != nullptr); + STA_ASSERT(rxBuffer != nullptr); + STA_ASSERT(size != 0); - HAL_SPI_TransmitReceive(info_.handle, const_cast(txBuffer), rxBuffer, size, HAL_MAX_DELAY); - } + HAL_SPI_TransmitReceive(handle_, const_cast(txBuffer), rxBuffer, size, HAL_MAX_DELAY); + } - void STM32SpiInterface::receive(uint8_t * buffer, size_t size) - { - STA_ASSERT(buffer != nullptr); + void STM32SPI::receive(uint8_t * buffer, size_t size) + { + STA_ASSERT(buffer != nullptr); - HAL_SPI_Receive(info_.handle, buffer, size, HAL_MAX_DELAY); - } + HAL_SPI_Receive(handle_, buffer, size, HAL_MAX_DELAY); + } - void STM32SpiInterface::fill(uint8_t value, size_t count) - { - STA_ASSERT(count != 0); + void STM32SPI::fill(uint8_t value, size_t count) + { + STA_ASSERT(count != 0); - if (settings().dataSize == SpiDataSize::SIZE_8) - { - for (size_t i = 0; i < count; ++i) - { - HAL_SPI_Transmit(info_.handle, &value, 1, HAL_MAX_DELAY); - } - } - else - { - // Required since tx buffer is cast to uint16_t * internally - uint16_t dummy = value; - for (size_t i = 0; i < count; ++i) - { - HAL_SPI_Transmit(info_.handle, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); - } - } - } - - - const SpiSettings & STM32SpiInterface::settings() const - { - // Cache settings - static SpiSettings settings = getSpiSettings(info_.handle, info_.getPCLKFreq()); - - return settings; - } + if (settings().dataSize == SPIDataSize::SIZE_8) + { + for (size_t i = 0; i < count; ++i) + { + HAL_SPI_Transmit(handle_, &value, 1, HAL_MAX_DELAY); + } + } + else + { + // Required since tx buffer is cast to uint16_t * internally + uint16_t dummy = value; + for (size_t i = 0; i < count; ++i) + { + HAL_SPI_Transmit(handle_, reinterpret_cast(&dummy), 1, HAL_MAX_DELAY); + } + } + } - - STM32SpiDevice::STM32SpiDevice(STM32SpiInterface * intf, STM32GpioPin csPin) - : SpiDevice(intf, &csPin_), csPin_{csPin} - {} + STM32SPIDevice::STM32SPIDevice(STM32SPI * intf, STM32GpioPin csPin) + : SPIDevice(intf, &csPin_), csPin_{csPin} + {} } // namespace sta From be0abb1e80dd203725e958de09b1174b40521e49 Mon Sep 17 00:00:00 2001 From: Theodor Teslia Date: Sat, 11 Mar 2023 21:46:41 +0100 Subject: [PATCH 21/28] Implement I2C generic device and STM32 specific; Not yet tested, will be with ADC --- .vscode/settings.json | 69 +++++++++++++++++++++++++++++++++++++++ include/sta/i2c.hpp | 26 +++++++++++++++ include/sta/stm32/i2c.hpp | 39 ++++++++++++++++++++++ src/i2c.cpp | 21 ++++++++++++ src/stm32/i2c.cpp | 53 ++++++++++++++++++++++++++++++ 5 files changed, 208 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 include/sta/i2c.hpp create mode 100644 include/sta/stm32/i2c.hpp create mode 100644 src/i2c.cpp create mode 100644 src/stm32/i2c.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0c03699 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,69 @@ +{ + "files.associations": { + "__bit_reference": "cpp", + "__bits": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tuple": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "exception": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "locale": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "variant": "cpp", + "vector": "cpp", + "__functional_base": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "utility": "cpp" + } +} \ No newline at end of file diff --git a/include/sta/i2c.hpp b/include/sta/i2c.hpp new file mode 100644 index 0000000..faf0eeb --- /dev/null +++ b/include/sta/i2c.hpp @@ -0,0 +1,26 @@ +#ifndef STA_I2C_HPP +#define STA_I2C_HPP + +#include +#include + +namespace sta { + class I2cDevice { + protected: + uint16_t address; + Mutex* mutex; + bool master; + public: + I2cDevice(uint16_t address_10bit, Mutex* mutex=nullptr, bool master=false); + + virtual bool transmit(uint8_t* data, uint16_t size, bool blocking=true) = 0; + + virtual bool receive(uint8_t* data, uint16_t size, bool blocking=true) = 0; + + virtual void acquire(); + + virtual void release(); + }; +} + +#endif // #ifdef STA_I2C_HPP \ No newline at end of file diff --git a/include/sta/stm32/i2c.hpp b/include/sta/stm32/i2c.hpp new file mode 100644 index 0000000..4804e1a --- /dev/null +++ b/include/sta/stm32/i2c.hpp @@ -0,0 +1,39 @@ +#ifndef STA_STM32_I2C_HPP +#define STA_STM32_I2C_HPP + +#include +#ifdef STA_PLATFORM_STM32 +# include +# ifdef HAL_I2C_MODULE_ENABLED +# define STA_STM32_I2C_ENABLED +# endif // HAL_SPI_MODULE_ENABLED +#endif // STA_PLATFORM_STM32 + +#ifdef STA_STM32_I2C_ENABLED + +#include + +namespace sta { + class STM32I2cDevice : public I2cDevice { + private: + I2C_HandleTypeDef* i2cHandle; + const uint32_t timeout = HAL_MAX_DELAY; + + public: + STM32I2cDevice( + I2C_HandleTypeDef* i2cHandle, + uint16_t address, + Mutex* mutex=nullptr, + bool master=false, + bool blocking=true + ); + + bool transmit(uint8_t* data, uint16_t size) override; + bool receive(uint8_t* data, uint16_t size) override; + + bool deviceReady(); + }; +} + +#endif // STA_STM32_I2C_ENABLED +#endif // STA_STM32_I2C_HPP diff --git a/src/i2c.cpp b/src/i2c.cpp new file mode 100644 index 0000000..7f1904a --- /dev/null +++ b/src/i2c.cpp @@ -0,0 +1,21 @@ +#include + +namespace sta { + I2cDevice::I2cDevice(uint16_t address_7bit, Mutex* mutex, bool master) { + this->address = address_7bit << 1; + this->mutex = mutex; + this->master = master; + } + + void I2cDevice::acquire() { + if (this->mutex != nullptr) { + mutex->acquire(); + } + } + + void I2cDevice::release() { + if (this->mutex != nullptr) { + mutex->release(); + } + } +} \ No newline at end of file diff --git a/src/stm32/i2c.cpp b/src/stm32/i2c.cpp new file mode 100644 index 0000000..289bfc1 --- /dev/null +++ b/src/stm32/i2c.cpp @@ -0,0 +1,53 @@ +#include + +namespace sta { + STM32I2cDevice::STM32I2cDevice(I2C_HandleTypeDef* i2cHandle, uint16_t address, Mutex* mutex, bool master, bool blocking) + : I2cDevice(address, mutex, master, blocking) { + this->master = master; + } + + bool STM32I2cDevice::transmit(uint8_t* data, uint16_t size) { + HAL_StatusTypeDef res; + + if (this->blocking) { + if (!this->master) { + res = HAL_I2C_Master_Transmit(i2cHandle, address, data, size, this->timeout); + } else { + res = HAL_I2C_Slave_Transmit(i2cHandle , data, size, this->timeout); + } + } else { + if (!this->master) { + res = HAL_I2C_Master_Transmit_IT(i2cHandle, address, data, size); + } else { + res = HAL_I2C_Slave_Transmit_IT(i2cHandle , data, size); + } + } + + return res == HAL_OK; + } + + bool STM32I2cDevice::receive(uint8_t* data, uint16_t size) { + HAL_StatusTypeDef res; + + if (this->blocking) { + if (!this->master) { + res = HAL_I2C_Master_Receive(i2cHandle, address, data, size, this->timeout); + } else { + res = HAL_I2C_Slave_Receive(i2cHandle , data, size, this->timeout); + } + } else { + if (!this->master) { + res = HAL_I2C_Master_Receive_IT(i2cHandle, address, data, size); + } else { + res = HAL_I2C_Slave_Receive_IT(i2cHandle , data, size); + } + } + + return res == HAL_OK; + } + + bool STM32I2cDevice::deviceReady() { + HAL_StatusTypeDef res = HAL_I2C_IsDeviceReady(this->i2cHandle, this->address, 8, this->timeout); + return res == HAL_OK; + } +} From 08e61cb30007b4e422015024256cc1dd8850c84c Mon Sep 17 00:00:00 2001 From: Theodor Teslia Date: Sat, 11 Mar 2023 21:47:46 +0100 Subject: [PATCH 22/28] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cfe5f9d..4b5a695 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # IDE settings .settings/ +.vscode/ # Contain local paths .mxproject From 94f9cdd8842d2fd878168ef4bc47c9a9219002ac Mon Sep 17 00:00:00 2001 From: Theodor Teslia Date: Fri, 17 Mar 2023 14:15:22 +0100 Subject: [PATCH 23/28] I2C Error fixes --- include/sta/i2c.hpp | 9 +++++---- src/i2c.cpp | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/sta/i2c.hpp b/include/sta/i2c.hpp index faf0eeb..db467dd 100644 --- a/include/sta/i2c.hpp +++ b/include/sta/i2c.hpp @@ -10,12 +10,13 @@ namespace sta { uint16_t address; Mutex* mutex; bool master; + bool blocking; public: - I2cDevice(uint16_t address_10bit, Mutex* mutex=nullptr, bool master=false); + I2cDevice(uint16_t address_10bit, Mutex* mutex=nullptr, bool master=false, bool blocking=true); - virtual bool transmit(uint8_t* data, uint16_t size, bool blocking=true) = 0; + virtual bool transmit(uint8_t* data, uint16_t size) = 0; - virtual bool receive(uint8_t* data, uint16_t size, bool blocking=true) = 0; + virtual bool receive(uint8_t* data, uint16_t size) = 0; virtual void acquire(); @@ -23,4 +24,4 @@ namespace sta { }; } -#endif // #ifdef STA_I2C_HPP \ No newline at end of file +#endif // STA_I2C_HPP diff --git a/src/i2c.cpp b/src/i2c.cpp index 7f1904a..0f32c26 100644 --- a/src/i2c.cpp +++ b/src/i2c.cpp @@ -1,10 +1,11 @@ #include namespace sta { - I2cDevice::I2cDevice(uint16_t address_7bit, Mutex* mutex, bool master) { + I2cDevice::I2cDevice(uint16_t address_7bit, Mutex* mutex, bool master, bool blocking) { this->address = address_7bit << 1; this->mutex = mutex; this->master = master; + this->blocking = blocking; } void I2cDevice::acquire() { @@ -18,4 +19,4 @@ namespace sta { mutex->release(); } } -} \ No newline at end of file +} From 01c2f5971a3e5ff30b9ead6dc5c4b606fc806b53 Mon Sep 17 00:00:00 2001 From: Theodor Teslia Date: Fri, 17 Mar 2023 13:31:39 +0000 Subject: [PATCH 24/28] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index bb7a761..66e36a8 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ Interfaces for the following resources are provided: * Signal * SPI * UART +* I2C ## HAL implementations @@ -108,6 +109,16 @@ Implementations using the HAL are provided for the following interfaces: To enable these implementations follow the instructions from the individual headers. +## Merge with STM32 Core + +The merge with STM32 Core allows seamless usage of the STM32 implementations for the different Interfaces etc. +Notable inclusions: +* CAN +* I2C +* SPI +* UART + + ## Atomic implementations Implementations using atomic variables are provided for the following interfaces: From d2fcd0c12cfa118b032a378be60cba616f0919ba Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sat, 22 Apr 2023 13:03:27 +0200 Subject: [PATCH 25/28] Include config.hpp --- include/sta/lang.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/sta/lang.hpp b/include/sta/lang.hpp index 109860b..35591b7 100644 --- a/include/sta/lang.hpp +++ b/include/sta/lang.hpp @@ -5,6 +5,8 @@ #ifndef STA_CORE_LANG_HPP #define STA_CORE_LANG_HPP +#include + /** * @defgroup sta_core_lang Lang From db69a00b0674ee95b7f0e414646fbc7e0cec0af6 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sat, 22 Apr 2023 13:04:24 +0200 Subject: [PATCH 26/28] Add guards and warning for STM32 HAL include --- include/sta/stm32/hal.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/sta/stm32/hal.hpp b/include/sta/stm32/hal.hpp index c6f1c33..1cf89e5 100644 --- a/include/sta/stm32/hal.hpp +++ b/include/sta/stm32/hal.hpp @@ -12,9 +12,15 @@ * @brief Modules implemented for the STM32 platform. */ +#include +#ifdef STA_PLATFORM_STM32 // Include STM32 HAL headers #include +#else // !STA_PLATFORM_STM32 +# warning "Included STM32 HAL on non-STM32 platform!" +#endif // !STA_PLATFORM_STM32 + #endif // STA_CORE_STM32_HAL_HPP From d4bb7cce884c7713b38cc2d46bfeea3b18555fb4 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sat, 22 Apr 2023 13:06:25 +0200 Subject: [PATCH 27/28] Update Doxyfile to version 1.9.6 --- docs/Doxyfile | 2751 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2751 insertions(+) create mode 100644 docs/Doxyfile diff --git a/docs/Doxyfile b/docs/Doxyfile new file mode 100644 index 0000000..18c4c4d --- /dev/null +++ b/docs/Doxyfile @@ -0,0 +1,2751 @@ +# Doxyfile 1.9.6 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "STA Core" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = "1.0.0" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Commonly used components and interfaces for use in STA software" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = \ + include \ + App/include \ + Libs/sta-core/include \ + Libs/mpaland-printf \ + Libs/rtos2/include \ + Libs/MCP2518FD/include \ + Libs/iso-tp/include \ + Libs/BMP388/include + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = \ + *.c \ + *.cpp \ + *.h \ + *.hpp \ + *.tpp \ + *.py \ + *.pyw + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = \ + Core \ + Drivers \ + Middlewares \ + Debug \ + Release + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# ANamespace::AClass, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = TOGGLE + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /