Skip to content
Snippets Groups Projects
Commit 12b6ff67 authored by Niccolò Betto's avatar Niccolò Betto Committed by Davide Mor
Browse files

[EventBroker] Update to Miosix 2.7 API

parent 75c309d2
No related branches found
No related tags found
No related merge requests found
...@@ -66,11 +66,8 @@ uint16_t EventBroker::postDelayed(const Event& ev, uint8_t topic, ...@@ -66,11 +66,8 @@ uint16_t EventBroker::postDelayed(const Event& ev, uint8_t topic,
Lock<FastMutex> lock(mtxDelayedEvents); Lock<FastMutex> lock(mtxDelayedEvents);
// Delay in system ticks DelayedEvent dev{eventCounter++, ev, topic,
long long delayTicks = miosix::getTime() + delayMs * Constants::NS_IN_MS};
static_cast<long long>(delayMs * miosix::TICK_FREQ / 1000);
DelayedEvent dev{eventCounter++, ev, topic, getTick() + delayTicks};
bool added = false; bool added = false;
// Add the new event in the list, ordered by deadline (first = nearest // Add the new event in the list, ordered by deadline (first = nearest
...@@ -141,7 +138,7 @@ void EventBroker::run() ...@@ -141,7 +138,7 @@ void EventBroker::run()
while (!shouldStop()) while (!shouldStop())
{ {
while (delayedEvents.size() > 0 && while (delayedEvents.size() > 0 &&
delayedEvents.front().deadline <= getTick()) delayedEvents.front().deadline <= miosix::getTime())
{ {
// Pop the first element // Pop the first element
DelayedEvent dev = delayedEvents.front(); DelayedEvent dev = delayedEvents.front();
...@@ -157,7 +154,7 @@ void EventBroker::run() ...@@ -157,7 +154,7 @@ void EventBroker::run()
// When to wakeup for the next cycle // When to wakeup for the next cycle
long long sleepUntil = long long sleepUntil =
getTick() + EVENT_BROKER_MIN_DELAY * miosix::TICK_FREQ / 1000; miosix::getTime() + EVENT_BROKER_MIN_DELAY * Constants::NS_IN_MS;
if (delayedEvents.size() > 0) if (delayedEvents.size() > 0)
{ {
...@@ -173,7 +170,7 @@ void EventBroker::run() ...@@ -173,7 +170,7 @@ void EventBroker::run()
Unlock<FastMutex> unlock(lock); Unlock<FastMutex> unlock(lock);
StackLogger::getInstance().updateStack(THID_EVT_BROKER); StackLogger::getInstance().updateStack(THID_EVT_BROKER);
Thread::sleepUntil(sleepUntil); Thread::nanoSleepUntil(sleepUntil);
} }
} }
} }
......
...@@ -39,7 +39,6 @@ using std::map; ...@@ -39,7 +39,6 @@ using std::map;
using std::vector; using std::vector;
using miosix::FastMutex; using miosix::FastMutex;
using miosix::getTick;
using miosix::Lock; using miosix::Lock;
using miosix::Thread; using miosix::Thread;
using miosix::Unlock; using miosix::Unlock;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment