mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-06-10 16:45:59 +00:00
refactor: moved startup from rtos2-utils to TACOS
This commit is contained in:
parent
cf09e7beb1
commit
f0c5faf29e
@ -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...
|
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)
|
void StartDefaultTask(void *argument)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN StartDefaultTask */
|
/* USER CODE BEGIN StartDefaultTask */
|
||||||
extern void startALPAKA(void *);
|
extern void startTACOS(void *);
|
||||||
startALPAKA(argument);
|
startTACOS(argument);
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
|
22
include/sta/tacos/c_api/startup.h
Normal file
22
include/sta/tacos/c_api/startup.h
Normal 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
|
||||||
|
*
|
||||||
|
* @param arg Default task argument
|
||||||
|
*/
|
||||||
|
void startTACOS(void * arg);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // STA_TACOS_C_API_STARTUP_H
|
@ -21,11 +21,18 @@
|
|||||||
|
|
||||||
// sta-core-specific imports.
|
// sta-core-specific imports.
|
||||||
#include <sta/devices/stm32/bus/uart.hpp>
|
#include <sta/devices/stm32/bus/uart.hpp>
|
||||||
|
#include <sta/devices/stm32/init.hpp>
|
||||||
#include <sta/debug/printing/printable_uart.hpp>
|
#include <sta/debug/printing/printable_uart.hpp>
|
||||||
#include <sta/debug/debug.hpp>
|
#include <sta/debug/debug.hpp>
|
||||||
|
#include <sta/debug/assert.hpp>
|
||||||
#include <sta/lang.hpp>
|
#include <sta/lang.hpp>
|
||||||
|
|
||||||
|
// rtos2-utils-specific includes.
|
||||||
|
#include <sta/rtos/system/startup.hpp>
|
||||||
|
#include <sta/rtos/system/events.hpp>
|
||||||
|
|
||||||
// Tacos-specific includes.
|
// Tacos-specific includes.
|
||||||
|
#include <sta/tacos/c_api/startup.h>
|
||||||
#include <sta/tacos/manager.hpp>
|
#include <sta/tacos/manager.hpp>
|
||||||
#include <sta/tacos/statemachine.hpp>
|
#include <sta/tacos/statemachine.hpp>
|
||||||
#include <sta/tacos/watchdog.hpp>
|
#include <sta/tacos/watchdog.hpp>
|
||||||
@ -72,7 +79,7 @@ namespace sta
|
|||||||
STM32UART * intf_ptr = new STM32UART(getUARThandle(), settings, mutex);
|
STM32UART * intf_ptr = new STM32UART(getUARThandle(), settings, mutex);
|
||||||
Debug = new PrintableUART(intf_ptr);
|
Debug = new PrintableUART(intf_ptr);
|
||||||
}
|
}
|
||||||
}
|
} // namespace tacos
|
||||||
#endif // STA_DEBUGGING_ENABLED
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
namespace tacos
|
namespace tacos
|
||||||
@ -142,12 +149,7 @@ namespace sta
|
|||||||
CanBus::instance()->start();
|
CanBus::instance()->start();
|
||||||
}
|
}
|
||||||
#endif //STA_TACOS_CAN_BUS_ENABLED
|
#endif //STA_TACOS_CAN_BUS_ENABLED
|
||||||
} // namespace tacos
|
|
||||||
|
|
||||||
|
|
||||||
namespace rtos
|
|
||||||
{
|
|
||||||
// Override the weak implementation of startupExtras provided in rtos2-utils.
|
|
||||||
void startupExtras(void * argument)
|
void startupExtras(void * argument)
|
||||||
{
|
{
|
||||||
#ifdef STA_DEBUGGING_ENABLED
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
@ -166,7 +168,31 @@ namespace sta
|
|||||||
tacos::initCanBus();
|
tacos::initCanBus();
|
||||||
#endif // STA_TACOS_CAN_BUS_ENABLED
|
#endif // STA_TACOS_CAN_BUS_ENABLED
|
||||||
}
|
}
|
||||||
} // namespace rtos
|
} // namespace tacos
|
||||||
} // namespace sta
|
} // 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user