I got one doubt while using event flag. what is difference between following API's
Code: Select all
chEvtWaitAllTimeout
chEvtWaitAnyTimeout
chEvtWaitOneTimeout
I read the documents, here is my understanding if i m not wrong,
if we pass ALL_EVENT as event_mask then i think all will behave same only.
Again, i was going through one demo other than deom shared in chibi_studio.
I am bit confuse here in the following statement
Code: Select all
chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(500)));
i found following snippet(simplified).
Code: Select all
static EVENTSOURCE_DECL(inserted_event);
static EVENTSOURCE_DECL(removed_event);
void main(void)
{
evhandler_t evhndl[] = {
InsertHandler,
RemoveHandler
};
struct event_listener el0, el1;
chEvtRegister(&inserted_event, &el0, 0);
chEvtRegister(&removed_event, &el1, 1);
while(1)
{
chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(500)));
}
}
static void InsertHandler(eventid_t id) {
//do something
}
static void RemoveHandler(eventid_t id) {
//do something
}
void task(void)
{
if(mmc_available)
{
chEvtBroadcastI(&inserted_event);
}
else
{
chEvtBroadcastI(&removed_event);
}
}