1 /**
2  ****************************************************************************************
3  *
4  * @file ke_event.h
5  *
6  * @brief This file contains the definition related to kernel events.
7  *
8  * Copyright (C) RivieraWaves 2009-2015
9  *
10  *
11  ****************************************************************************************
12  */
13 
14 #ifndef _KE_EVENT_H_
15 #define _KE_EVENT_H_
16 
17 /**
18  ****************************************************************************************
19  * @addtogroup EVT Events and Schedule
20  * @ingroup KERNEL
21  * @brief Event scheduling module.
22  *
23  * The KE_EVT module implements event scheduling functions. It can be used to
24  * implement deferred actions.
25  *
26  * @{
27  ****************************************************************************************
28  */
29 
30 /*
31  * INCLUDE FILES
32  ****************************************************************************************
33  */
34 
35 #include "rwip_config.h"          // stack configuration
36 
37 #include <stdint.h>       // standard integer definition
38 
39 
40 /*
41  * CONSTANTS
42  ****************************************************************************************
43  */
44 
45 
46 /// Status of ke_task API functions
47 enum KE_EVENT_STATUS
48 {
49     KE_EVENT_OK = 0,
50     KE_EVENT_FAIL,
51     KE_EVENT_UNKNOWN,
52     KE_EVENT_CAPA_EXCEEDED,
53     KE_EVENT_ALREADY_EXISTS,
54 };
55 
56 
57 /*
58  * TYPE DEFINITION
59  ****************************************************************************************
60  */
61 
62 
63 
64 
65 /*
66  * FUNCTION PROTOTYPES
67  ****************************************************************************************
68  */
69 
70 
71 
72 /**
73  ****************************************************************************************
74  * @brief Initialize Kernel event module.
75  ****************************************************************************************
76  */
77 void ke_event_init(void);
78 
79 /**
80  ****************************************************************************************
81  * @brief Register an event callback.
82  *
83  * @param[in]  event_type       Event type.
84  * @param[in]  p_callback       Pointer to callback function.
85  *
86  * @return                      Status
87  ****************************************************************************************
88  */
89 uint8_t ke_event_callback_set(uint8_t event_type, void (*p_callback)(void));
90 
91 /**
92  ****************************************************************************************
93  * @brief Set an event
94  *
95  * This primitive sets one event. It will trigger the call to the corresponding event
96  * handler in the next scheduling call.
97  *
98  * @param[in]  event_type      Event to be set.
99  ****************************************************************************************
100  */
101 void ke_event_set(uint8_t event_type);
102 
103 /**
104  ****************************************************************************************
105  * @brief Clear an event
106  *
107  * @param[in]  event_type      Event to be cleared.
108  ****************************************************************************************
109  */
110 void ke_event_clear(uint8_t event_type);
111 
112 /**
113  ****************************************************************************************
114  * @brief Get the status of an event
115  *
116  * @param[in]  event_type      Event to get.
117  *
118  * @return                     Event status (0: not set / 1: set)
119  ****************************************************************************************
120  */
121 uint8_t ke_event_get(uint8_t event_type);
122 
123 /**
124  ****************************************************************************************
125  * @brief Get all event status
126  *
127  * @return                     Events bit field
128  ****************************************************************************************
129  */
130 uint32_t ke_event_get_all(void);
131 
132 /**
133  ****************************************************************************************
134  * @brief Flush all pending events.
135  ****************************************************************************************
136  */
137 void ke_event_flush(void);
138 
139 /**
140  ****************************************************************************************
141  * @brief Event scheduler entry point.
142  *
143  * This primitive is the entry point of Kernel event scheduling.
144  ****************************************************************************************
145  */
146 void ke_event_schedule(void);
147 
148 
149 
150 /// @} EVT
151 
152 #endif //_KE_EVENT_H_
153