Events programming

Committer:
corsa1600
Date:
Thu Mar 28 18:15:10 2019 +0000
Revision:
4:964e73eb0618
Parent:
0:c3df3a527006
verbesserte Version des Queue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
corsa1600 0:c3df3a527006 1 # Getting started example for Mbed OS
corsa1600 0:c3df3a527006 2
corsa1600 0:c3df3a527006 3 This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).)
corsa1600 0:c3df3a527006 4
corsa1600 0:c3df3a527006 5 Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
corsa1600 0:c3df3a527006 6
corsa1600 0:c3df3a527006 7 ## Import the example application
corsa1600 0:c3df3a527006 8
corsa1600 0:c3df3a527006 9 From the command-line, import the example:
corsa1600 0:c3df3a527006 10
corsa1600 0:c3df3a527006 11 ```
corsa1600 0:c3df3a527006 12 mbed import mbed-os-example-blinky
corsa1600 0:c3df3a527006 13 cd mbed-os-example-blinky
corsa1600 0:c3df3a527006 14 ```
corsa1600 0:c3df3a527006 15
corsa1600 0:c3df3a527006 16 ### Now compile
corsa1600 0:c3df3a527006 17
corsa1600 0:c3df3a527006 18 Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the Arm Compiler:
corsa1600 0:c3df3a527006 19
corsa1600 0:c3df3a527006 20 ```
corsa1600 0:c3df3a527006 21 mbed compile -m K64F -t ARM
corsa1600 0:c3df3a527006 22 ```
corsa1600 0:c3df3a527006 23
corsa1600 0:c3df3a527006 24 Your PC may take a few minutes to compile your code. At the end, you see the following result:
corsa1600 0:c3df3a527006 25
corsa1600 0:c3df3a527006 26 ```
corsa1600 0:c3df3a527006 27 [snip]
corsa1600 0:c3df3a527006 28
corsa1600 0:c3df3a527006 29 Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin
corsa1600 0:c3df3a527006 30 ```
corsa1600 0:c3df3a527006 31
corsa1600 0:c3df3a527006 32 ### Program your board
corsa1600 0:c3df3a527006 33
corsa1600 0:c3df3a527006 34 1. Connect your Mbed device to the computer over USB.
corsa1600 0:c3df3a527006 35 1. Copy the binary file to the Mbed device.
corsa1600 0:c3df3a527006 36 1. Press the reset button to start the program.
corsa1600 0:c3df3a527006 37
corsa1600 0:c3df3a527006 38 The LED on your platform turns on and off. The main thread will additionally take a snapshot of the device's runtime statistics and display it over serial to your PC. The snapshot includes:
corsa1600 0:c3df3a527006 39
corsa1600 0:c3df3a527006 40 * System Information:
corsa1600 0:c3df3a527006 41 * Mbed OS Version: Will currently default to 999999
corsa1600 0:c3df3a527006 42 * Compiler ID
corsa1600 0:c3df3a527006 43 * ARM = 1
corsa1600 0:c3df3a527006 44 * GCC_ARM = 2
corsa1600 0:c3df3a527006 45 * IAR = 3
corsa1600 0:c3df3a527006 46 * [CPUID Register Information](#cpuid-register-information)
corsa1600 0:c3df3a527006 47 * [Compiler Version](#compiler-version)
corsa1600 0:c3df3a527006 48 * CPU Statistics
corsa1600 0:c3df3a527006 49 * Percentage of runtime that the device has spent awake versus in sleep
corsa1600 0:c3df3a527006 50 * Heap Statistics
corsa1600 0:c3df3a527006 51 * Current heap size
corsa1600 0:c3df3a527006 52 * Max heap size which refers to the largest the heap has grown to
corsa1600 0:c3df3a527006 53 * Thread Statistics
corsa1600 0:c3df3a527006 54 * Provides information on all running threads in the OS including
corsa1600 0:c3df3a527006 55 * Thread ID
corsa1600 0:c3df3a527006 56 * Thread Name
corsa1600 0:c3df3a527006 57 * Thread State
corsa1600 0:c3df3a527006 58 * Thread Priority
corsa1600 0:c3df3a527006 59 * Thread Stack Size
corsa1600 0:c3df3a527006 60 * Thread Stack Space
corsa1600 0:c3df3a527006 61
corsa1600 0:c3df3a527006 62 #### Compiler Version
corsa1600 0:c3df3a527006 63
corsa1600 0:c3df3a527006 64 | Compiler | Version Layout |
corsa1600 0:c3df3a527006 65 | -------- | -------------- |
corsa1600 0:c3df3a527006 66 | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
corsa1600 0:c3df3a527006 67 | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) |
corsa1600 0:c3df3a527006 68 | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
corsa1600 0:c3df3a527006 69
corsa1600 0:c3df3a527006 70 #### CPUID Register Information
corsa1600 0:c3df3a527006 71
corsa1600 0:c3df3a527006 72 | Bit Field | Field Description | Values |
corsa1600 0:c3df3a527006 73 | --------- | ----------------- | ------ |
corsa1600 0:c3df3a527006 74 |[31:24] | Implementer | 0x41 = ARM |
corsa1600 0:c3df3a527006 75 |[23:20] | Variant | Major revision 0x0 = Revision 0 |
corsa1600 0:c3df3a527006 76 |[19:16] | Architecture | 0xC = Baseline Architecture |
corsa1600 0:c3df3a527006 77 | | | 0xF = Constant (Mainline Architecture) |
corsa1600 0:c3df3a527006 78 |[15:4] | Part Number | 0xC20 = Cortex-M0 |
corsa1600 0:c3df3a527006 79 | | | 0xC60 = Cortex-M0+ |
corsa1600 0:c3df3a527006 80 | | | 0xC23 = Cortex-M3 |
corsa1600 0:c3df3a527006 81 | | | 0xC24 = Cortex-M4 |
corsa1600 0:c3df3a527006 82 | | | 0xC27 = Cortex-M7 |
corsa1600 0:c3df3a527006 83 | | | 0xD20 = Cortex-M23 |
corsa1600 0:c3df3a527006 84 | | | 0xD21 = Cortex-M33 |
corsa1600 0:c3df3a527006 85 |[3:0] | Revision | Minor revision: 0x1 = Patch 1 |
corsa1600 0:c3df3a527006 86
corsa1600 0:c3df3a527006 87
corsa1600 0:c3df3a527006 88
corsa1600 0:c3df3a527006 89 You can view individual examples and additional API information of the statistics collection tools at the bottom of the page in the [related links section](#related-links).
corsa1600 0:c3df3a527006 90
corsa1600 0:c3df3a527006 91
corsa1600 0:c3df3a527006 92 ### Output
corsa1600 0:c3df3a527006 93
corsa1600 0:c3df3a527006 94 To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/). Unless otherwise specified, printf defaults to a baud rate of 9600 on Mbed OS.
corsa1600 0:c3df3a527006 95
corsa1600 0:c3df3a527006 96 You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related [related links section](#related-links).
corsa1600 0:c3df3a527006 97
corsa1600 0:c3df3a527006 98 The output should contain the following block transmitted at the blinking LED frequency (actual values may vary depending on your target, build profile, and toolchain):
corsa1600 0:c3df3a527006 99
corsa1600 0:c3df3a527006 100 ```
corsa1600 0:c3df3a527006 101 =============================== SYSTEM INFO ================================
corsa1600 0:c3df3a527006 102 Mbed OS Version: 999999
corsa1600 0:c3df3a527006 103 CPU ID: 0x410fc241
corsa1600 0:c3df3a527006 104 Compiler ID: 2
corsa1600 0:c3df3a527006 105 Compiler Version: 60300
corsa1600 0:c3df3a527006 106 RAM0: Start 0x20000000 Size: 0x30000
corsa1600 0:c3df3a527006 107 RAM1: Start 0x1fff0000 Size: 0x10000
corsa1600 0:c3df3a527006 108 ROM0: Start 0x0 Size: 0x100000
corsa1600 0:c3df3a527006 109 ================= CPU STATS =================
corsa1600 0:c3df3a527006 110 Idle: 98% Usage: 2%
corsa1600 0:c3df3a527006 111 ================ HEAP STATS =================
corsa1600 0:c3df3a527006 112 Current heap: 1096
corsa1600 0:c3df3a527006 113 Max heap size: 1096
corsa1600 0:c3df3a527006 114 ================ THREAD STATS ===============
corsa1600 0:c3df3a527006 115 ID: 0x20001eac
corsa1600 0:c3df3a527006 116 Name: main_thread
corsa1600 0:c3df3a527006 117 State: 2
corsa1600 0:c3df3a527006 118 Priority: 24
corsa1600 0:c3df3a527006 119 Stack Size: 4096
corsa1600 0:c3df3a527006 120 Stack Space: 3296
corsa1600 0:c3df3a527006 121
corsa1600 0:c3df3a527006 122 ID: 0x20000f5c
corsa1600 0:c3df3a527006 123 Name: idle_thread
corsa1600 0:c3df3a527006 124 State: 1
corsa1600 0:c3df3a527006 125 Priority: 1
corsa1600 0:c3df3a527006 126 Stack Size: 512
corsa1600 0:c3df3a527006 127 Stack Space: 352
corsa1600 0:c3df3a527006 128
corsa1600 0:c3df3a527006 129 ID: 0x20000f18
corsa1600 0:c3df3a527006 130 Name: timer_thread
corsa1600 0:c3df3a527006 131 State: 3
corsa1600 0:c3df3a527006 132 Priority: 40
corsa1600 0:c3df3a527006 133 Stack Size: 768
corsa1600 0:c3df3a527006 134 Stack Space: 664
corsa1600 0:c3df3a527006 135
corsa1600 0:c3df3a527006 136 ```
corsa1600 0:c3df3a527006 137
corsa1600 0:c3df3a527006 138 ## Troubleshooting
corsa1600 0:c3df3a527006 139
corsa1600 0:c3df3a527006 140 If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
corsa1600 0:c3df3a527006 141
corsa1600 0:c3df3a527006 142 ## Related Links
corsa1600 0:c3df3a527006 143
corsa1600 0:c3df3a527006 144 * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html)
corsa1600 0:c3df3a527006 145 * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html)
corsa1600 0:c3df3a527006 146 * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html)
corsa1600 0:c3df3a527006 147
corsa1600 0:c3df3a527006 148 ### License and contributions
corsa1600 0:c3df3a527006 149
corsa1600 0:c3df3a527006 150 The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info.
corsa1600 0:c3df3a527006 151
corsa1600 0:c3df3a527006 152 This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.