diff --git a/README.md b/README.md index 7611825..51cdb5b 100644 --- a/README.md +++ b/README.md @@ -28,26 +28,8 @@ void StartDefaultTask(void *argument) } ``` -Ebenfalls müssen noch diese Ergänzungen in `Core/Src/freertos.c` vorgenommen werden: -``` -/* Definitions for uartMutex */ -osMutexId_t uartMutexHandle; -osStaticMutexDef_t uartMutex_cb; -const osMutexAttr_t uartMutex_attributes = { - .name = "uartMutex", - .cb_mem = &uartMutex_cb, - .cb_size = sizeof(uartMutex_cb), -}; - - -void MX_FREERTOS_Init(void) { - uartMutexHandle = osMutexNew(&uartMutex_attributes); - //... -} -``` - ## Configuring TACOS -Be sure to add a "config.hpp" to the App/Inc/sta directory. This file could look like this: +In order to use TACOS, you need to provide a configuration file in the path `sta/config.hpp`. The following code is an example for a TACOS-project using default configuration: ``` #ifndef INC_STA_CONFIG_HPP_ #define INC_STA_CONFIG_HPP_ @@ -62,23 +44,13 @@ Be sure to add a "config.hpp" to the App/Inc/sta directory. This file could look #define STA_ASSERT_FORCE #define STA_DEBUGGING_ENABLED -// Activate the timer for microsecond delays. -// #define STA_STM32_DELAY_ENABLE -// #define STA_STM32_DELAY_US_TIM htim1 - // Settings for the rtos-utils #define STA_RTOS_SYSTEM_EVENTS_ENABLE // #define STA_RTOS_SYSTEM_WATCHDOG_ENABLE // #define STA_RTOS_WATCHDOG_ENABLE - -// Settings for TACOS -#define STA_TACOS_MANAGER_PRIORITY osPriorityNormal -#define STA_TACOS_STATEMACHINE_PRIORITY osPriorityNormal - -// Statemachine settings. Here, we only have a single state which is also the initial state. -#define STA_TACOS_NUM_STATES 3 -#define STA_TACOS_INITIAL_STATE 0 +// Uses the default configuration for TACOS. +#include #endif /* INC_STA_CONFIG_HPP_ */ ``` diff --git a/include/sta/tacos/configs/default.hpp b/include/sta/tacos/configs/default.hpp new file mode 100644 index 0000000..b68739b --- /dev/null +++ b/include/sta/tacos/configs/default.hpp @@ -0,0 +1,12 @@ +#ifndef STA_TACOS_CONFIGS_DEFAULT_HPP +#define STA_TACOS_CONFIGS_DEFAULT_HPP + +// Generally, we assume the TACOS threads to have the highest priorties. +#define STA_TACOS_MANAGER_PRIORITY osPriorityHigh +#define STA_TACOS_STATEMACHINE_PRIORITY osPriorityHigh +#define STA_TACOS_WATCHDOG_PRIORITY osPriorityHigh + +// Per default, we assume state 0 to be the initial state. +#define STA_TACOS_INITIAL_STATE 0 + +#endif // STA_TACOS_CONFIGS_DEFAULT_HPP \ No newline at end of file diff --git a/include/sta/tacos/startup.hpp b/include/sta/tacos/startup.hpp deleted file mode 100644 index c0edd90..0000000 --- a/include/sta/tacos/startup.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * startup.hpp - * - * Created on: 22 Sep 2023 - * Author: Dario - */ - -#ifndef INCLUDE_STA_TACOS_STARTUP_HPP_ -#define INCLUDE_STA_TACOS_STARTUP_HPP_ - -/** - * @defgroup tacos TACOS - * @brief TACOS library. - */ - -namespace sta -{ - namespace tacos - { - /** - * @brief Function that is called before the statemachine task is started. - * Override it to adjust the statemachine to your specifications. - */ - void onStatemachineInit(); - - /** - * @brief Function that is called before the manager task is started. - * Override it to adjust the manager to your specifications. - */ - void onManagerInit(); - } // namespace tacos -} // namespace sta - - - -#endif /* INCLUDE_STA_TACOS_STARTUP_HPP_ */ diff --git a/src/startup.cpp b/src/startup.cpp index 1a9e4fb..6550cc1 100644 --- a/src/startup.cpp +++ b/src/startup.cpp @@ -5,6 +5,13 @@ * Author: Dario */ +/** + * @defgroup tacos + * @brief TACOS library. + */ + + +#include #include #include @@ -19,7 +26,6 @@ // Tacos-specific includes. #include #include -#include // The UART mutex defined in freertos.c @@ -28,15 +34,16 @@ extern osMutexId_t uartMutexHandle; namespace sta { +#ifdef STA_DEBUGGING_ENABLED // Here the printable used for debugging is defined. Printable * Debug; - namespace tacos + namespace tacos { void initPrintable() { // Initialize the mutex for UART communication. - RtosMutex * mutex = new RtosMutex(&uartMutexHandle); + RtosMutex * mutex = new RtosMutex("uart"); // Initialize the UART interface and printable object. UARTSettings settings = { .mode = UARTMode::RX_TX }; @@ -45,13 +52,19 @@ namespace sta STA_DEBUG_PRINTLN("UART SUCCESSFULLY INITIALIZED"); } + } +#endif // STA_DEBUGGING_ENABLED - + namespace tacos + { + /** + * @brief Function that is called before the statemachine task is started. Override it to + * adjust the statemachine to your specifications. + */ STA_WEAK void onStatemachineInit() {} - void initStatemachine() { onStatemachineInit(); @@ -59,12 +72,14 @@ namespace sta Statemachine::instance()->start(); } - + /** + * @brief Function that is called before the manager task is started. Override it to adjust + * the manager to your specifications. + */ STA_WEAK void onManagerInit() {} - void initManager() { onManagerInit(); @@ -79,7 +94,9 @@ namespace sta // Override the weak implementation of startupExtras provided in rtos2-utils. void startupExtras(void * argument) { +#ifdef STA_DEBUGGING_ENABLED tacos::initPrintable(); +#endif // STA_DEBUGGING_ENABLED tacos::initStatemachine();