code including all sensors

Dependencies:   LAAP AK8963

Committer:
Glaxys_finest1
Date:
Mon Nov 25 10:51:18 2019 +0000
Revision:
0:66a265dc3146
hello1

Who changed what in which revision?

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