This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Examples using the scheduler

I am trying to use the Scheduler to create my own event handler system (similar to a Ti 8051 OSAL system). I'm writing separate classes that can push data/trigger handlers between classes via put/scheduled events. Sort of like a soft interrupt. For example I want a timer timeout handler of a Button_timer.c class to send an event to Main.c, to trigger enable/disable some LEDs. This way Main.c acts as the main dispatch and controller for all peripheral events. However I cannot find any examples of the Scheduler where the application created its own events and event handlers. Thus I'm still a little in the dark with exactly how to implement a Scheduler into my application. Can anyone point me to some examples that use the scheduler?

p.s. Tried looking into the HID examples, but the app_sched_init and app_sched_event_put calls are not coded in the application.

Thanks guys.

Parents
    1. Need to init sheduler in main() like this:

      APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);

    2. in main() need insert this code:

      while(1) { app_sched_execute(); ... }

    3. in app_sheduler.h we have Scheduler event handler type:

      typedef void (*app_sched_event_handler_t)(void * p_event_data, uint16_t event_size);

    4. Declare own function like than typedef:

      void my_flash_event_func(void *data, uint16_t size); //this is event handler

    5. In any place where it is need, we call:

      app_sched_event_put(pointer_to_own_data, size_of_data, my_flash_event_func); //this is event

    And sheduler will call your function "my_flash_event_func" with params: "pointer_to_own_data" and "size_of_data" like this:

    my_flash_event_func(pointer_to_data, size_of_data);
    
  • This is a great response. It should be included in the documentation! Item one should mention that #include "app_scheduler.h" is required.

Reply Children
No Data
Related