Skip to content

Commit 1961428

Browse files
author
Deepika
committed
OS version added + CPUID for cortex-M only
CPUID base register is available for Cortex-M processors only. Cortex-A devices have Main ID Register, which can be used in future to get processor info.
1 parent 40021eb commit 1961428

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

TESTS/mbed_platform/stats_sys/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ void test_sys_info()
3232
mbed_stats_sys_t stats;
3333
mbed_stats_sys_get(&stats);
3434

35+
#if defined(MBED_VERSION)
36+
TEST_ASSERT_NOT_EQUAL(0, stats.os_version);
37+
#endif
38+
39+
#if defined(__CORTEX_M)
3540
TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id);
41+
#endif
42+
3643
#if defined(__IAR_SYSTEMS_ICC__)
3744
TEST_ASSERT_EQUAL(IAR, stats.compiler_id);
3845
#elif defined(__CC_ARM)

platform/mbed_stats.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ void mbed_stats_sys_get(mbed_stats_sys_t *stats)
106106
memset(stats, 0, sizeof(mbed_stats_sys_t));
107107

108108
#if defined(MBED_SYS_STATS_ENABLED)
109-
109+
#if defined(MBED_VERSION)
110+
stats->os_version = MBED_VERSION;
111+
#endif
112+
#if defined(__CORTEX_M)
110113
stats->cpu_id = SCB->CPUID;
111-
114+
#endif
112115
#if defined(__IAR_SYSTEMS_ICC__)
113116
stats->compiler_id = IAR;
114117
stats->compiler_version = __VER__;

platform/mbed_stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ typedef enum {
118118
* struct mbed_stats_sys_t definition
119119
*/
120120
typedef struct {
121-
uint32_t cpu_id; /**< CPUID Register data */
121+
uint32_t os_version; /**< Mbed OS Version (Release only) */
122+
uint32_t cpu_id; /**< CPUID Register data (Cortex-M only supported) */
122123
mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */
123124
uint32_t compiler_version; /**< Compiler version */
124125
} mbed_stats_sys_t;

0 commit comments

Comments
 (0)