This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SIMPLELINK-CC26X2-SDK: Event_pend with no wait

Part Number: SIMPLELINK-CC26X2-SDK


Is there any problem using,

events = Event_pend(syncEvent, Event_Id_NONE, MR_ALL_EVENTS,0);

if(events){

//code for handling events

}else loop_fns(); //which keeps running and isn't event based.

or is it advisable to use a 1ms timer(using UtilClock) and call loop_fns() as timer cb with events = Event_pend(syncEvent, Event_Id_NONE, MR_ALL_EVENTS,ICALL_TIMEOUT_FOREVER); so that it gets called each time timer event occurs.

Both cases seem to work, is there any issues or drawbacks while using the first method. 

  • Hi eteom,

    If you use a timeout period of 0 then you are essentially doing a non-blocking call to Event_pend() which either immediately returns with available events or with no events at all.

    I guess it all depends on what you are trying to achieve. If you want to connect loop_fns() to a timer then either call that function in a timer callback, or let the timer callback post an event to your main event loop which subsequently calls loop_fns(), e.g.

    void my_timer_callback(void) {
        // Note that MR_TIMER_EVENT must be defined
        Event_post(syncEvent, MR_TIMER_EVENT);
    }
    
    void my_application(void) {
        // ...
        events = Event_pend(syncEvent, Event_Id_NONE, MR_ALL_EVENTS, BIOS_WAIT_FOREVER);
    
        if(events & MR_OTHER_EVENTS) {
            //code for handling events
        }
    
        if(events & MR_TIMER_EVENT) {
            loop_fns();
        }
    }