-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add osal/threadx/EventDispatcherThreadX (#637)
* feat: add osal/threadx/EventDispatcherThreadX * Process review comments
- Loading branch information
1 parent
23ac162
commit 8c66ddd
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "osal/threadx/EventDispatcherThreadX.hpp" | ||
|
||
namespace hal | ||
{ | ||
constexpr static ULONG Execute{ 0x01 }; | ||
|
||
void EventDispatcherThreadXWorker::RequestExecution() | ||
{ | ||
if (tx_event_flags_set(&flags, Execute, TX_OR) != TX_SUCCESS) | ||
std::abort(); | ||
} | ||
|
||
void EventDispatcherThreadXWorker::Idle() | ||
{ | ||
ULONG events; | ||
if (tx_event_flags_get(&flags, Execute, TX_OR_CLEAR, &events, TX_WAIT_FOREVER) != TX_SUCCESS) | ||
std::abort(); | ||
} | ||
|
||
TX_EVENT_FLAGS_GROUP EventDispatcherThreadXWorker::init() | ||
{ | ||
TX_EVENT_FLAGS_GROUP flags{}; | ||
if (tx_event_flags_create(&flags, const_cast<char*>("")) != TX_SUCCESS) | ||
std::abort(); | ||
|
||
return flags; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef OSAL_EVENT_DISPATCHER_THREADX_HPP | ||
#define OSAL_EVENT_DISPATCHER_THREADX_HPP | ||
|
||
#include "infra/event/EventDispatcherWithWeakPtr.hpp" | ||
#include "tx_api.h" | ||
|
||
namespace hal | ||
{ | ||
class EventDispatcherThreadXWorker | ||
: public infra::EventDispatcherWithWeakPtrWorker | ||
{ | ||
public: | ||
using EventDispatcherWithWeakPtrWorker::EventDispatcherWithWeakPtrWorker; | ||
|
||
void RequestExecution() override; | ||
void Idle() override; | ||
|
||
private: | ||
TX_EVENT_FLAGS_GROUP flags{ init() }; | ||
|
||
static TX_EVENT_FLAGS_GROUP init(); | ||
}; | ||
|
||
using EventDispatcherThreadX = infra::EventDispatcherWithWeakPtrConnector<EventDispatcherThreadXWorker>; | ||
} | ||
|
||
#endif |