From fa3f420fa6f9dae5a9da16ba4870f3ee3f913cfa Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Sun, 3 Nov 2024 12:42:37 +0100 Subject: [PATCH 1/3] gitignore: ds_store --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 64dcbf5..3c4eb09 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ docs/latex # Config include/sta/config.hpp +# Mac OS X +.DS_Store From 4ac600d2b7bf2d113f3bf4e2be6f7b2d6f4b0d7e Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Sun, 3 Nov 2024 12:43:46 +0100 Subject: [PATCH 2/3] refactor: moved startup from rtos2-utils to TACOS --- README.md | 6 ++--- include/sta/tacos/c_api/startup.h | 22 +++++++++++++++++ src/startup.cpp | 40 +++++++++++++++++++++++++------ 3 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 include/sta/tacos/c_api/startup.h diff --git a/README.md b/README.md index 5fec4c4..0a16532 100644 --- a/README.md +++ b/README.md @@ -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(;;) diff --git a/include/sta/tacos/c_api/startup.h b/include/sta/tacos/c_api/startup.h new file mode 100644 index 0000000..3876718 --- /dev/null +++ b/include/sta/tacos/c_api/startup.h @@ -0,0 +1,22 @@ +#ifndef STA_TACOS_C_API_STARTUP_H +#define STA_TACOS_C_API_STARTUP_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief + * + * @param arg Default task argument + */ +void startTACOS(void * arg); + + +#ifdef __cplusplus +} +#endif + + +#endif // STA_TACOS_C_API_STARTUP_H diff --git a/src/startup.cpp b/src/startup.cpp index 6934df5..0f450f5 100644 --- a/src/startup.cpp +++ b/src/startup.cpp @@ -21,11 +21,18 @@ // sta-core-specific imports. #include +#include #include #include +#include #include +// rtos2-utils-specific includes. +#include +#include + // Tacos-specific includes. +#include #include #include #include @@ -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(); + } +} From 344ef03f4a1ffa68d4c86457d2b0aefa63f3ceac Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Fri, 8 Nov 2024 19:10:14 +0100 Subject: [PATCH 3/3] doc: Amended documentation for startTACOS --- include/sta/tacos/c_api/startup.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sta/tacos/c_api/startup.h b/include/sta/tacos/c_api/startup.h index 3876718..5c33fac 100644 --- a/include/sta/tacos/c_api/startup.h +++ b/include/sta/tacos/c_api/startup.h @@ -7,9 +7,9 @@ extern "C" { /** - * @brief + * @brief Entry point for TACOS. Initializes all activated features and starts associated tasks. * - * @param arg Default task argument + * @param arg Passed on default task argument */ void startTACOS(void * arg);