The Event Question

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: The Event Question

Post by Tabulous »

steved wrote:Nice to see I'm not the only one that has to think hard about events!

I've been using a slightly different arrangement, which works well if only one thread needs to know about the event (and if you don't have too many threads). It doesn't need a specific listener.

Code: Select all

void watchdogNotify(uint8_t threadNumber)
{
chEvtSignal(mainThread, EVENT_MASK(threadNumber));
}

Each monitored thread calls watchdogNotify() periodically; threadNumber is an arbitrary value (within limits) which uniquely identifies the thread.
mainThread is a pointer to the main thread! (or the thread which is triggering the watchdog).

Then use chEvtWaitAll(<your_sources_mask>); as previously mentioned.


Nice steve, i followed your approach but added the ability for threads to register into the watchdog, this is because i have some threads that only start if configured to.
It wraps around the independent watchdog driver.

Ive attached the files so it may be of use to others :-)
Attachments
watchdog-for-threads.zip
thread watchdog
(974 Bytes) Downloaded 288 times
Post Reply