Files
pico-launcher/common/ipc/ThreadIpcService.cpp
2025-11-25 17:41:31 +01:00

34 lines
693 B
C++

#include "common.h"
#include "ThreadIpcService.h"
void ThreadIpcService::ThreadMain()
{
while (true)
{
rtos_waitEvent(&_event, false, true);
if (_messageValid)
{
_messageValid = false;
HandleMessage(_message);
}
}
}
void ThreadIpcService::Start()
{
rtos_createEvent(&_event);
rtos_createThread(&_thread, 5, [] (void* arg)
{
static_cast<ThreadIpcService*>(arg)->ThreadMain();
}, this, _stack, _stackSize);
rtos_wakeupThread(&_thread);
IpcService::Start();
}
void ThreadIpcService::OnMessageReceived(u32 data)
{
_message = data;
_messageValid = true;
rtos_signalEvent(&_event);
}