Example to get the System Information from Mbed OS

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Jun 05 17:34:25 2018 +0100
Child:
1:56c15f963f52
Commit message:
Initial commit.
Commit copied from https://github.com/ARMmbed/mbed-os-example-sys-info

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Tue Jun 05 17:34:25 2018 +0100
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Tue Jun 05 17:34:25 2018 +0100
@@ -0,0 +1,55 @@
+# Getting started with System Information on Mbed OS
+
+This guide reviews the steps required to get system information on Mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-sys-info
+cd mbed-os-example-sys-info
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++------------------+-------+-------+------+
+| Module           | .text | .data | .bss |
++------------------+-------+-------+------+
+| [lib]\c_w.l      | 11473 |    16 |  348 |
+| [lib]\cpprt_w.l  |    36 |     0 |    0 |
+| [lib]\fz_wm.l    |    18 |     0 |    0 |
+| [lib]\m_wm.l     |    48 |     0 |    0 |
+| anon$$obj.o      |    32 |     0 | 1024 |
+| main.o           |   136 |     0 |    0 |
+| mbed-os\drivers  |   130 |     0 |    0 |
+| mbed-os\features |   132 |     0 |  304 |
+| mbed-os\hal      |  1660 |    30 |   64 |
+| mbed-os\platform |  3465 |   104 |  604 |
+| mbed-os\rtos     | 12926 |  2310 | 4592 |
+| mbed-os\targets  |  9193 |   104 |  324 |
+| Subtotals        | 39249 |  2564 | 7260 |
++------------------+-------+-------+------+
+Total Static RAM memory (data + bss): 9824 bytes
+Total Flash memory (text + data): 41813 bytes
+
+Image: .\BUILD\K64F\ARM\mbed-os-example-sys-info.bin
+```
+
+### Program your board
+
+1. Connect your Mbed device to the computer over USB.
+1. Copy the binary file to the Mbed device.
+1. Press the reset button to start the program.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 05 17:34:25 2018 +0100
@@ -0,0 +1,40 @@
+#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: 0x%x \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);
+
+    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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Jun 05 17:34:25 2018 +0100
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#5371c107353f20ab79edcbe8a005cb7c0ea9249e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Tue Jun 05 17:34:25 2018 +0100
@@ -0,0 +1,3 @@
+{
+    "macros": ["MBED_SYS_STATS_ENABLED"]
+}