mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-12 02:36:00 +00:00
Simplify startup API
This commit is contained in:
parent
cccf24ae59
commit
aeb472fd03
@ -5,8 +5,6 @@
|
|||||||
#ifndef STA_RTOS_SYSTEM_STARTUP_HPP
|
#ifndef STA_RTOS_SYSTEM_STARTUP_HPP
|
||||||
#define STA_RTOS_SYSTEM_STARTUP_HPP
|
#define STA_RTOS_SYSTEM_STARTUP_HPP
|
||||||
|
|
||||||
#include <sta/rtos/system/names.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup STA_RTOS_Startup Startup task
|
* @defgroup STA_RTOS_Startup Startup task
|
||||||
@ -17,41 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef DOXYGEN
|
|
||||||
/**
|
|
||||||
* @brief Enable module.
|
|
||||||
*
|
|
||||||
* @ingroup STA_RTOS_BuildConfig
|
|
||||||
*/
|
|
||||||
# define STA_RTOS_STARTUP_ENABLE
|
|
||||||
#endif // DOXYGEN
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @def STA_RTOS_STARTUP_TASK_NAME
|
|
||||||
* @brief Set name of startup task.
|
|
||||||
*
|
|
||||||
* @ingroup STA_RTOS_BuildConfig
|
|
||||||
*/
|
|
||||||
#ifndef STA_RTOS_STARTUP_TASK_NAME
|
|
||||||
# define STA_RTOS_STARTUP_TASK_NAME startup
|
|
||||||
#endif // !STA_RTOS_STARTUP_TASK_NAME
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @def STA_RTOS_STARTUP_ENTRY_FUNCTION
|
|
||||||
* @brief Set name of startup task entry function.
|
|
||||||
*
|
|
||||||
* @ingroup STA_RTOS_BuildConfig
|
|
||||||
*/
|
|
||||||
#ifndef STA_RTOS_STARTUP_ENTRY_FUNCTION
|
|
||||||
# define STA_RTOS_STARTUP_ENTRY_FUNCTION STA_RTOS_MAKE_ENTRY_NAME(STA_RTOS_STARTUP_TASK_NAME)
|
|
||||||
#endif // !STA_RTOS_STARTUP_ENTRY_FUNCTION
|
|
||||||
|
|
||||||
|
|
||||||
#include <sta/config.hpp>
|
|
||||||
#ifdef STA_RTOS_STARTUP_ENABLE
|
|
||||||
|
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace rtos
|
namespace rtos
|
||||||
@ -68,6 +31,4 @@ namespace sta
|
|||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
#endif // STA_RTOS_STARTUP_ENABLE
|
|
||||||
|
|
||||||
#endif // STA_RTOS_SYSTEM_STARTUP_HPP
|
#endif // STA_RTOS_SYSTEM_STARTUP_HPP
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include <sta/rtos/system/startup.hpp>
|
#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/lang.hpp>
|
||||||
|
#include <sta/rtos/system/can_bus.hpp>
|
||||||
#include <sta/rtos/system/system_event.hpp>
|
#include <sta/rtos/system/system_event.hpp>
|
||||||
#include <sta/rtos/system/watchdog.hpp>
|
#include <sta/rtos/system/watchdog.hpp>
|
||||||
#include <sta/stm32/init.hpp>
|
#include <sta/stm32/init.hpp>
|
||||||
@ -17,33 +20,46 @@ namespace sta
|
|||||||
STA_WEAK
|
STA_WEAK
|
||||||
void startupExtras(void *)
|
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 rtos
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
// Declare with C linkage
|
void startALPAKA(void * arg)
|
||||||
extern "C"
|
|
||||||
{
|
{
|
||||||
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
|
// Terminate current thread
|
||||||
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
|
|
||||||
osThreadExit();
|
osThreadExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // STA_RTOS_STARTUP_ENABLE
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user