1 /**
2  ****************************************************************************************
3  *
4  * @file ke.h
5  *
6  * @brief This file contains the definition of the kernel environment.
7  *
8  * Copyright (C) RivieraWaves 2009-2015
9  *
10  *
11  ****************************************************************************************
12  */
13 
14 #ifndef _KE_H_
15 #define _KE_H_
16 
17 /**
18  ****************************************************************************************
19  * @addtogroup ENV Environment
20  * @ingroup KERNEL
21  * @brief Kernel Environment
22  *
23  * @{
24  ****************************************************************************************
25  */
26 
27 /*
28  * INCLUDE FILES
29  ****************************************************************************************
30  */
31 
32 #include "rwip_config.h"          // stack configuration
33 
34 #include <stdbool.h>              // standard boolean definitions
35 #include <stdint.h>               // standard integer definitions
36 
37 /*
38  * ENUMERATION
39  ****************************************************************************************
40  */
41 
42 /// Kernel Error Status
43 enum KE_STATUS
44 {
45     KE_SUCCESS = 0,
46     KE_FAIL
47 };
48 
49 
50 /*
51  * FUNCTION DECLARATIONS
52  ****************************************************************************************
53  */
54 
55 /**
56  ****************************************************************************************
57  * @brief This function performs all the initializations of the kernel.
58  *
59  * It initializes first the heap, then the message queues and the events. Then if required
60  * it initializes the trace.
61  *
62  ****************************************************************************************
63  */
64 void ke_init(void);
65 
66 /**
67  ****************************************************************************************
68  * @brief This function flushes all messages, timers and events currently pending in the
69  * kernel.
70  *
71  ****************************************************************************************
72  */
73 void ke_flush(void);
74 
75 /**
76  ****************************************************************************************
77  * @brief This function checks if sleep is possible or kernel is processing
78  *
79  * @return      True if sleep is allowed, false otherwise
80  ****************************************************************************************
81  */
82 bool ke_sleep_check(void);
83 
84 #if (KE_PROFILING)
85 /**
86  ****************************************************************************************
87  * @brief This function gets the statistics of the kernel usage.
88  *
89  * @param[out]   max_msg_sent      Max message sent
90  * @param[out]   max_msg_saved     Max message saved
91  * @param[out]   max_timer_used    Max timer used
92  * @param[out]   max_heap_used     Max heap used
93  ****************************************************************************************
94  */
95 enum KE_STATUS ke_stats_get(uint8_t* max_msg_sent,
96                 uint8_t* max_msg_saved,
97                 uint8_t* max_timer_used,
98                 uint16_t* max_heap_used);
99 #endif //KE_PROFILING
100 
101 /// @} KE
102 
103 #endif // _KE_H_
104