15
15
* limitations under the License.
16
16
*/
17
17
18
- #include " mbed_stats.h"
19
- #include " cmsis_os2.h"
20
18
#include " greentea-client/test_env.h"
21
19
#include " greentea-client/greentea_metrics.h"
22
- #include " SingletonPtr .h"
23
- #include " CircularBuffer.h "
20
+ #include " platform/mbed_stats .h"
21
+ #include < stdint.h >
24
22
25
23
#define THREAD_BUF_COUNT 16
26
24
@@ -31,6 +29,20 @@ typedef struct {
31
29
} thread_info_t ;
32
30
33
31
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
32
+
33
+ #if !defined(MBED_CONF_RTOS_PRESENT) || !(MBED_CONF_RTOS_PRESENT)
34
+ #error "RTOS required for Stack stats"
35
+ #endif
36
+
37
+ #include " rtos/Mutex.h"
38
+ #include " rtos/Thread.h"
39
+ #include " mbed_stats.h"
40
+ #include " cmsis_os2.h"
41
+ #include " platform/SingletonPtr.h"
42
+ #include " platform/CircularBuffer.h"
43
+ using namespace mbed ;
44
+ using namespace rtos ;
45
+
34
46
// Mutex to protect "buf"
35
47
static SingletonPtr<Mutex> mutex;
36
48
static char buf[128 ];
@@ -41,7 +53,9 @@ static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
41
53
static void send_CPU_info (void );
42
54
#endif
43
55
56
+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
44
57
static void send_heap_info (void );
58
+ #endif
45
59
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
46
60
static void send_stack_info (void );
47
61
static void on_thread_terminate (osThreadId_t id);
@@ -62,7 +76,9 @@ void greentea_metrics_setup()
62
76
63
77
void greentea_metrics_report ()
64
78
{
79
+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
65
80
send_heap_info ();
81
+ #endif
66
82
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
67
83
send_stack_info ();
68
84
Kernel::attach_thread_terminate_hook (NULL );
@@ -85,13 +101,15 @@ static void send_CPU_info()
85
101
}
86
102
#endif
87
103
104
+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
88
105
static void send_heap_info ()
89
106
{
90
107
mbed_stats_heap_t heap_stats;
91
108
mbed_stats_heap_get (&heap_stats);
92
109
greentea_send_kv (" max_heap_usage" ,heap_stats.max_size );
93
110
greentea_send_kv (" reserved_heap" ,heap_stats.reserved_size );
94
111
}
112
+ #endif
95
113
96
114
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
97
115
MBED_UNUSED static void send_stack_info ()
0 commit comments