Merge pull request 'Moved startup code from rtos2-utils to TACOS' (#40) from refactor/startup into main

Reviewed-on: https://git.intern.spaceteamaachen.de/ALPAKA/TACOS/pulls/40
Reviewed-by: dario <dario@noreply.git.intern.spaceteamaachen.de>
This commit is contained in:
dario 2024-11-09 08:02:35 +00:00
commit b39a2a9027
4 changed files with 60 additions and 10 deletions

2
.gitignore vendored
View File

@ -16,3 +16,5 @@ docs/latex
# Config
include/sta/config.hpp
# Mac OS X
.DS_Store

View File

@ -11,13 +11,13 @@ Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C++ -> Add..
Properties -> C/C++ General -> Paths and Symbols -> Source Location -> Add Folder...
```
Create a new thread via the project's IOC and call `startALPAKA()` from this thread. If your thread is called `defaultTask`, the corresponding function `StartDefaultTask` generated in `Core/Src/freertos.c` should look like this:
Create a new thread via the project's IOC and call `startTACOS()` from this thread. If your thread is called `defaultTask`, the corresponding function `StartDefaultTask` generated in `Core/Src/freertos.c` should look like this:
```
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN StartDefaultTask */
extern void startALPAKA(void *);
startALPAKA(argument);
extern void startTACOS(void *);
startTACOS(argument);
/* Infinite loop */
for(;;)

View File

@ -0,0 +1,22 @@
#ifndef STA_TACOS_C_API_STARTUP_H
#define STA_TACOS_C_API_STARTUP_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Entry point for TACOS. Initializes all activated features and starts associated tasks.
*
* @param arg Passed on default task argument
*/
void startTACOS(void * arg);
#ifdef __cplusplus
}
#endif
#endif // STA_TACOS_C_API_STARTUP_H

View File

@ -21,11 +21,18 @@
// sta-core-specific imports.
#include <sta/devices/stm32/bus/uart.hpp>
#include <sta/devices/stm32/init.hpp>
#include <sta/debug/printing/printable_uart.hpp>
#include <sta/debug/debug.hpp>
#include <sta/debug/assert.hpp>
#include <sta/lang.hpp>
// rtos2-utils-specific includes.
#include <sta/rtos/system/startup.hpp>
#include <sta/rtos/system/events.hpp>
// Tacos-specific includes.
#include <sta/tacos/c_api/startup.h>
#include <sta/tacos/manager.hpp>
#include <sta/tacos/statemachine.hpp>
#include <sta/tacos/watchdog.hpp>
@ -72,7 +79,7 @@ namespace sta
STM32UART * intf_ptr = new STM32UART(getUARThandle(), settings, mutex);
Debug = new PrintableUART(intf_ptr);
}
}
} // namespace tacos
#endif // STA_DEBUGGING_ENABLED
namespace tacos
@ -142,12 +149,7 @@ namespace sta
CanBus::instance()->start();
}
#endif //STA_TACOS_CAN_BUS_ENABLED
} // namespace tacos
namespace rtos
{
// Override the weak implementation of startupExtras provided in rtos2-utils.
void startupExtras(void * argument)
{
#ifdef STA_DEBUGGING_ENABLED
@ -166,7 +168,31 @@ namespace sta
tacos::initCanBus();
#endif // STA_TACOS_CAN_BUS_ENABLED
}
} // namespace rtos
} // namespace tacos
} // namespace sta
void startTACOS(void * arg)
{
STA_ASSERT_MSG(osKernelGetState() != osKernelInactive, "Cannot call startTACOS() before osKernelInitialize()");
// Initialize HAL
sta::initHAL();
// Initialize RTOS system resources
sta::rtos::initSystem();
// Call further initialization code
sta::tacos::startupExtras(arg);
// Wake threads
#ifdef STA_RTOS_SYSTEM_EVENTS_ENABLE
sta::rtos::signalStartupEvent();
#endif // STA_RTOS_SYSTEM_EVENTS_ENABLE
// Check if called from thread
if (osThreadGetId() != nullptr)
{
// Terminate current thread
osThreadExit();
}
}