Skip to content

Commit c08b3e3

Browse files
author
deepikabhavnani
committed
System Info API addition
API added to get the system information like CPU ID, compiler ID and compiler version.
1 parent 8be2e34 commit c08b3e3

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

platform/mbed_stats.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#include "mbed_assert.h"
12
#include "mbed_stats.h"
23
#include <string.h>
34
#include <stdlib.h>
4-
#include "mbed_assert.h"
55

6+
#include "device.h"
67
#ifdef MBED_CONF_RTOS_PRESENT
78
#include "cmsis_os2.h"
89
#elif defined(MBED_STACK_STATS_ENABLED) || defined(MBED_THREAD_STATS_ENABLED)
@@ -96,6 +97,29 @@ size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count)
9697
osKernelUnlock();
9798
free(threads);
9899
#endif
99-
100100
return i;
101101
}
102+
103+
void mbed_stats_sys_get(mbed_stats_sys_t *stats)
104+
{
105+
MBED_ASSERT(stats != NULL);
106+
memset(stats, 0, sizeof(mbed_stats_sys_t));
107+
108+
#if defined(MBED_SYS_STATS_ENABLED)
109+
110+
stats->cpu_id = SCB->CPUID;
111+
112+
#if defined(__IAR_SYSTEMS_ICC__)
113+
stats->compiler_id = IAR;
114+
stats->compiler_version = __VER__;
115+
#elif defined(__CC_ARM)
116+
stats->compiler_id = ARM;
117+
stats->compiler_version = __ARMCC_VERSION;
118+
#elif defined(__GNUC__)
119+
stats->compiler_id = GCC_ARM;
120+
stats->compiler_version = (__GNUC__ * 10000 + __GNUC_MINOR__ * 100);
121+
#endif
122+
123+
#endif
124+
return;
125+
}

platform/mbed_stats.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern "C" {
3030
#endif
3131

3232
#ifdef MBED_ALL_STATS_ENABLED
33+
#define MBED_SYS_STATS_ENABLED 1
3334
#define MBED_STACK_STATS_ENABLED 1
3435
#define MBED_HEAP_STATS_ENABLED 1
3536
#define MBED_THREAD_STATS_ENABLED 1
@@ -85,7 +86,6 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
8586
/**
8687
* struct mbed_stats_thread_t definition
8788
*/
88-
8989
typedef struct {
9090
uint32_t id; /**< Thread Object Identifier */
9191
uint32_t state; /**< Thread Object State */
@@ -105,6 +105,31 @@ typedef struct {
105105
*/
106106
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count);
107107

108+
/**
109+
* enum mbed_compiler_id_t definition
110+
*/
111+
typedef enum {
112+
ARM = 1, /**< ARM */
113+
GCC_ARM, /**< GNU ARM */
114+
IAR /**< IAR */
115+
} mbed_compiler_id_t;
116+
117+
/**
118+
* struct mbed_stats_sys_t definition
119+
*/
120+
typedef struct {
121+
uint32_t cpu_id; /**< CPUID Register data */
122+
mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */
123+
uint32_t compiler_version; /**< Compiler version */
124+
} mbed_stats_sys_t;
125+
126+
/**
127+
* Fill the passed in sys stat structure with system stats.
128+
*
129+
* @param stats A pointer to the mbed_stats_sys_t structure to fill
130+
*/
131+
void mbed_stats_sys_get(mbed_stats_sys_t *stats);
132+
108133
#ifdef __cplusplus
109134
}
110135
#endif

0 commit comments

Comments
 (0)