Werluschnig: Aufgabe 7, 2 Threads, Temp Werte, Consumer, Producer

Dependencies:   C12832 LM75B

Committer:
martwerl
Date:
Mon Apr 29 14:58:34 2019 +0000
Revision:
0:f5de9cd30ded
Werluschnig: Aufgabe 7, zwei Threads, Tempwerte, Consumer, Producer;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martwerl 0:f5de9cd30ded 1 # Getting started example for Mbed OS
martwerl 0:f5de9cd30ded 2
martwerl 0:f5de9cd30ded 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).)
martwerl 0:f5de9cd30ded 4
martwerl 0:f5de9cd30ded 5 Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
martwerl 0:f5de9cd30ded 6
martwerl 0:f5de9cd30ded 7 ## Import the example application
martwerl 0:f5de9cd30ded 8
martwerl 0:f5de9cd30ded 9 From the command-line, import the example:
martwerl 0:f5de9cd30ded 10
martwerl 0:f5de9cd30ded 11 ```
martwerl 0:f5de9cd30ded 12 mbed import mbed-os-example-blinky
martwerl 0:f5de9cd30ded 13 cd mbed-os-example-blinky
martwerl 0:f5de9cd30ded 14 ```
martwerl 0:f5de9cd30ded 15
martwerl 0:f5de9cd30ded 16 ### Now compile
martwerl 0:f5de9cd30ded 17
martwerl 0:f5de9cd30ded 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:
martwerl 0:f5de9cd30ded 19
martwerl 0:f5de9cd30ded 20 ```
martwerl 0:f5de9cd30ded 21 mbed compile -m K64F -t ARM
martwerl 0:f5de9cd30ded 22 ```
martwerl 0:f5de9cd30ded 23
martwerl 0:f5de9cd30ded 24 Your PC may take a few minutes to compile your code. At the end, you see the following result:
martwerl 0:f5de9cd30ded 25
martwerl 0:f5de9cd30ded 26 ```
martwerl 0:f5de9cd30ded 27 [snip]
martwerl 0:f5de9cd30ded 28
martwerl 0:f5de9cd30ded 29 Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin
martwerl 0:f5de9cd30ded 30 ```
martwerl 0:f5de9cd30ded 31
martwerl 0:f5de9cd30ded 32 ### Program your board
martwerl 0:f5de9cd30ded 33
martwerl 0:f5de9cd30ded 34 1. Connect your Mbed device to the computer over USB.
martwerl 0:f5de9cd30ded 35 1. Copy the binary file to the Mbed device.
martwerl 0:f5de9cd30ded 36 1. Press the reset button to start the program.
martwerl 0:f5de9cd30ded 37
martwerl 0:f5de9cd30ded 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:
martwerl 0:f5de9cd30ded 39
martwerl 0:f5de9cd30ded 40 * System Information:
martwerl 0:f5de9cd30ded 41 * Mbed OS Version: Will currently default to 999999
martwerl 0:f5de9cd30ded 42 * Compiler ID
martwerl 0:f5de9cd30ded 43 * ARM = 1
martwerl 0:f5de9cd30ded 44 * GCC_ARM = 2
martwerl 0:f5de9cd30ded 45 * IAR = 3
martwerl 0:f5de9cd30ded 46 * [CPUID Register Information](#cpuid-register-information)
martwerl 0:f5de9cd30ded 47 * [Compiler Version](#compiler-version)
martwerl 0:f5de9cd30ded 48 * CPU Statistics
martwerl 0:f5de9cd30ded 49 * Percentage of runtime that the device has spent awake versus in sleep
martwerl 0:f5de9cd30ded 50 * Heap Statistics
martwerl 0:f5de9cd30ded 51 * Current heap size
martwerl 0:f5de9cd30ded 52 * Max heap size which refers to the largest the heap has grown to
martwerl 0:f5de9cd30ded 53 * Thread Statistics
martwerl 0:f5de9cd30ded 54 * Provides information on all running threads in the OS including
martwerl 0:f5de9cd30ded 55 * Thread ID
martwerl 0:f5de9cd30ded 56 * Thread Name
martwerl 0:f5de9cd30ded 57 * Thread State
martwerl 0:f5de9cd30ded 58 * Thread Priority
martwerl 0:f5de9cd30ded 59 * Thread Stack Size
martwerl 0:f5de9cd30ded 60 * Thread Stack Space
martwerl 0:f5de9cd30ded 61
martwerl 0:f5de9cd30ded 62 #### Compiler Version
martwerl 0:f5de9cd30ded 63
martwerl 0:f5de9cd30ded 64 | Compiler | Version Layout |
martwerl 0:f5de9cd30ded 65 | -------- | -------------- |
martwerl 0:f5de9cd30ded 66 | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
martwerl 0:f5de9cd30ded 67 | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) |
martwerl 0:f5de9cd30ded 68 | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
martwerl 0:f5de9cd30ded 69
martwerl 0:f5de9cd30ded 70 #### CPUID Register Information
martwerl 0:f5de9cd30ded 71
martwerl 0:f5de9cd30ded 72 | Bit Field | Field Description | Values |
martwerl 0:f5de9cd30ded 73 | --------- | ----------------- | ------ |
martwerl 0:f5de9cd30ded 74 |[31:24] | Implementer | 0x41 = ARM |
martwerl 0:f5de9cd30ded 75 |[23:20] | Variant | Major revision 0x0 = Revision 0 |
martwerl 0:f5de9cd30ded 76 |[19:16] | Architecture | 0xC = Baseline Architecture |
martwerl 0:f5de9cd30ded 77 | | | 0xF = Constant (Mainline Architecture) |
martwerl 0:f5de9cd30ded 78 |[15:4] | Part Number | 0xC20 = Cortex-M0 |
martwerl 0:f5de9cd30ded 79 | | | 0xC60 = Cortex-M0+ |
martwerl 0:f5de9cd30ded 80 | | | 0xC23 = Cortex-M3 |
martwerl 0:f5de9cd30ded 81 | | | 0xC24 = Cortex-M4 |
martwerl 0:f5de9cd30ded 82 | | | 0xC27 = Cortex-M7 |
martwerl 0:f5de9cd30ded 83 | | | 0xD20 = Cortex-M23 |
martwerl 0:f5de9cd30ded 84 | | | 0xD21 = Cortex-M33 |
martwerl 0:f5de9cd30ded 85 |[3:0] | Revision | Minor revision: 0x1 = Patch 1 |
martwerl 0:f5de9cd30ded 86
martwerl 0:f5de9cd30ded 87
martwerl 0:f5de9cd30ded 88
martwerl 0:f5de9cd30ded 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).
martwerl 0:f5de9cd30ded 90
martwerl 0:f5de9cd30ded 91
martwerl 0:f5de9cd30ded 92 ### Output
martwerl 0:f5de9cd30ded 93
martwerl 0:f5de9cd30ded 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.
martwerl 0:f5de9cd30ded 95
martwerl 0:f5de9cd30ded 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).
martwerl 0:f5de9cd30ded 97
martwerl 0:f5de9cd30ded 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):
martwerl 0:f5de9cd30ded 99
martwerl 0:f5de9cd30ded 100 ```
martwerl 0:f5de9cd30ded 101 =============================== SYSTEM INFO ================================
martwerl 0:f5de9cd30ded 102 Mbed OS Version: 999999
martwerl 0:f5de9cd30ded 103 CPU ID: 0x410fc241
martwerl 0:f5de9cd30ded 104 Compiler ID: 2
martwerl 0:f5de9cd30ded 105 Compiler Version: 60300
martwerl 0:f5de9cd30ded 106 RAM0: Start 0x20000000 Size: 0x30000
martwerl 0:f5de9cd30ded 107 RAM1: Start 0x1fff0000 Size: 0x10000
martwerl 0:f5de9cd30ded 108 ROM0: Start 0x0 Size: 0x100000
martwerl 0:f5de9cd30ded 109 ================= CPU STATS =================
martwerl 0:f5de9cd30ded 110 Idle: 98% Usage: 2%
martwerl 0:f5de9cd30ded 111 ================ HEAP STATS =================
martwerl 0:f5de9cd30ded 112 Current heap: 1096
martwerl 0:f5de9cd30ded 113 Max heap size: 1096
martwerl 0:f5de9cd30ded 114 ================ THREAD STATS ===============
martwerl 0:f5de9cd30ded 115 ID: 0x20001eac
martwerl 0:f5de9cd30ded 116 Name: main_thread
martwerl 0:f5de9cd30ded 117 State: 2
martwerl 0:f5de9cd30ded 118 Priority: 24
martwerl 0:f5de9cd30ded 119 Stack Size: 4096
martwerl 0:f5de9cd30ded 120 Stack Space: 3296
martwerl 0:f5de9cd30ded 121
martwerl 0:f5de9cd30ded 122 ID: 0x20000f5c
martwerl 0:f5de9cd30ded 123 Name: idle_thread
martwerl 0:f5de9cd30ded 124 State: 1
martwerl 0:f5de9cd30ded 125 Priority: 1
martwerl 0:f5de9cd30ded 126 Stack Size: 512
martwerl 0:f5de9cd30ded 127 Stack Space: 352
martwerl 0:f5de9cd30ded 128
martwerl 0:f5de9cd30ded 129 ID: 0x20000f18
martwerl 0:f5de9cd30ded 130 Name: timer_thread
martwerl 0:f5de9cd30ded 131 State: 3
martwerl 0:f5de9cd30ded 132 Priority: 40
martwerl 0:f5de9cd30ded 133 Stack Size: 768
martwerl 0:f5de9cd30ded 134 Stack Space: 664
martwerl 0:f5de9cd30ded 135
martwerl 0:f5de9cd30ded 136 ```
martwerl 0:f5de9cd30ded 137
martwerl 0:f5de9cd30ded 138 ## Troubleshooting
martwerl 0:f5de9cd30ded 139
martwerl 0:f5de9cd30ded 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.
martwerl 0:f5de9cd30ded 141
martwerl 0:f5de9cd30ded 142 ## Related Links
martwerl 0:f5de9cd30ded 143
martwerl 0:f5de9cd30ded 144 * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html)
martwerl 0:f5de9cd30ded 145 * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html)
martwerl 0:f5de9cd30ded 146 * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html)
martwerl 0:f5de9cd30ded 147
martwerl 0:f5de9cd30ded 148 ### License and contributions
martwerl 0:f5de9cd30ded 149
martwerl 0:f5de9cd30ded 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.
martwerl 0:f5de9cd30ded 151
martwerl 0:f5de9cd30ded 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.