mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-06-12 01:25:59 +00:00
Added first successful test for statemachine rework
This commit is contained in:
parent
59b1005590
commit
5217945c03
@ -33,7 +33,7 @@
|
|||||||
#define STA_TACOS_STATEMACHINE_PRIORITY osPriorityNormal
|
#define STA_TACOS_STATEMACHINE_PRIORITY osPriorityNormal
|
||||||
|
|
||||||
// Statemachine settings. Here, we only have a single state which is also the initial state.
|
// Statemachine settings. Here, we only have a single state which is also the initial state.
|
||||||
#define STA_TACOS_NUM_STATES 1
|
#define STA_TACOS_NUM_STATES 2
|
||||||
#define STA_TACOS_INITIAL_STATE 0
|
#define STA_TACOS_INITIAL_STATE 0
|
||||||
|
|
||||||
#endif /* INC_STA_CONFIG_HPP_ */
|
#endif /* INC_STA_CONFIG_HPP_ */
|
||||||
|
26
App/Inc/tasks/toggle.hpp
Normal file
26
App/Inc/tasks/toggle.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* toggle.hpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 10, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_STA_TOGGLE_HPP_
|
||||||
|
#define INC_STA_TOGGLE_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos/thread.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
class Toggle : public sta::tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Toggle();
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INC_STA_TOGGLE_HPP_ */
|
@ -12,6 +12,7 @@
|
|||||||
#include <sta/tacos/manager.hpp>
|
#include <sta/tacos/manager.hpp>
|
||||||
#include <sta/tacos/statemachine.hpp>
|
#include <sta/tacos/statemachine.hpp>
|
||||||
#include <tasks/dummy.hpp>
|
#include <tasks/dummy.hpp>
|
||||||
|
#include <tasks/toggle.hpp>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include <sta/devices/stm32/gpio_pin.hpp>
|
#include <sta/devices/stm32/gpio_pin.hpp>
|
||||||
|
|
||||||
@ -32,7 +33,9 @@ namespace sta
|
|||||||
// ###### Register different threads for different states here. ######
|
// ###### Register different threads for different states here. ######
|
||||||
|
|
||||||
// The dummy task runs for state 0.
|
// The dummy task runs for state 0.
|
||||||
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("Dummy"), {0});
|
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("State 0"), {0});
|
||||||
|
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("State 1"), {1});
|
||||||
|
Manager::instance()->registerThread(std::make_shared<demo::Toggle>(), {0, 1});
|
||||||
}
|
}
|
||||||
} // namespace tacos
|
} // namespace tacos
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
37
App/Src/tasks/toggle.cpp
Normal file
37
App/Src/tasks/toggle.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* toggle.cpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 10, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tasks/toggle.hpp>
|
||||||
|
#include <sta/tacos/statemachine.hpp>
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
Toggle::Toggle()
|
||||||
|
: sta::tacos::TacosThread{ "Toggle", osPriorityNormal }
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Toggle::init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Toggle::func()
|
||||||
|
{
|
||||||
|
osDelay(5000);
|
||||||
|
|
||||||
|
uint16_t state = sta::tacos::Statemachine::instance()->getCurrentState();
|
||||||
|
uint16_t next = 1 - state;
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTLN("Toggle!");
|
||||||
|
sta::tacos::Statemachine::instance()->requestStateTransition(state, next, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
Subproject commit c609dc81cc70327948aa8173c9d6ad804ae7a642
|
Subproject commit 615900f16e246f3f33eebb9b022b7da3c62b7162
|
Loading…
x
Reference in New Issue
Block a user