Init project for GPS

Committer:
AustinKim
Date:
Wed Sep 18 04:23:32 2019 +0000
Revision:
3:3fed3b61771e
Parent:
0:6d4ac55b6b76
Update main.cpp

Who changed what in which revision?

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