mbed-os-examples
/
mbed-os-example-mbed5-sys-info
Example to get the System Information from Mbed OS
main.cpp
- Committer:
- mbed_official
- Date:
- 2018-11-14
- Revision:
- 16:49a99fd4085c
- Parent:
- 15:0d8d06c4864d
- Child:
- 18:84717aecb01a
File content as of revision 16:49a99fd4085c:
#include "mbed.h" #if !defined(MBED_SYS_STATS_ENABLED) #error [NOT_SUPPORTED] test not supported #endif int main() { mbed_stats_sys_t stats; mbed_stats_sys_get(&stats); printf("Mbed OS Version: %ld \n", stats.os_version); /* CPUID Register information [31:24]Implementer 0x41 = ARM [23:20]Variant Major revision 0x0 = Revision 0 [19:16]Architecture 0xC = Baseline Architecture 0xF = Constant (Mainline Architecture) [15:4]PartNO 0xC20 = Cortex-M0 0xC60 = Cortex-M0+ 0xC23 = Cortex-M3 0xC24 = Cortex-M4 0xC27 = Cortex-M7 0xD20 = Cortex-M23 0xD21 = Cortex-M33 [3:0]Revision Minor revision: 0x1 = Patch 1 */ printf("CPU ID: 0x%x \n", stats.cpu_id); /* Compiler IDs ARM = 1 GCC_ARM = 2 IAR = 3 */ printf("Compiler ID: %d \n", stats.compiler_id); /* Compiler versions: ARM: PVVbbbb (P = Major; VV = Minor; bbbb = build number) GCC: VVRRPP (VV = Version; RR = Revision; PP = Patch) IAR: VRRRPPP (V = Version; RRR = Revision; PPP = Patch) */ printf("Compiler Version: %d \n", stats.compiler_version); return 0; }