Module for declaring system events API. More...
Data Structures | |
struct | sys_event_desc_t |
Event descriptor. More... | |
Typedefs | |
typedef void(* | sys_event_callback_t )(const void *p_data) |
Prototype of user-implemented callback for processing an event. More... | |
Enumerations | |
enum | sys_event_id_t { SYS_EVENT_FALLING_ASLEEP, SYS_EVENT_WAKE_UP, SYS_EVENT_OUT_OF_MEMORY, SYS_EVENT_MEMORY_FREED, TST_EVENT_0, TST_EVENT_1, TST_EVENT_2, SYS_EVENTS_AMOUNT } |
IDs of globally available events. More... | |
Functions | |
void | sys_events_init (void) |
Function for initializing the global events infrastructure. | |
void | sys_event_subscribe (sys_event_desc_t *p_event_desc) |
Function for subscribing to a system event. More... | |
void | sys_event_unsubscribe (sys_event_desc_t *p_event_desc) |
Function for unsubscribing from a system event event. More... | |
void | sys_events_array_subscribe (sys_event_desc_t *p_desc_array, size_t desc_amount) |
Function for subscribing to a group of events. More... | |
void | sys_events_array_unsubscribe (sys_event_desc_t *p_desc_array, size_t desc_amount) |
Function for unsubscribing from the group of events. More... | |
void | sys_event_post (sys_event_id_t event_id, const void *p_data) |
Function for posting an event. More... | |
Module for declaring system events API.
The Events module defines some routines to subscribe/unsubscribe to/from system events. The events pool can be extended by adding new events to the sys_event_id_t enumeration. The registered callbacks can be called for an array of events. The callbacks can be called implicitly via posting the event by the sys_event_post() routine.
typedef void(* sys_event_callback_t)(const void *p_data) |
Prototype of user-implemented callback for processing an event.
This callback is registered for the given event by a *_subscribe routine, and is then called by the system events engine, when this event occurs.
[in] | p_data | Pointer to the data, specific for this event. |
enum sys_event_id_t |
IDs of globally available events.
Event IDs are system extension points that allow the user to implement specific processing of predefined set of events, occurring in different modules.
void sys_event_post | ( | sys_event_id_t | event_id, |
const void * | p_data | ||
) |
Function for posting an event.
This function is used to notify all the subscribers of the given events via their callbacks, when the given event occurs.
[in] | event_id | ID of the event to be posted. |
[in] | p_data | Pointer to be passed to the event handlers' callbacks. |
void sys_event_subscribe | ( | sys_event_desc_t * | p_event_desc | ) |
Function for subscribing to a system event.
[in] | p_event_desc | Pointer to the event descriptor. |
void sys_event_unsubscribe | ( | sys_event_desc_t * | p_event_desc | ) |
Function for unsubscribing from a system event event.
[in] | p_event_desc | Pointer to the event descriptor. |
void sys_events_array_subscribe | ( | sys_event_desc_t * | p_desc_array, |
size_t | desc_amount | ||
) |
Function for subscribing to a group of events.
[in] | p_desc_array | Pointer to the array of event descriptors. |
[in] | desc_amount | Amount of event descriptors in the array. |
void sys_events_array_unsubscribe | ( | sys_event_desc_t * | p_desc_array, |
size_t | desc_amount | ||
) |
Function for unsubscribing from the group of events.
[in] | p_desc_array | Pointer to the array of event descriptors. |
[in] | desc_amount | Amount of the event descriptors in the array. |