From 202c1f3aa69a35f91e273c75124832301997ac98 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sun, 24 Apr 2022 13:40:11 +0200 Subject: [PATCH] Improve doxygen comments. Add HAL init --- include/sta/os2/defs.hpp | 3 ++ include/sta/os2/easy_config.hpp | 6 ++-- include/sta/os2/mutex.hpp | 3 ++ include/sta/os2/queue.hpp | 63 +++++++++++++++++++++++++++++++++ include/sta/os2/signal.hpp | 3 ++ src/os2/startup.cpp | 12 +++---- 6 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 include/sta/os2/queue.hpp diff --git a/include/sta/os2/defs.hpp b/include/sta/os2/defs.hpp index 5da075d..a572504 100644 --- a/include/sta/os2/defs.hpp +++ b/include/sta/os2/defs.hpp @@ -1,3 +1,6 @@ +/** + * @brief Constants and macros for use with CMSIS RTOS2. + */ #ifndef STA_OS2_DEFS_HPP #define STA_OS2_DEFS_HPP diff --git a/include/sta/os2/easy_config.hpp b/include/sta/os2/easy_config.hpp index 931daf0..1e438fc 100644 --- a/include/sta/os2/easy_config.hpp +++ b/include/sta/os2/easy_config.hpp @@ -1,8 +1,10 @@ /** * @brief Helper for easy system task setup in ``. * - * Define **STA_OS2_SYSTEM_TASKS_ENABLE** before including this header - * to enable all system tasks and required features. + * Configuration: + * STA_OS2_SYSTEM_TASKS_ENABLE: Enable all system tasks and required features + * STA_OS2_WATCHDOG_TIMER_NAME: Set watchdog timer handle and callback names based on this + * STA_OS2_WATCHDOG_NAME: Set watchdog task handle and entry function names based on this */ #ifndef STA_OS2_EASY_CONFIG_HPP #define STA_OS2_EASY_CONFIG_HPP diff --git a/include/sta/os2/mutex.hpp b/include/sta/os2/mutex.hpp index 23e1d85..2dc91ae 100644 --- a/include/sta/os2/mutex.hpp +++ b/include/sta/os2/mutex.hpp @@ -1,3 +1,6 @@ +/** + * @brief CMSIS RTOS2 mutex implementation. + */ #ifndef STA_OS2_MUTEX_HPP #define STA_OS2_MUTEX_HPP diff --git a/include/sta/os2/queue.hpp b/include/sta/os2/queue.hpp new file mode 100644 index 0000000..975574f --- /dev/null +++ b/include/sta/os2/queue.hpp @@ -0,0 +1,63 @@ +/** + * @brief CMSIS RTOS2 queue implementation. + */ +#ifndef STA_OS2_QUEUE_HPP +#define STA_OS2_QUEUE_HPP + +#include + +#include + + +namespace sta +{ + template + class Os2Queue + { + public: + using Message = T; + public: + Os2Queue(osMessageQueueId_t * handle); + + bool put(const Message & msg, uint32_t timeout = osWaitForever); + bool get(Message * outMsg, uint32_t timeout = osWaitForever); + + uint32 available() const; + + private: + osMessageQueueId_t * handle_; + }; +} // namespace sta + + +namespace sta +{ + template + Os2Queue::Os2Queue(osMessageQueueId_t * handle) + : handle_{handle} + { + STA_ASSERT(handle != nullptr); + } + + template + bool Os2Queue::put(const Message & msg, uint32_t timeout /* = osWaitForever */) + { + return (osOK == osMessageQueuePut(*handle_, &msg, 0, timeout)); + } + + template + bool Os2Queue::get(Message * outMsg, uint32_t timeout /* = osWaitForever */) + { + uint8_t prio; + return (osOK == osMessageQueueGet(*handle_, outMsg, &prio, timeout)); + } + + template + uint32 Os2Queue::available() const + { + return osMessageQueueGetCount(*handle_); + } +} // namespace sta + + +#endif // STA_OS2_QUEUE_HPP diff --git a/include/sta/os2/signal.hpp b/include/sta/os2/signal.hpp index 319f623..94fcef1 100644 --- a/include/sta/os2/signal.hpp +++ b/include/sta/os2/signal.hpp @@ -1,3 +1,6 @@ +/** + * @brief CMSIS RTOS2 signal implementation. + */ #ifndef STA_OS2_SIGNAL_HPP #define STA_OS2_SIGNAL_HPP diff --git a/src/os2/startup.cpp b/src/os2/startup.cpp index aa1ee3f..d87f2bc 100644 --- a/src/os2/startup.cpp +++ b/src/os2/startup.cpp @@ -1,12 +1,14 @@ +/** + * @brief System startup task. + */ #include #ifdef STA_OS2_STARTUP_ENABLE #include +#include #include #include -#include - #include @@ -32,16 +34,14 @@ extern "C" // Call further initialization code sta::startupExtras(arg); + // Initialize HAL + sta::initHAL(); #ifdef STA_OS2_WATCHDOG_ENABLE // Start timers sta::startWatchdogTimer(); #endif // STA_OS2_WATCHDOG_ENABLE -#ifdef STA_HAL_DELAY_US_TIM - HAL_TIM_Base_Start(&STA_HAL_DELAY_US_TIM); -#endif // STA_HAL_DELAY_US_TIM - // Wake tasks sta::signalStartupEvent();