Add rtos namespace

This commit is contained in:
Henrik Stickann 2022-05-24 14:37:00 +02:00
parent 9c4f2d1927
commit cf30f8f793
7 changed files with 121 additions and 100 deletions

View File

@ -53,6 +53,8 @@
namespace sta namespace sta
{
namespace rtos
{ {
/** /**
* @brief Extra initialization run at start of startup task. * @brief Extra initialization run at start of startup task.
@ -62,6 +64,7 @@ namespace sta
* @ingroup STA_RTOS_Startup * @ingroup STA_RTOS_Startup
*/ */
void startupExtras(void * argument); void startupExtras(void * argument);
} // namespace rtos
} // namespace sta } // namespace sta

View File

@ -55,6 +55,8 @@
namespace sta namespace sta
{
namespace rtos
{ {
/** /**
* @brief Signal system events. * @brief Signal system events.
@ -92,6 +94,7 @@ namespace sta
* @ingroup STA_RTOS_SysEvent * @ingroup STA_RTOS_SysEvent
*/ */
void waitForStartupEvent(); void waitForStartupEvent();
} // namespace rtos
} // namespace sta } // namespace sta

View File

@ -107,6 +107,8 @@
namespace sta namespace sta
{
namespace rtos
{ {
/** /**
* @brief Start heartbeat timer for watchdog. * @brief Start heartbeat timer for watchdog.
@ -133,6 +135,7 @@ namespace sta
* @ingroup STA_RTOS_Watchdog * @ingroup STA_RTOS_Watchdog
*/ */
void watchdogEventHandler(void * arg, uint32_t flags); void watchdogEventHandler(void * arg, uint32_t flags);
} // namespace rtos
} // namespace sta } // namespace sta

View File

@ -10,11 +10,14 @@
namespace sta namespace sta
{
namespace rtos
{ {
// Provide weak implementation to allow overriding // Provide weak implementation to allow overriding
STA_WEAK STA_WEAK
void startupExtras(void *) void startupExtras(void *)
{} {}
} // namespace rtos
} // namespace sta } // namespace sta
@ -24,20 +27,20 @@ extern "C"
void STA_RTOS_STARTUP_ENTRY_FUNCTION(void * arg) void STA_RTOS_STARTUP_ENTRY_FUNCTION(void * arg)
{ {
// Call further initialization code // Call further initialization code
sta::startupExtras(arg); sta::rtos::startupExtras(arg);
// Initialize HAL // Initialize HAL
sta::initHAL(); sta::initHAL();
#ifdef STA_RTOS_WATCHDOG_ENABLE #ifdef STA_RTOS_WATCHDOG_ENABLE
// Start timers // Start timers
sta::startWatchdogTimer(); sta::rtos::startWatchdogTimer();
#endif // STA_RTOS_WATCHDOG_ENABLE #endif // STA_RTOS_WATCHDOG_ENABLE
// Wake tasks // Wake threads
sta::signalStartupEvent(); sta::rtos::signalStartupEvent();
// Terminate task // Terminate thread
osThreadExit(); osThreadExit();
} }
} }

View File

@ -13,6 +13,8 @@ extern osEventFlagsId_t STA_RTOS_SYSTEM_EVENT_HANDLE;
namespace sta namespace sta
{
namespace rtos
{ {
void signalSystemEvents(uint32_t flags) void signalSystemEvents(uint32_t flags)
{ {
@ -34,6 +36,7 @@ namespace sta
{ {
waitForSystemEvents(STA_SYSTEM_EVENT_STARTUP, osFlagsWaitAll, osWaitForever); waitForSystemEvents(STA_SYSTEM_EVENT_STARTUP, osFlagsWaitAll, osWaitForever);
} }
} // namespace rtos
} // namespace sta } // namespace sta

View File

@ -6,11 +6,14 @@
namespace sta namespace sta
{
namespace rtos
{ {
void startWatchdogTimer() void startWatchdogTimer()
{ {
osTimerStart(WATCHDOG_TIMER_HANDLE, STA_RTOS_WATCHDOG_TIMER_PERIOD); osTimerStart(WATCHDOG_TIMER_HANDLE, STA_RTOS_WATCHDOG_TIMER_PERIOD);
} }
} // namespace rtos
} // namespace sta } // namespace sta

View File

@ -10,11 +10,14 @@
namespace sta namespace sta
{
namespace rtos
{ {
void notifyWatchdog(uint32_t flags) void notifyWatchdog(uint32_t flags)
{ {
osThreadFlagsSet(WATCHDOG_TASK_HANDLE, flags); osThreadFlagsSet(WATCHDOG_TASK_HANDLE, flags);
} }
} // namespace rtos
} // namespace sta } // namespace sta
@ -23,7 +26,7 @@ extern "C"
{ {
void STA_RTOS_WATCHDOG_ENTRY_FUNCTION(void * arg) void STA_RTOS_WATCHDOG_ENTRY_FUNCTION(void * arg)
{ {
sta::waitForStartupEvent(); sta::rtos::waitForStartupEvent();
while (true) while (true)
{ {
@ -31,7 +34,7 @@ extern "C"
uint32_t flags = osThreadFlagsWait(STA_RTOS_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, osWaitForever); uint32_t flags = osThreadFlagsWait(STA_RTOS_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, osWaitForever);
// Call event handler // Call event handler
sta::watchdogEventHandler(arg, flags); sta::rtos::watchdogEventHandler(arg, flags);
} }
} }
} }