mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 09:37:34 +00:00
Added reworked manager / statemachine tasks, thread implementation and new directory layout
This commit is contained in:
@@ -6,42 +6,70 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <sta/debug/debug.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
#include <FreeRTOS.h>
|
||||
|
||||
#include <sta/debug/debug.hpp>
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
#include <sta/rtos/system/events.hpp>
|
||||
|
||||
#include <tasks/statemachine.hpp>
|
||||
|
||||
#define STATE_CHANGED_MSK 0x01
|
||||
#define STATE_CHANGED_TIMOUT_MSK 0x02
|
||||
|
||||
// The state changed event defined somewhere else.
|
||||
extern osEventFlagsId_t stateChangeEvent_id;
|
||||
namespace tacos
|
||||
{
|
||||
|
||||
// The data structure representing a TACOS task.
|
||||
struct tacos_task_t
|
||||
{
|
||||
// The code to be executed for this task.
|
||||
osThreadFunc_t func;
|
||||
|
||||
// The attributes for the task.
|
||||
osThreadAttr_t attribs;
|
||||
|
||||
// A list of currently running instances of this task.
|
||||
std::list<osThreadId_t> running;
|
||||
|
||||
// A list of states for which this task should be running.
|
||||
std::list<tacos_states_t> states;
|
||||
};
|
||||
|
||||
|
||||
} // namespace tacos
|
||||
|
||||
|
||||
// The current state defined somewhere else.
|
||||
extern tacos_states_t currentState;
|
||||
|
||||
|
||||
// The data structure representing a TACOS task.
|
||||
struct tacos_task_t
|
||||
extern "C"
|
||||
{
|
||||
// The code to be executed for this task.
|
||||
osThreadFunc_t func;
|
||||
void managerTask(void *)
|
||||
{
|
||||
STA_DEBUG_PRINTLN("INITIALIZED MANAGER TASK");
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Wait until the state machine triggers an event signaling a state-change.
|
||||
uint32_t flags = osEventFlagsWait(stateChangeEvent_id, STATE_CHANGED_MSK, osFlagsWaitAll, osWaitForever);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// The attributes for the task.
|
||||
osThreadAttr_t attribs;
|
||||
|
||||
// A list of currently running instances of this task.
|
||||
std::list<osThreadId_t> running;
|
||||
|
||||
// A list of states for which this task should be running.
|
||||
std::list<tacos_states_t> states;
|
||||
};
|
||||
|
||||
std::list<tacos_task_t> tasks;
|
||||
|
||||
@@ -111,12 +139,12 @@ extern "C" void startManagerTask(void *)
|
||||
{
|
||||
if (!task.running.empty())
|
||||
{
|
||||
osThreadCreate(thread_def, argument);
|
||||
osThreadDef (task.attribs.name, task.attribs.priority, 1, 0);
|
||||
|
||||
osThreadCreate(osTh, argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STA_DEBUG_PRINTLN("STARTING NEW TASKS DUE TO STATE CHANGE!");
|
||||
}
|
||||
|
||||
osThreadExit();
|
||||
|
@@ -46,8 +46,8 @@ void changeState(uint8_t flag)
|
||||
osEventFlagsSet(stateChangeEvent_id, flag);
|
||||
osEventFlagsClear(stateChangeEvent_id, TACOS_STATE_CHG_ALL);
|
||||
|
||||
uint8_t lockoutCycles = 0;
|
||||
uint8_t failsafeCycles = 0;
|
||||
uint32_t lockoutCycles = 0;
|
||||
uint32_t failsafeCycles = 0;
|
||||
|
||||
switch (currentState) {
|
||||
case tacos_states_t::init:
|
||||
|
Reference in New Issue
Block a user