mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 19:17:34 +00:00
Rename to STA RTOS
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#include <sta/rtos2/mutex.hpp>
|
||||
#include <sta/rtos/mutex.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
Rtos2Mutex::Rtos2Mutex(osMutexId_t * handle)
|
||||
RTOSMutex::RTOSMutex(osMutexId_t * handle)
|
||||
: handle_{handle}
|
||||
{}
|
||||
|
||||
void Rtos2Mutex::acquire()
|
||||
void RTOSMutex::acquire()
|
||||
{
|
||||
osMutexAcquire(*handle_, osWaitForever);
|
||||
}
|
||||
|
||||
void Rtos2Mutex::release()
|
||||
void RTOSMutex::release()
|
||||
{
|
||||
osMutexRelease(*handle_);
|
||||
}
|
@@ -1,28 +1,28 @@
|
||||
#include <sta/rtos2/signal.hpp>
|
||||
#include <sta/rtos/signal.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
Rtos2Signal::Rtos2Signal(osSemaphoreId_t * semaphore)
|
||||
RTOSSignal::RTOSSignal(osSemaphoreId_t * semaphore)
|
||||
: semaphore_{semaphore}
|
||||
{}
|
||||
|
||||
void Rtos2Signal::notify()
|
||||
void RTOSSignal::notify()
|
||||
{
|
||||
osSemaphoreRelease(*semaphore_);
|
||||
}
|
||||
|
||||
bool Rtos2Signal::peek()
|
||||
bool RTOSSignal::peek()
|
||||
{
|
||||
return (osSemaphoreGetCount(*semaphore_) != 0);
|
||||
}
|
||||
|
||||
bool Rtos2Signal::test()
|
||||
bool RTOSSignal::test()
|
||||
{
|
||||
return (osSemaphoreAcquire(*semaphore_, 0) == osOK);
|
||||
}
|
||||
|
||||
void Rtos2Signal::wait()
|
||||
void RTOSSignal::wait()
|
||||
{
|
||||
osSemaphoreAcquire(*semaphore_, osWaitForever);
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
#include <sta/rtos2/startup.hpp>
|
||||
#ifdef STA_RTOS2_STARTUP_ENABLE
|
||||
#include <sta/rtos/startup.hpp>
|
||||
#ifdef STA_RTOS_STARTUP_ENABLE
|
||||
|
||||
#include <sta/lang.hpp>
|
||||
#include <sta/rtos2/system_event.hpp>
|
||||
#include <sta/rtos2/watchdog.hpp>
|
||||
#include <sta/rtos/system_event.hpp>
|
||||
#include <sta/rtos/watchdog.hpp>
|
||||
#include <sta/stm32/init.hpp>
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
@@ -21,7 +21,7 @@ namespace sta
|
||||
// Declare with C linkage
|
||||
extern "C"
|
||||
{
|
||||
void STA_RTOS2_STARTUP_ENTRY_FUNCTION(void * arg)
|
||||
void STA_RTOS_STARTUP_ENTRY_FUNCTION(void * arg)
|
||||
{
|
||||
// Call further initialization code
|
||||
sta::startupExtras(arg);
|
||||
@@ -29,10 +29,10 @@ extern "C"
|
||||
// Initialize HAL
|
||||
sta::initHAL();
|
||||
|
||||
#ifdef STA_RTOS2_WATCHDOG_ENABLE
|
||||
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
||||
// Start timers
|
||||
sta::startWatchdogTimer();
|
||||
#endif // STA_RTOS2_WATCHDOG_ENABLE
|
||||
#endif // STA_RTOS_WATCHDOG_ENABLE
|
||||
|
||||
// Wake tasks
|
||||
sta::signalStartupEvent();
|
||||
@@ -43,4 +43,4 @@ extern "C"
|
||||
}
|
||||
|
||||
|
||||
#endif // STA_RTOS2_STARTUP_ENABLE
|
||||
#endif // STA_RTOS_STARTUP_ENABLE
|
@@ -1,24 +1,24 @@
|
||||
#include <sta/rtos2/system_event.hpp>
|
||||
#include <sta/rtos/system_event.hpp>
|
||||
|
||||
#ifdef STA_RTOS2_SYSTEM_EVENT_ENABLE
|
||||
#ifdef STA_RTOS_SYSTEM_EVENT_ENABLE
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
|
||||
// Access handle from freertos.c
|
||||
extern osEventFlagsId_t STA_RTOS2_SYSTEM_EVENT_HANDLE;
|
||||
extern osEventFlagsId_t STA_RTOS_SYSTEM_EVENT_HANDLE;
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void signalSystemEvents(uint32_t flags)
|
||||
{
|
||||
osEventFlagsSet(STA_RTOS2_SYSTEM_EVENT_HANDLE, flags);
|
||||
osEventFlagsSet(STA_RTOS_SYSTEM_EVENT_HANDLE, flags);
|
||||
}
|
||||
|
||||
void waitForSystemEvents(uint32_t flags, uint32_t options, uint32_t timeout)
|
||||
{
|
||||
osEventFlagsWait(STA_RTOS2_SYSTEM_EVENT_HANDLE, flags, options | osFlagsNoClear, timeout);
|
||||
osEventFlagsWait(STA_RTOS_SYSTEM_EVENT_HANDLE, flags, options | osFlagsNoClear, timeout);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@ namespace sta
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_RTOS2_SYSTEM_EVENT_ENABLE
|
||||
#endif // STA_RTOS_SYSTEM_EVENT_ENABLE
|
@@ -1,19 +1,19 @@
|
||||
#include <sta/rtos2/watchdog.hpp>
|
||||
#include <sta/rtos/watchdog.hpp>
|
||||
|
||||
#ifdef STA_RTOS2_WATCHDOG_ENABLE
|
||||
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
|
||||
// Access handles from freertos.c
|
||||
extern osTimerId_t STA_RTOS2_WATCHDOG_TIMER_HANDLE;
|
||||
extern osTimerId_t STA_RTOS_WATCHDOG_TIMER_HANDLE;
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void startWatchdogTimer()
|
||||
{
|
||||
osTimerStart(STA_RTOS2_WATCHDOG_TIMER_HANDLE, STA_RTOS2_WATCHDOG_TIMER_PERIOD);
|
||||
osTimerStart(STA_RTOS_WATCHDOG_TIMER_HANDLE, STA_RTOS_WATCHDOG_TIMER_PERIOD);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace sta
|
||||
// Declare with C linkage
|
||||
extern "C"
|
||||
{
|
||||
void STA_RTOS2_WATCHDOG_TIMER_CALLBACK(void *)
|
||||
void STA_RTOS_WATCHDOG_TIMER_CALLBACK(void *)
|
||||
{
|
||||
// Notify watchdog task to send heartbeat message
|
||||
// Required because blocking in a timer callback is not allowed
|
||||
@@ -30,4 +30,4 @@ extern "C"
|
||||
}
|
||||
|
||||
|
||||
#endif // STA_RTOS2_WATCHDOG_ENABLE
|
||||
#endif // STA_RTOS_WATCHDOG_ENABLE
|
45
src/rtos/watchdog/watchdog.cpp
Normal file
45
src/rtos/watchdog/watchdog.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <sta/rtos/watchdog.hpp>
|
||||
|
||||
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
||||
|
||||
#include <sta/rtos/defs.hpp>
|
||||
#include <sta/rtos/system_event.hpp>
|
||||
|
||||
#include <main.h>
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
|
||||
// Access handle from freertos.c
|
||||
extern osThreadId_t STA_RTOS_WATCHDOG_HANDLE;
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void notifyWatchdog(uint32_t flags)
|
||||
{
|
||||
osThreadFlagsSet(STA_RTOS_WATCHDOG_HANDLE, flags);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
// Declare with C linkage
|
||||
extern "C"
|
||||
{
|
||||
void STA_RTOS_WATCHDOG_ENTRY_FUNCTION(void * arg)
|
||||
{
|
||||
sta::waitForStartupEvent();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Wait for any flag to be set
|
||||
uint32_t flags = osThreadFlagsWait(STA_RTOS_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, osWaitForever);
|
||||
|
||||
// Call event handler
|
||||
sta::watchdogEventHandler(arg, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // STA_RTOS_WATCHDOG_ENABLE
|
@@ -1,45 +0,0 @@
|
||||
#include <sta/rtos2/watchdog.hpp>
|
||||
|
||||
#ifdef STA_RTOS2_WATCHDOG_ENABLE
|
||||
|
||||
#include <sta/rtos2/defs.hpp>
|
||||
#include <sta/rtos2/system_event.hpp>
|
||||
|
||||
#include <main.h>
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
|
||||
// Access handle from freertos.c
|
||||
extern osThreadId_t STA_RTOS2_WATCHDOG_HANDLE;
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void notifyWatchdog(uint32_t flags)
|
||||
{
|
||||
osThreadFlagsSet(STA_RTOS2_WATCHDOG_HANDLE, flags);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
// Declare with C linkage
|
||||
extern "C"
|
||||
{
|
||||
void STA_RTOS2_WATCHDOG_ENTRY_FUNCTION(void * arg)
|
||||
{
|
||||
sta::waitForStartupEvent();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Wait for any flag to be set
|
||||
uint32_t flags = osThreadFlagsWait(STA_RTOS2_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, osWaitForever);
|
||||
|
||||
// Call event handler
|
||||
sta::watchdogEventHandler(arg, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // STA_RTOS2_WATCHDOG_ENABLE
|
Reference in New Issue
Block a user