TACOS/README.md
2023-12-21 13:50:23 +00:00

2.9 KiB

TACOS

This is the Trajectory Analysis Control OS (TACOS) that serves as a starting point for developing TACOS-based projects, by implementing threads in the App directory. TACOS is a subset of the features provided by ALPAKA. In particular, TACOS consists of the STM32-specific components of sta-core, rtos-2 and rtos2-utils.

Setting Up TACOS

Add this as a library an existing CubeIDE project using FreeRTOS. Generally, we advise you to add it as a submodule. Make sure that you add the include paths for Tacos, i.e. sta-core and rtos2-utils, to the project with the following steps:

Properties -> C/C++ General -> Paths and Symbols -> Includes -> GNU C -> Add... 
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:

void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN StartDefaultTask */
	extern void startALPAKA(void *);
	startALPAKA(argument);

  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END StartDefaultTask */
}

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:

#ifndef INC_STA_CONFIG_HPP_
#define INC_STA_CONFIG_HPP_

// Use the STM32F411 microprocessor.
#include <sta/devices/stm32/mcu/STM32F411xE.hpp>

// Doesn't really do too much right now. Has to be added for successful compilation.
#define STA_PRINTF_USE_STDLIB

// Enable debug serial output and assertions.
#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

#endif /* INC_STA_CONFIG_HPP_ */

PS: For not officially supported chips use this as the include:

#include <sta/devices/stm32/mcu/common.hpp>
#define STA_MCU_LITTLE_ENDIAN
#define STA_PLATFORM_STM32