mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 11:07:34 +00:00
Simplify startup API
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include <sta/rtos/system/startup.hpp>
|
||||
#ifdef STA_RTOS_STARTUP_ENABLE
|
||||
|
||||
#include <sta/rtos/c_api/startup.h>
|
||||
|
||||
#include <sta/assert.hpp>
|
||||
#include <sta/lang.hpp>
|
||||
#include <sta/rtos/system/can_bus.hpp>
|
||||
#include <sta/rtos/system/system_event.hpp>
|
||||
#include <sta/rtos/system/watchdog.hpp>
|
||||
#include <sta/stm32/init.hpp>
|
||||
@@ -17,33 +20,46 @@ namespace sta
|
||||
STA_WEAK
|
||||
void startupExtras(void *)
|
||||
{}
|
||||
|
||||
|
||||
void initSystem()
|
||||
{
|
||||
#ifdef STA_RTOS_SYSTEM_EVENTS_ENABLE
|
||||
initSystemEvents();
|
||||
#endif // STA_RTOS_SYSTEM_EVENTS_ENABLE
|
||||
|
||||
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
||||
initWatchdog();
|
||||
#endif // STA_RTOS_WATCHDOG_ENABLE
|
||||
|
||||
#ifdef STA_RTOS_CAN_BUS_ENABLE
|
||||
initCanBus();
|
||||
#endif // STA_RTOS_CAN_BUS_ENABLE
|
||||
}
|
||||
} // namespace rtos
|
||||
} // namespace sta
|
||||
|
||||
|
||||
// Declare with C linkage
|
||||
extern "C"
|
||||
void startALPAKA(void * arg)
|
||||
{
|
||||
void STA_RTOS_STARTUP_ENTRY_FUNCTION(void * arg)
|
||||
STA_ASSERT_MSG(osKernelGetState() != osKernelInactive, "Cannot call startALPAKA() before osKernelInitialize()");
|
||||
|
||||
// Call further initialization code
|
||||
sta::rtos::startupExtras(arg);
|
||||
|
||||
// Initialize HAL
|
||||
sta::initHAL();
|
||||
|
||||
// Initialize RTOS system resources
|
||||
sta::rtos::initSystem();
|
||||
|
||||
// Wake threads
|
||||
sta::rtos::signalStartupEvent();
|
||||
|
||||
// Check if called from thread
|
||||
if (osThreadGetId() != nullptr)
|
||||
{
|
||||
// Call further initialization code
|
||||
sta::rtos::startupExtras(arg);
|
||||
|
||||
// Initialize HAL
|
||||
sta::initHAL();
|
||||
|
||||
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
||||
// Start timers
|
||||
sta::rtos::startWatchdogTimer();
|
||||
#endif // STA_RTOS_WATCHDOG_ENABLE
|
||||
|
||||
// Wake threads
|
||||
sta::rtos::signalStartupEvent();
|
||||
|
||||
// Terminate thread
|
||||
// Terminate current thread
|
||||
osThreadExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // STA_RTOS_STARTUP_ENABLE
|
||||
|
Reference in New Issue
Block a user