mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-05 19:01:54 +00:00
Change include paths
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @brief Constants and macros for use with CMSIS RTOS2.
|
||||
*/
|
||||
#ifndef STA_OS2_DEFS_HPP
|
||||
#define STA_OS2_DEFS_HPP
|
||||
|
||||
|
||||
// See limits defined in cmsis_os2.c
|
||||
#define STA_OS2_MAX_BITS_TASK_NOTIFY 31U
|
||||
#define STA_OS2_MAX_BITS_EVENT_GROUPS 24U
|
||||
|
||||
#define STA_OS2_THREAD_FLAGS_VALID_BITS ((1UL << STA_OS2_MAX_BITS_TASK_NOTIFY) - 1U)
|
||||
#define STA_OS2_EVENT_FLAGS_VALID_BITS ((1UL << STA_OS2_MAX_BITS_EVENT_GROUPS) - 1U)
|
||||
|
||||
|
||||
#endif // STA_OS2_DEFS_HPP
|
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* @brief Helper for easy system task setup in `<sta/config.hpp>`.
|
||||
*
|
||||
* 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
|
||||
|
||||
#if !defined(STA_CONFIG_HPP) && !defined(STA_OS2_EASY_CONFIG_NO_WARNING)
|
||||
#warning "Intended for use in <sta/config.hpp>"
|
||||
#endif // !STA_CONFIG_HPP && !STA_OS2_EASY_CONFIG_NO_WARNING
|
||||
|
||||
|
||||
#ifdef STA_OS2_SYSTEM_TASKS_ENABLE
|
||||
// Enable system events used by system tasks
|
||||
# define STA_OS2_SYSTEM_EVENT_ENABLE
|
||||
// Enable system tasks
|
||||
# define STA_OS2_WATCHDOG_ENABLE
|
||||
# define STA_OS2_STARTUP_ENABLE
|
||||
#endif // STA_OS2_SYSTEM_TASKS_ENABLE
|
||||
|
||||
|
||||
#define _STA_OS2_CONCAT(a, b) a ## b
|
||||
|
||||
#define STA_OS2_MAKE_HANDLE_NAME(name) _STA_OS2_CONCAT(name, Handle)
|
||||
#define STA_OS2_MAKE_CALLBACK_NAME(name) _STA_OS2_CONCAT(name, Callback)
|
||||
#define STA_OS2_MAKE_TASK_NAME(name) _STA_OS2_CONCAT(name, Task)
|
||||
|
||||
// Use common base name for watchdog timer handle and callback
|
||||
#ifdef STA_OS2_WATCHDOG_TIMER_NAME
|
||||
# define STA_OS2_WATCHDOG_TIMER_HANDLE STA_OS2_MAKE_HANDLE_NAME(STA_OS2_WATCHDOG_TIMER_NAME)
|
||||
# define STA_OS2_WATCHDOG_TIMER_CALLBACK STA_OS2_MAKE_CALLBACK_NAME(STA_OS2_WATCHDOG_TIMER_NAME)
|
||||
#endif // STA_OS2_WATCHDOG_TIMER_NAME
|
||||
|
||||
// Use common base name for watchdog task handle and entry function
|
||||
#ifdef STA_OS2_WATCHDOG_NAME
|
||||
# define STA_OS2_WATCHDOG_HANDLE STA_OS2_MAKE_HANDLE_NAME(STA_OS2_WATCHDOG_NAME)
|
||||
# define STA_OS2_WATCHDOG_ENTRY_FUNCTION STA_OS2_MAKE_TASK_NAME(STA_OS2_WATCHDOG_NAME)
|
||||
#endif // STA_OS2_WATCHDOG_NAME
|
||||
|
||||
|
||||
#endif // STA_OS2_EASY_CONFIG_HPP
|
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* @brief Implementation of startup system task.
|
||||
*
|
||||
* Configuration:
|
||||
* STA_OS2_STARTUP_ENABLE: Enable module
|
||||
* STA_OS2_STARTUP_ENTRY_FUNCTION: Override name of startup task entry function (default: startupTask)
|
||||
*/
|
||||
#ifndef STA_OS2_STARTUP_HPP
|
||||
#define STA_OS2_STARTUP_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_OS2_STARTUP_ENABLE
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Extra initialization run at start of startup task.
|
||||
*
|
||||
* May be overridden by application if required.
|
||||
*/
|
||||
void startupExtras(void * argument);
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_OS2_STARTUP_ENABLE
|
||||
|
||||
#endif // STA_OS2_STARTUP_HPP
|
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* @brief Implementation of watchdog system task.
|
||||
*
|
||||
* Configuration:
|
||||
* STA_OS2_WATCHDOG_ENABLE: Enable module
|
||||
* STA_OS2_WATCHDOG_TIMER_PERIOD: Set period in ticks of heartbeat timer (default: 1000)
|
||||
* STA_OS2_WATCHDOG_TIMER_HANDLE: Override variable name of heartbeat timer handle (default: heartbeatHandle)
|
||||
* STA_OS2_WATCHDOG_TIMER_CALLBACK: Override name of heartbeat timer callback function (default: heartbeatCallback)
|
||||
* STA_OS2_WATCHDOG_HANDLE: Override variable name of watchdog task handle (default: watchdogHandle)
|
||||
* STA_OS2_WATCHDOG_ENTRY_FUNCTION: Override name of watchdog task entry function (default: watchdogTask)
|
||||
*/
|
||||
#ifndef STA_OS2_WATCHDOG_HPP
|
||||
#define STA_OS2_WATCHDOG_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_OS2_WATCHDOG_ENABLE
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
// Watchdog task flags
|
||||
//
|
||||
|
||||
#define STA_WATCHDOG_FLAG_HEARTBEAT 0x00001000U
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Start heartbeat timer for watchdog.
|
||||
*/
|
||||
void startWatchdogTimer();
|
||||
/**
|
||||
* @brief Send notification to watchdog task.
|
||||
*/
|
||||
void notifyWatchdog(uint32_t flags);
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_OS2_WATCHDOG_ENABLE
|
||||
|
||||
#endif // STA_OS2_WATCHDOG_HPP
|
16
include/sta/rtos2/defs.hpp
Normal file
16
include/sta/rtos2/defs.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @brief Constants and macros for use with CMSIS RTOS2.
|
||||
*/
|
||||
#ifndef STA_RTOS2_DEFS_HPP
|
||||
#define STA_RTOS2_DEFS_HPP
|
||||
|
||||
|
||||
// See limits defined in cmsis_os2.c
|
||||
#define STA_RTOS2_MAX_BITS_TASK_NOTIFY 31U
|
||||
#define STA_RTOS2_MAX_BITS_EVENT_GROUPS 24U
|
||||
|
||||
#define STA_RTOS2_THREAD_FLAGS_VALID_BITS ((1UL << STA_RTOS2_MAX_BITS_TASK_NOTIFY) - 1U)
|
||||
#define STA_RTOS2_EVENT_FLAGS_VALID_BITS ((1UL << STA_RTOS2_MAX_BITS_EVENT_GROUPS) - 1U)
|
||||
|
||||
|
||||
#endif // STA_RTOS2_DEFS_HPP
|
45
include/sta/rtos2/easy_config.hpp
Normal file
45
include/sta/rtos2/easy_config.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @brief Helper for easy system task setup in `<sta/config.hpp>`.
|
||||
*
|
||||
* 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_RTOS2_EASY_CONFIG_HPP
|
||||
#define STA_RTOS2_EASY_CONFIG_HPP
|
||||
|
||||
#if !defined(STA_CONFIG_HPP) && !defined(STA_RTOS2_EASY_CONFIG_NO_WARNING)
|
||||
#warning "Intended for use in <sta/config.hpp>"
|
||||
#endif // !STA_CONFIG_HPP && !STA_RTOS2_EASY_CONFIG_NO_WARNING
|
||||
|
||||
|
||||
#ifdef STA_RTOS2_SYSTEM_TASKS_ENABLE
|
||||
// Enable system events used by system tasks
|
||||
# define STA_RTOS2_SYSTEM_EVENT_ENABLE
|
||||
// Enable system tasks
|
||||
# define STA_RTOS2_WATCHDOG_ENABLE
|
||||
# define STA_RTOS2_STARTUP_ENABLE
|
||||
#endif // STA_RTOS2_SYSTEM_TASKS_ENABLE
|
||||
|
||||
|
||||
#define _STA_RTOS2_CONCAT(a, b) a ## b
|
||||
|
||||
#define STA_RTOS2_MAKE_HANDLE_NAME(name) _STA_RTOS2_CONCAT(name, Handle)
|
||||
#define STA_RTOS2_MAKE_CALLBACK_NAME(name) _STA_RTOS2_CONCAT(name, Callback)
|
||||
#define STA_RTOS2_MAKE_TASK_NAME(name) _STA_RTOS2_CONCAT(name, Task)
|
||||
|
||||
// Use common base name for watchdog timer handle and callback
|
||||
#ifdef STA_RTOS2_WATCHDOG_TIMER_NAME
|
||||
# define STA_RTOS2_WATCHDOG_TIMER_HANDLE STA_RTOS2_MAKE_HANDLE_NAME(STA_RTOS2_WATCHDOG_TIMER_NAME)
|
||||
# define STA_RTOS2_WATCHDOG_TIMER_CALLBACK STA_RTOS2_MAKE_CALLBACK_NAME(STA_RTOS2_WATCHDOG_TIMER_NAME)
|
||||
#endif // STA_RTOS2_WATCHDOG_TIMER_NAME
|
||||
|
||||
// Use common base name for watchdog task handle and entry function
|
||||
#ifdef STA_RTOS2_WATCHDOG_NAME
|
||||
# define STA_RTOS2_WATCHDOG_HANDLE STA_RTOS2_MAKE_HANDLE_NAME(STA_RTOS2_WATCHDOG_NAME)
|
||||
# define STA_RTOS2_WATCHDOG_ENTRY_FUNCTION STA_RTOS2_MAKE_TASK_NAME(STA_RTOS2_WATCHDOG_NAME)
|
||||
#endif // STA_RTOS2_WATCHDOG_NAME
|
||||
|
||||
|
||||
#endif // STA_RTOS2_EASY_CONFIG_HPP
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @brief CMSIS RTOS2 mutex implementation.
|
||||
*/
|
||||
#ifndef STA_OS2_MUTEX_HPP
|
||||
#define STA_OS2_MUTEX_HPP
|
||||
#ifndef STA_RTOS2_MUTEX_HPP
|
||||
#define STA_RTOS2_MUTEX_HPP
|
||||
|
||||
#include <sta/intf/mutex.hpp>
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace sta
|
||||
/**
|
||||
* @brief Implementation of `Mutex` interface using CMSIS RTOS2.
|
||||
*/
|
||||
class Os2Mutex : public Mutex
|
||||
class Rtos2Mutex : public Mutex
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param handle CMSIS RTOS2 mutex
|
||||
*/
|
||||
Os2Mutex(osMutexId_t * handle);
|
||||
Rtos2Mutex(osMutexId_t * handle);
|
||||
|
||||
void acquire() override;
|
||||
void release() override;
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @brief CMSIS RTOS2 queue implementation.
|
||||
*/
|
||||
#ifndef STA_OS2_QUEUE_HPP
|
||||
#define STA_OS2_QUEUE_HPP
|
||||
#ifndef STA_RTOS2_QUEUE_HPP
|
||||
#define STA_RTOS2_QUEUE_HPP
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
namespace sta
|
||||
{
|
||||
template <typename T>
|
||||
class Os2Queue
|
||||
class Rtos2Queue
|
||||
{
|
||||
public:
|
||||
using Message = T;
|
||||
public:
|
||||
Os2Queue(osMessageQueueId_t * handle);
|
||||
Rtos2Queue(osMessageQueueId_t * handle);
|
||||
|
||||
bool put(const Message & msg, uint32_t timeout = osWaitForever);
|
||||
bool get(Message * outMsg, uint32_t timeout = osWaitForever);
|
||||
@@ -33,31 +33,31 @@ namespace sta
|
||||
namespace sta
|
||||
{
|
||||
template <typename T>
|
||||
Os2Queue<T>::Os2Queue(osMessageQueueId_t * handle)
|
||||
Rtos2Queue<T>::Rtos2Queue(osMessageQueueId_t * handle)
|
||||
: handle_{handle}
|
||||
{
|
||||
STA_ASSERT(handle != nullptr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Os2Queue<T>::put(const Message & msg, uint32_t timeout /* = osWaitForever */)
|
||||
bool Rtos2Queue<T>::put(const Message & msg, uint32_t timeout /* = osWaitForever */)
|
||||
{
|
||||
return (osOK == osMessageQueuePut(*handle_, &msg, 0, timeout));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Os2Queue<T>::get(Message * outMsg, uint32_t timeout /* = osWaitForever */)
|
||||
bool Rtos2Queue<T>::get(Message * outMsg, uint32_t timeout /* = osWaitForever */)
|
||||
{
|
||||
uint8_t prio;
|
||||
return (osOK == osMessageQueueGet(*handle_, outMsg, &prio, timeout));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
uint32 Os2Queue<T>::available() const
|
||||
uint32 Rtos2Queue<T>::available() const
|
||||
{
|
||||
return osMessageQueueGetCount(*handle_);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_OS2_QUEUE_HPP
|
||||
#endif // STA_RTOS2_QUEUE_HPP
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @brief CMSIS RTOS2 signal implementation.
|
||||
*/
|
||||
#ifndef STA_OS2_SIGNAL_HPP
|
||||
#define STA_OS2_SIGNAL_HPP
|
||||
#ifndef STA_RTOS2_SIGNAL_HPP
|
||||
#define STA_RTOS2_SIGNAL_HPP
|
||||
|
||||
#include <sta/intf/signal.hpp>
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace sta
|
||||
/**
|
||||
* @brief Implementation of `Signal` interface using CMSIS RTOS2.
|
||||
*/
|
||||
class Os2Signal : public Signal
|
||||
class Rtos2Signal : public Signal
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param semaphore CMSIS RTOS2 semaphore
|
||||
*/
|
||||
Os2Signal(osSemaphoreId_t * semaphore);
|
||||
Rtos2Signal(osSemaphoreId_t * semaphore);
|
||||
|
||||
void notify() override;
|
||||
bool peek() override;
|
||||
@@ -33,4 +33,4 @@ namespace sta
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_OS2_SIGNAL_HPP
|
||||
#endif // STA_RTOS2_SIGNAL_HPP
|
28
include/sta/rtos2/startup.hpp
Normal file
28
include/sta/rtos2/startup.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @brief Implementation of startup system task.
|
||||
*
|
||||
* Configuration:
|
||||
* STA_RTOS2_STARTUP_ENABLE: Enable module
|
||||
* STA_RTOS2_STARTUP_ENTRY_FUNCTION: Override name of startup task entry function (default: startupTask)
|
||||
*/
|
||||
#ifndef STA_RTOS2_STARTUP_HPP
|
||||
#define STA_RTOS2_STARTUP_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_RTOS2_STARTUP_ENABLE
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Extra initialization run at start of startup task.
|
||||
*
|
||||
* May be overridden by application if required.
|
||||
*/
|
||||
void startupExtras(void * argument);
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_RTOS2_STARTUP_ENABLE
|
||||
|
||||
#endif // STA_RTOS2_STARTUP_HPP
|
@@ -2,14 +2,14 @@
|
||||
* @brief Implementation of system events.
|
||||
*
|
||||
* Configuration:
|
||||
* STA_OS2_SYSTEM_EVENT_ENABLE: Enable module
|
||||
* STA_OS2_SYSTEM_EVENT_HANDLE: Override variable name of flag handle (default: systemEventHandle)
|
||||
* STA_RTOS2_SYSTEM_EVENT_ENABLE: Enable module
|
||||
* STA_RTOS2_SYSTEM_EVENT_HANDLE: Override variable name of flag handle (default: systemEventHandle)
|
||||
*/
|
||||
#ifndef STA_OS2_SYSTEM_EVENT_HPP
|
||||
#define STA_OS2_SYSTEM_EVENT_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_OS2_SYSTEM_EVENT_ENABLE
|
||||
#ifdef STA_RTOS2_SYSTEM_EVENT_ENABLE
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -53,6 +53,6 @@ namespace sta
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_OS2_SYSTEM_EVENT_ENABLE
|
||||
#endif // STA_RTOS2_SYSTEM_EVENT_ENABLE
|
||||
|
||||
#endif // STA_OS2_SYSTEM_EVENT_HPP
|
||||
#endif // STA_RTOS2_SYSTEM_EVENT_HPP
|
42
include/sta/rtos2/watchdog.hpp
Normal file
42
include/sta/rtos2/watchdog.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @brief Implementation of watchdog system task.
|
||||
*
|
||||
* Configuration:
|
||||
* STA_RTOS2_WATCHDOG_ENABLE: Enable module
|
||||
* STA_RTOS2_WATCHDOG_TIMER_PERIOD: Set period in ticks of heartbeat timer (default: 1000)
|
||||
* STA_RTOS2_WATCHDOG_TIMER_HANDLE: Override variable name of heartbeat timer handle (default: heartbeatHandle)
|
||||
* STA_RTOS2_WATCHDOG_TIMER_CALLBACK: Override name of heartbeat timer callback function (default: heartbeatCallback)
|
||||
* STA_RTOS2_WATCHDOG_HANDLE: Override variable name of watchdog task handle (default: watchdogHandle)
|
||||
* STA_RTOS2_WATCHDOG_ENTRY_FUNCTION: Override name of watchdog task entry function (default: watchdogTask)
|
||||
*/
|
||||
#ifndef STA_RTOS2_WATCHDOG_HPP
|
||||
#define STA_RTOS2_WATCHDOG_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_RTOS2_WATCHDOG_ENABLE
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
// Watchdog task flags
|
||||
//
|
||||
|
||||
#define STA_WATCHDOG_FLAG_HEARTBEAT 0x00001000U
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Start heartbeat timer for watchdog.
|
||||
*/
|
||||
void startWatchdogTimer();
|
||||
/**
|
||||
* @brief Send notification to watchdog task.
|
||||
*/
|
||||
void notifyWatchdog(uint32_t flags);
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_RTOS2_WATCHDOG_ENABLE
|
||||
|
||||
#endif // STA_RTOS2_WATCHDOG_HPP
|
Reference in New Issue
Block a user