Merge branch 'feat/documentation' of ssh://git.intern.spaceteamaachen.de:22222/ALPAKA/TACOS into feat/documentation

This commit is contained in:
dario 2024-12-01 13:18:12 +01:00
commit 58721422b6

View File

@ -45,15 +45,18 @@ git submodule add https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
``` ```
Make sure that you add the include paths for TACOS, sta-core and rtos2-utils to the project with the following steps: Make sure that you add the include paths for TACOS, sta-core and rtos2-utils to the project with the following steps:
1. `Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C -> Add...` 1. Right click your project in the `Project Explorer` and select `Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C -> Add...`
2. Select `Add to all languages` and `Is a workspace path` 2. Select `Add to all languages` and `Is a workspace path`
3. Click on `Workspace` and select a folder from the `YOUR_PROJECT_FOLDER/(Libs|App)` directory 3. Click on `Workspace` and select a folder from the `YOUR_PROJECT_FOLDER/(Libs|App)` directory
- Always select the `include` or `Inc` folder for the include paths - Always select the `include` or `Inc` folder for the include paths
- If the path you want to add is not in the list, refresh the project with `F5` in the `Project Explorer` and try again - If the path you want to add is not in the list, refresh the project with `F5` in the `Project Explorer` and try again
4. Repeat for TACOS, sta-core, rtos2-utils and the App folder 4. Repeat for TACOS, sta-core, rtos2-utils and the App folder
5. `Properties -> C/C++ General -> Paths and Symbols -> Source Location -> Add Folder...` 5. Right click your project in the `Project Explorer` and select `Properties -> C/C++ General -> Paths and Symbols -> Source Location -> Add Folder...`
- Add the `App` and `Libs` folders - Add the `App` and `Libs` folders
> [!NOTE]
> You often want to add more submodules during development. Here, a faster way to add the include path for a library is to right click the library's include folder in the `Project Explorer` and select `Add/remove include path`.
### Starting TACOS ### Starting TACOS
Navigate to the `Core/Src/freertos.c` file and add the following code to the `StartDefaultTask` function: Navigate to the `Core/Src/freertos.c` file and add the following code to the `StartDefaultTask` function:
@ -90,17 +93,12 @@ In order to use TACOS, you need to provide a configuration file in the path `sta
#define STA_PRINTF_USE_STDLIB #define STA_PRINTF_USE_STDLIB
// Enable debug serial output and assertions. // Enable debug serial output and assertions.
#define STA_ASSERT_FORCE #define STA_ASSERT_ENABLED
#define STA_DEBUGGING_ENABLED #define STA_DEBUGGING_ENABLED
// Enable Features // Enable Features
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
// #define STA_RTOS_SYSTEM_WATCHDOG_ENABLE
// #define STA_RTOS_WATCHDOG_ENABLE
// #define STA_TACOS_WATCHDOG_FREQUENCY 10000
#define STA_CAN_BUS_ENABLE
// Statemachine settings. // Statemachine settings. How many states does your statemachine have?
#define STA_TACOS_NUM_STATES 3 #define STA_TACOS_NUM_STATES 3
// Uses the default configuration for TACOS. // Uses the default configuration for TACOS.
@ -162,6 +160,9 @@ namespace tasks {
} // namespace tasks } // namespace tasks
``` ```
> [!WARNING]
> A thread's priority must be strictly lower than the statemachine's priority. Unless manually changed, this is always `osPriorityHigh`.
To start this thread, we first need to fill out the `startup.cpp` file. This file may look like this: To start this thread, we first need to fill out the `startup.cpp` file. This file may look like this:
```cpp ```cpp
#include <sta/tacos.hpp> #include <sta/tacos.hpp>
@ -173,11 +174,11 @@ namespace sta
{ {
namespace tacos namespace tacos
{ {
void onStatemachineInit() void startup()
{ {
// ###### Register different threads for different states here. ###### // ###### Register different threads for different states here. ######
// Register a "Spam Task" thread for all states except 1 and 2. // Register a "Spam Task" thread for all states except 1 and 2.
sta::tacos::addThread<tasks::SpamTask>(ALL_STATES - state_set{1,2}); sta::tacos::addThread<tasks::SpamTask>(ALL_STATES - state_set{1,2});
STA_DEBUG_PRINTF("The answer to everything is %d", 42); STA_DEBUG_PRINTF("The answer to everything is %d", 42);
} }
@ -185,6 +186,8 @@ namespace sta
} // namespace sta } // namespace sta
``` ```
The function `startup()` is a weakly implemented function that is executed right before TACOS initializes its statemachine task. It serves as an entry point for the user to initialize all busses, threads and rtos2-utils stuff that is needed for the application to fulfill its purpose.
And that's it! Now you have a thread that prints "Hello World" every second. Simply build the project and flash it to your microcontroller and be amazed by the Spam! And that's it! Now you have a thread that prints "Hello World" every second. Simply build the project and flash it to your microcontroller and be amazed by the Spam!
### Setting up the CAN Bus ### Setting up the CAN Bus