1515 * limitations under the License.
1616 */
1717
18- #include " mbed_stats.h"
19- #include " cmsis_os2.h"
2018#include " greentea-client/test_env.h"
2119#include " greentea-client/greentea_metrics.h"
22- #include " SingletonPtr .h"
23- #include " CircularBuffer.h "
20+ #include " platform/mbed_stats .h"
21+ #include < stdint.h >
2422
2523#define THREAD_BUF_COUNT 16
2624
@@ -31,6 +29,20 @@ typedef struct {
3129} thread_info_t ;
3230
3331#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+
3446// Mutex to protect "buf"
3547static SingletonPtr<Mutex> mutex;
3648static char buf[128 ];
@@ -41,7 +53,9 @@ static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
4153static void send_CPU_info (void );
4254#endif
4355
56+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
4457static void send_heap_info (void );
58+ #endif
4559#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
4660static void send_stack_info (void );
4761static void on_thread_terminate (osThreadId_t id);
@@ -62,7 +76,9 @@ void greentea_metrics_setup()
6276
6377void greentea_metrics_report ()
6478{
79+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
6580 send_heap_info ();
81+ #endif
6682#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
6783 send_stack_info ();
6884 Kernel::attach_thread_terminate_hook (NULL );
@@ -85,13 +101,15 @@ static void send_CPU_info()
85101}
86102#endif
87103
104+ #if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
88105static void send_heap_info ()
89106{
90107 mbed_stats_heap_t heap_stats;
91108 mbed_stats_heap_get (&heap_stats);
92109 greentea_send_kv (" max_heap_usage" ,heap_stats.max_size );
93110 greentea_send_kv (" reserved_heap" ,heap_stats.reserved_size );
94111}
112+ #endif
95113
96114#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
97115MBED_UNUSED static void send_stack_info ()
0 commit comments