mbed-os-examples
/
mbed-os-example-mbed5-sys-info
Example to get the System Information from Mbed OS
main.cpp@15:0d8d06c4864d, 2018-11-13 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Nov 13 23:45:22 2018 +0000
- Revision:
- 15:0d8d06c4864d
- Parent:
- 5:ca9bf0d65cc6
- Child:
- 16:49a99fd4085c
Merge pull request #13 from kegilbert/patch-1
Minor: extra character removal from comment
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-sys-info
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:db1600a88ae1 | 1 | #include "mbed.h" |
mbed_official | 0:db1600a88ae1 | 2 | |
mbed_official | 0:db1600a88ae1 | 3 | #if !defined(MBED_SYS_STATS_ENABLED) |
mbed_official | 0:db1600a88ae1 | 4 | #error [NOT_SUPPORTED] test not supported |
mbed_official | 0:db1600a88ae1 | 5 | #endif |
mbed_official | 0:db1600a88ae1 | 6 | |
mbed_official | 0:db1600a88ae1 | 7 | int main() |
mbed_official | 0:db1600a88ae1 | 8 | { |
mbed_official | 0:db1600a88ae1 | 9 | mbed_stats_sys_t stats; |
mbed_official | 0:db1600a88ae1 | 10 | mbed_stats_sys_get(&stats); |
mbed_official | 0:db1600a88ae1 | 11 | |
mbed_official | 5:ca9bf0d65cc6 | 12 | printf("Mbed OS Version: %ld \n", stats.os_version); |
mbed_official | 0:db1600a88ae1 | 13 | |
mbed_official | 0:db1600a88ae1 | 14 | /* CPUID Register information |
mbed_official | 0:db1600a88ae1 | 15 | [31:24]Implementer 0x41 = ARM |
mbed_official | 0:db1600a88ae1 | 16 | [23:20]Variant Major revision 0x0 = Revision 0 |
mbed_official | 0:db1600a88ae1 | 17 | [19:16]Architecture 0xC = Baseline Architecture |
mbed_official | 15:0d8d06c4864d | 18 | 0xF = Constant (Mainline Architecture) |
mbed_official | 0:db1600a88ae1 | 19 | [15:4]PartNO 0xC20 = Cortex-M0 |
mbed_official | 0:db1600a88ae1 | 20 | 0xC60 = Cortex-M0+ |
mbed_official | 0:db1600a88ae1 | 21 | 0xC23 = Cortex-M3 |
mbed_official | 0:db1600a88ae1 | 22 | 0xC24 = Cortex-M4 |
mbed_official | 0:db1600a88ae1 | 23 | 0xC27 = Cortex-M7 |
mbed_official | 0:db1600a88ae1 | 24 | 0xD20 = Cortex-M23 |
mbed_official | 0:db1600a88ae1 | 25 | 0xD21 = Cortex-M33 |
mbed_official | 15:0d8d06c4864d | 26 | [3:0]Revision Minor revision: 0x1 = Patch 1 |
mbed_official | 0:db1600a88ae1 | 27 | */ |
mbed_official | 0:db1600a88ae1 | 28 | printf("CPU ID: 0x%x \n", stats.cpu_id); |
mbed_official | 0:db1600a88ae1 | 29 | |
mbed_official | 0:db1600a88ae1 | 30 | printf("Compiler ID: %d \n", stats.compiler_id); |
mbed_official | 0:db1600a88ae1 | 31 | |
mbed_official | 0:db1600a88ae1 | 32 | /* Compiler versions: |
mbed_official | 0:db1600a88ae1 | 33 | ARM: PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
mbed_official | 0:db1600a88ae1 | 34 | GCC: VVRRPP (VV = Version; RR = Revision; PP = Patch) |
mbed_official | 0:db1600a88ae1 | 35 | IAR: VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
mbed_official | 0:db1600a88ae1 | 36 | */ |
mbed_official | 0:db1600a88ae1 | 37 | printf("Compiler Version: %d \n", stats.compiler_version); |
mbed_official | 0:db1600a88ae1 | 38 | |
mbed_official | 0:db1600a88ae1 | 39 | return 0; |
mbed_official | 0:db1600a88ae1 | 40 | } |