mbed-os-examples
/
mbed-os-example-mbed5-sys-info
Example to get the System Information from Mbed OS
main.cpp@18:84717aecb01a, 2018-11-27 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Nov 27 04:45:35 2018 +0000
- Revision:
- 18:84717aecb01a
- Parent:
- 16:49a99fd4085c
- Child:
- 19:907415fb0a88
Merge pull request #12 from ARMmbed/mem_stats
Add RAM/ROM stats to the application
.
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 | 16:49a99fd4085c | 30 | /* Compiler IDs |
mbed_official | 16:49a99fd4085c | 31 | ARM = 1 |
mbed_official | 16:49a99fd4085c | 32 | GCC_ARM = 2 |
mbed_official | 16:49a99fd4085c | 33 | IAR = 3 |
mbed_official | 16:49a99fd4085c | 34 | */ |
mbed_official | 0:db1600a88ae1 | 35 | printf("Compiler ID: %d \n", stats.compiler_id); |
mbed_official | 0:db1600a88ae1 | 36 | |
mbed_official | 0:db1600a88ae1 | 37 | /* Compiler versions: |
mbed_official | 0:db1600a88ae1 | 38 | ARM: PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
mbed_official | 0:db1600a88ae1 | 39 | GCC: VVRRPP (VV = Version; RR = Revision; PP = Patch) |
mbed_official | 0:db1600a88ae1 | 40 | IAR: VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
mbed_official | 0:db1600a88ae1 | 41 | */ |
mbed_official | 0:db1600a88ae1 | 42 | printf("Compiler Version: %d \n", stats.compiler_version); |
mbed_official | 0:db1600a88ae1 | 43 | |
mbed_official | 18:84717aecb01a | 44 | /* RAM / ROM memory start and size information */ |
mbed_official | 18:84717aecb01a | 45 | for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { |
mbed_official | 18:84717aecb01a | 46 | if (stats.ram_size[i] != 0) { |
mbed_official | 18:84717aecb01a | 47 | printf("RAM%d: Start 0x%x Size: 0x%x \n",i , stats.ram_start[i], stats.ram_size[i]); |
mbed_official | 18:84717aecb01a | 48 | } |
mbed_official | 18:84717aecb01a | 49 | } |
mbed_official | 18:84717aecb01a | 50 | for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { |
mbed_official | 18:84717aecb01a | 51 | if (stats.rom_size[i] != 0) { |
mbed_official | 18:84717aecb01a | 52 | printf("ROM%d: Start 0x%x Size: 0x%x \n",i, stats.rom_start[i], stats.rom_size[i]); |
mbed_official | 18:84717aecb01a | 53 | } |
mbed_official | 18:84717aecb01a | 54 | } |
mbed_official | 0:db1600a88ae1 | 55 | return 0; |
mbed_official | 0:db1600a88ae1 | 56 | } |