mbed-os-examples
/
mbed-os-example-mbed5-sys-info
Example to get the System Information from Mbed OS
main.cpp@19:907415fb0a88, 2019-02-13 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 13 18:37:42 2019 +0000
- Revision:
- 19:907415fb0a88
- Parent:
- 18:84717aecb01a
Merge pull request #22 from adbridge/master
Updating mbed-os to mbed-os-5.11.4
.
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 | 19:907415fb0a88 | 1 | /* Copyright (c) 2018 Arm Limited |
mbed_official | 19:907415fb0a88 | 2 | * |
mbed_official | 19:907415fb0a88 | 3 | * SPDX-License-Identifier: Apache-2.0 |
mbed_official | 19:907415fb0a88 | 4 | * |
mbed_official | 19:907415fb0a88 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 19:907415fb0a88 | 6 | * you may not use this file except in compliance with the License. |
mbed_official | 19:907415fb0a88 | 7 | * You may obtain a copy of the License at |
mbed_official | 19:907415fb0a88 | 8 | * |
mbed_official | 19:907415fb0a88 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 19:907415fb0a88 | 10 | * |
mbed_official | 19:907415fb0a88 | 11 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 19:907415fb0a88 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 19:907415fb0a88 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 19:907415fb0a88 | 14 | * See the License for the specific language governing permissions and |
mbed_official | 19:907415fb0a88 | 15 | * limitations under the License. |
mbed_official | 19:907415fb0a88 | 16 | */ |
mbed_official | 0:db1600a88ae1 | 17 | #include "mbed.h" |
mbed_official | 0:db1600a88ae1 | 18 | |
mbed_official | 0:db1600a88ae1 | 19 | #if !defined(MBED_SYS_STATS_ENABLED) |
mbed_official | 0:db1600a88ae1 | 20 | #error [NOT_SUPPORTED] test not supported |
mbed_official | 0:db1600a88ae1 | 21 | #endif |
mbed_official | 0:db1600a88ae1 | 22 | |
mbed_official | 0:db1600a88ae1 | 23 | int main() |
mbed_official | 0:db1600a88ae1 | 24 | { |
mbed_official | 0:db1600a88ae1 | 25 | mbed_stats_sys_t stats; |
mbed_official | 0:db1600a88ae1 | 26 | mbed_stats_sys_get(&stats); |
mbed_official | 0:db1600a88ae1 | 27 | |
mbed_official | 5:ca9bf0d65cc6 | 28 | printf("Mbed OS Version: %ld \n", stats.os_version); |
mbed_official | 0:db1600a88ae1 | 29 | |
mbed_official | 0:db1600a88ae1 | 30 | /* CPUID Register information |
mbed_official | 0:db1600a88ae1 | 31 | [31:24]Implementer 0x41 = ARM |
mbed_official | 0:db1600a88ae1 | 32 | [23:20]Variant Major revision 0x0 = Revision 0 |
mbed_official | 0:db1600a88ae1 | 33 | [19:16]Architecture 0xC = Baseline Architecture |
mbed_official | 15:0d8d06c4864d | 34 | 0xF = Constant (Mainline Architecture) |
mbed_official | 0:db1600a88ae1 | 35 | [15:4]PartNO 0xC20 = Cortex-M0 |
mbed_official | 0:db1600a88ae1 | 36 | 0xC60 = Cortex-M0+ |
mbed_official | 0:db1600a88ae1 | 37 | 0xC23 = Cortex-M3 |
mbed_official | 0:db1600a88ae1 | 38 | 0xC24 = Cortex-M4 |
mbed_official | 0:db1600a88ae1 | 39 | 0xC27 = Cortex-M7 |
mbed_official | 0:db1600a88ae1 | 40 | 0xD20 = Cortex-M23 |
mbed_official | 0:db1600a88ae1 | 41 | 0xD21 = Cortex-M33 |
mbed_official | 15:0d8d06c4864d | 42 | [3:0]Revision Minor revision: 0x1 = Patch 1 |
mbed_official | 0:db1600a88ae1 | 43 | */ |
mbed_official | 0:db1600a88ae1 | 44 | printf("CPU ID: 0x%x \n", stats.cpu_id); |
mbed_official | 0:db1600a88ae1 | 45 | |
mbed_official | 16:49a99fd4085c | 46 | /* Compiler IDs |
mbed_official | 16:49a99fd4085c | 47 | ARM = 1 |
mbed_official | 16:49a99fd4085c | 48 | GCC_ARM = 2 |
mbed_official | 16:49a99fd4085c | 49 | IAR = 3 |
mbed_official | 16:49a99fd4085c | 50 | */ |
mbed_official | 0:db1600a88ae1 | 51 | printf("Compiler ID: %d \n", stats.compiler_id); |
mbed_official | 0:db1600a88ae1 | 52 | |
mbed_official | 0:db1600a88ae1 | 53 | /* Compiler versions: |
mbed_official | 0:db1600a88ae1 | 54 | ARM: PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
mbed_official | 0:db1600a88ae1 | 55 | GCC: VVRRPP (VV = Version; RR = Revision; PP = Patch) |
mbed_official | 0:db1600a88ae1 | 56 | IAR: VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
mbed_official | 0:db1600a88ae1 | 57 | */ |
mbed_official | 0:db1600a88ae1 | 58 | printf("Compiler Version: %d \n", stats.compiler_version); |
mbed_official | 0:db1600a88ae1 | 59 | |
mbed_official | 18:84717aecb01a | 60 | /* RAM / ROM memory start and size information */ |
mbed_official | 18:84717aecb01a | 61 | for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { |
mbed_official | 18:84717aecb01a | 62 | if (stats.ram_size[i] != 0) { |
mbed_official | 19:907415fb0a88 | 63 | printf("RAM%d: Start 0x%lx Size: 0x%lx \n", i, stats.ram_start[i], stats.ram_size[i]); |
mbed_official | 18:84717aecb01a | 64 | } |
mbed_official | 18:84717aecb01a | 65 | } |
mbed_official | 18:84717aecb01a | 66 | for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { |
mbed_official | 18:84717aecb01a | 67 | if (stats.rom_size[i] != 0) { |
mbed_official | 19:907415fb0a88 | 68 | printf("ROM%d: Start 0x%lx Size: 0x%lx \n", i, stats.rom_start[i], stats.rom_size[i]); |
mbed_official | 18:84717aecb01a | 69 | } |
mbed_official | 18:84717aecb01a | 70 | } |
mbed_official | 0:db1600a88ae1 | 71 | return 0; |
mbed_official | 0:db1600a88ae1 | 72 | } |