Simple implementation of goal counter for table football using laser diode and phototransistor.
Dependencies: GoalCounter WS2812 PixelArray
README.md@6:a93ee22232f2, 2019-01-14 (annotated)
- Committer:
- nxf46245
- Date:
- Mon Jan 14 17:48:30 2019 +0000
- Revision:
- 6:a93ee22232f2
- Parent:
- 0:24f846b68c77
Code cleaning, added winner animation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nxf46245 | 0:24f846b68c77 | 1 | # Getting started example for Mbed OS |
nxf46245 | 0:24f846b68c77 | 2 | |
nxf46245 | 0:24f846b68c77 | 3 | This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. |
nxf46245 | 0:24f846b68c77 | 4 | |
nxf46245 | 0:24f846b68c77 | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
nxf46245 | 0:24f846b68c77 | 6 | |
nxf46245 | 0:24f846b68c77 | 7 | ## Import the example application |
nxf46245 | 0:24f846b68c77 | 8 | |
nxf46245 | 0:24f846b68c77 | 9 | From the command-line, import the example: |
nxf46245 | 0:24f846b68c77 | 10 | |
nxf46245 | 0:24f846b68c77 | 11 | ``` |
nxf46245 | 0:24f846b68c77 | 12 | mbed import mbed-os-example-blinky |
nxf46245 | 0:24f846b68c77 | 13 | cd mbed-os-example-blinky |
nxf46245 | 0:24f846b68c77 | 14 | ``` |
nxf46245 | 0:24f846b68c77 | 15 | |
nxf46245 | 0:24f846b68c77 | 16 | ### Now compile |
nxf46245 | 0:24f846b68c77 | 17 | |
nxf46245 | 0:24f846b68c77 | 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 5: |
nxf46245 | 0:24f846b68c77 | 19 | |
nxf46245 | 0:24f846b68c77 | 20 | ``` |
nxf46245 | 0:24f846b68c77 | 21 | mbed compile -m K64F -t ARM |
nxf46245 | 0:24f846b68c77 | 22 | ``` |
nxf46245 | 0:24f846b68c77 | 23 | |
nxf46245 | 0:24f846b68c77 | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
nxf46245 | 0:24f846b68c77 | 25 | |
nxf46245 | 0:24f846b68c77 | 26 | ``` |
nxf46245 | 0:24f846b68c77 | 27 | [snip] |
nxf46245 | 0:24f846b68c77 | 28 | +----------------------------+-------+-------+------+ |
nxf46245 | 0:24f846b68c77 | 29 | | Module | .text | .data | .bss | |
nxf46245 | 0:24f846b68c77 | 30 | |--------------------|-----------|----------|----------| |
nxf46245 | 0:24f846b68c77 | 31 | | [fill] | 98(+0) | 0(+0) | 2211(+0) | |
nxf46245 | 0:24f846b68c77 | 32 | | [lib]/c.a | 27835(+0) | 2472(+0) | 89(+0) | |
nxf46245 | 0:24f846b68c77 | 33 | | [lib]/gcc.a | 3168(+0) | 0(+0) | 0(+0) | |
nxf46245 | 0:24f846b68c77 | 34 | | [lib]/misc | 248(+0) | 8(+0) | 28(+0) | |
nxf46245 | 0:24f846b68c77 | 35 | | [lib]/nosys.a | 32(+0) | 0(+0) | 0(+0) | |
nxf46245 | 0:24f846b68c77 | 36 | | main.o | 924(+0) | 0(+0) | 12(+0) | |
nxf46245 | 0:24f846b68c77 | 37 | | mbed-os/components | 134(+0) | 0(+0) | 0(+0) | |
nxf46245 | 0:24f846b68c77 | 38 | | mbed-os/drivers | 56(+0) | 0(+0) | 0(+0) | |
nxf46245 | 0:24f846b68c77 | 39 | | mbed-os/features | 42(+0) | 0(+0) | 184(+0) | |
nxf46245 | 0:24f846b68c77 | 40 | | mbed-os/hal | 2087(+0) | 8(+0) | 152(+0) | |
nxf46245 | 0:24f846b68c77 | 41 | | mbed-os/platform | 3633(+0) | 260(+0) | 209(+0) | |
nxf46245 | 0:24f846b68c77 | 42 | | mbed-os/rtos | 9370(+0) | 168(+0) | 6053(+0) | |
nxf46245 | 0:24f846b68c77 | 43 | | mbed-os/targets | 9536(+0) | 12(+0) | 382(+0) | |
nxf46245 | 0:24f846b68c77 | 44 | | Subtotals | 57163(+0) | 2928(+0) | 9320(+0) | |
nxf46245 | 0:24f846b68c77 | 45 | Total Static RAM memory (data + bss): 12248(+0) bytes |
nxf46245 | 0:24f846b68c77 | 46 | Total Flash memory (text + data): 60091(+0) bytes |
nxf46245 | 0:24f846b68c77 | 47 | |
nxf46245 | 0:24f846b68c77 | 48 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
nxf46245 | 0:24f846b68c77 | 49 | ``` |
nxf46245 | 0:24f846b68c77 | 50 | |
nxf46245 | 0:24f846b68c77 | 51 | ### Program your board |
nxf46245 | 0:24f846b68c77 | 52 | |
nxf46245 | 0:24f846b68c77 | 53 | 1. Connect your mbed device to the computer over USB. |
nxf46245 | 0:24f846b68c77 | 54 | 1. Copy the binary file to the mbed device. |
nxf46245 | 0:24f846b68c77 | 55 | 1. Press the reset button to start the program. |
nxf46245 | 0:24f846b68c77 | 56 | |
nxf46245 | 0:24f846b68c77 | 57 | 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: |
nxf46245 | 0:24f846b68c77 | 58 | |
nxf46245 | 0:24f846b68c77 | 59 | * System Information: |
nxf46245 | 0:24f846b68c77 | 60 | * Mbed OS Version: Will currently default to 999999 |
nxf46245 | 0:24f846b68c77 | 61 | * Compiler ID |
nxf46245 | 0:24f846b68c77 | 62 | * ARM = 1 |
nxf46245 | 0:24f846b68c77 | 63 | * GCC_ARM = 2 |
nxf46245 | 0:24f846b68c77 | 64 | * IAR = 3 |
nxf46245 | 0:24f846b68c77 | 65 | * [CPUID Register Information](#cpuid-register-information) |
nxf46245 | 0:24f846b68c77 | 66 | * [Compiler Version](#compiler-version) |
nxf46245 | 0:24f846b68c77 | 67 | * CPU Statistics |
nxf46245 | 0:24f846b68c77 | 68 | * Percentage of runtime that the device has spent awake versus in sleep |
nxf46245 | 0:24f846b68c77 | 69 | * Heap Statistics |
nxf46245 | 0:24f846b68c77 | 70 | * Current heap size |
nxf46245 | 0:24f846b68c77 | 71 | * Max heap size which refers to the largest the heap has grown to |
nxf46245 | 0:24f846b68c77 | 72 | * Thread Statistics |
nxf46245 | 0:24f846b68c77 | 73 | * Provides information on all running threads in the OS including |
nxf46245 | 0:24f846b68c77 | 74 | * Thread ID |
nxf46245 | 0:24f846b68c77 | 75 | * Thread Name |
nxf46245 | 0:24f846b68c77 | 76 | * Thread State |
nxf46245 | 0:24f846b68c77 | 77 | * Thread Priority |
nxf46245 | 0:24f846b68c77 | 78 | * Thread Stack Size |
nxf46245 | 0:24f846b68c77 | 79 | * Thread Stack Space |
nxf46245 | 0:24f846b68c77 | 80 | |
nxf46245 | 0:24f846b68c77 | 81 | #### Compiler Version |
nxf46245 | 0:24f846b68c77 | 82 | |
nxf46245 | 0:24f846b68c77 | 83 | | Compiler | Version Layout | |
nxf46245 | 0:24f846b68c77 | 84 | | -------- | -------------- | |
nxf46245 | 0:24f846b68c77 | 85 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
nxf46245 | 0:24f846b68c77 | 86 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
nxf46245 | 0:24f846b68c77 | 87 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
nxf46245 | 0:24f846b68c77 | 88 | |
nxf46245 | 0:24f846b68c77 | 89 | #### CPUID Register Information |
nxf46245 | 0:24f846b68c77 | 90 | |
nxf46245 | 0:24f846b68c77 | 91 | | Bit Field | Field Description | Values | |
nxf46245 | 0:24f846b68c77 | 92 | | --------- | ----------------- | ------ | |
nxf46245 | 0:24f846b68c77 | 93 | |[31:24] | Implementer | 0x41 = ARM | |
nxf46245 | 0:24f846b68c77 | 94 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
nxf46245 | 0:24f846b68c77 | 95 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
nxf46245 | 0:24f846b68c77 | 96 | | | | 0xF = Constant (Mainline Architecture) | |
nxf46245 | 0:24f846b68c77 | 97 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
nxf46245 | 0:24f846b68c77 | 98 | | | | 0xC60 = Cortex-M0+ | |
nxf46245 | 0:24f846b68c77 | 99 | | | | 0xC23 = Cortex-M3 | |
nxf46245 | 0:24f846b68c77 | 100 | | | | 0xC24 = Cortex-M4 | |
nxf46245 | 0:24f846b68c77 | 101 | | | | 0xC27 = Cortex-M7 | |
nxf46245 | 0:24f846b68c77 | 102 | | | | 0xD20 = Cortex-M23 | |
nxf46245 | 0:24f846b68c77 | 103 | | | | 0xD21 = Cortex-M33 | |
nxf46245 | 0:24f846b68c77 | 104 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
nxf46245 | 0:24f846b68c77 | 105 | |
nxf46245 | 0:24f846b68c77 | 106 | |
nxf46245 | 0:24f846b68c77 | 107 | |
nxf46245 | 0:24f846b68c77 | 108 | 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). |
nxf46245 | 0:24f846b68c77 | 109 | |
nxf46245 | 0:24f846b68c77 | 110 | |
nxf46245 | 0:24f846b68c77 | 111 | ### Output |
nxf46245 | 0:24f846b68c77 | 112 | |
nxf46245 | 0:24f846b68c77 | 113 | 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/). |
nxf46245 | 0:24f846b68c77 | 114 | |
nxf46245 | 0:24f846b68c77 | 115 | The default baud rate for this application is set to `115200` and may be modified in the `mbed_app.json` file. |
nxf46245 | 0:24f846b68c77 | 116 | |
nxf46245 | 0:24f846b68c77 | 117 | You can find more information on the Mbed OS configuration tools and serail communication in Mbed OS in the related [related links section](#related-links). |
nxf46245 | 0:24f846b68c77 | 118 | |
nxf46245 | 0:24f846b68c77 | 119 | 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): |
nxf46245 | 0:24f846b68c77 | 120 | |
nxf46245 | 0:24f846b68c77 | 121 | ``` |
nxf46245 | 0:24f846b68c77 | 122 | =============================== SYSTEM INFO ================================ |
nxf46245 | 0:24f846b68c77 | 123 | Mbed OS Version: 999999 |
nxf46245 | 0:24f846b68c77 | 124 | CPU ID: 0x410fc241 |
nxf46245 | 0:24f846b68c77 | 125 | Compiler ID: 2 |
nxf46245 | 0:24f846b68c77 | 126 | Compiler Version: 60300 |
nxf46245 | 0:24f846b68c77 | 127 | ================= CPU STATS ================= |
nxf46245 | 0:24f846b68c77 | 128 | Idle: 98% Usage: 2% |
nxf46245 | 0:24f846b68c77 | 129 | ================ HEAP STATS ================= |
nxf46245 | 0:24f846b68c77 | 130 | Current heap: 1096 |
nxf46245 | 0:24f846b68c77 | 131 | Max heap size: 1096 |
nxf46245 | 0:24f846b68c77 | 132 | ================ THREAD STATS =============== |
nxf46245 | 0:24f846b68c77 | 133 | ID: 0x20001eac |
nxf46245 | 0:24f846b68c77 | 134 | Name: main_thread |
nxf46245 | 0:24f846b68c77 | 135 | State: 2 |
nxf46245 | 0:24f846b68c77 | 136 | Priority: 24 |
nxf46245 | 0:24f846b68c77 | 137 | Stack Size: 4096 |
nxf46245 | 0:24f846b68c77 | 138 | Stack Space: 3296 |
nxf46245 | 0:24f846b68c77 | 139 | |
nxf46245 | 0:24f846b68c77 | 140 | ID: 0x20000f5c |
nxf46245 | 0:24f846b68c77 | 141 | Name: idle_thread |
nxf46245 | 0:24f846b68c77 | 142 | State: 1 |
nxf46245 | 0:24f846b68c77 | 143 | Priority: 1 |
nxf46245 | 0:24f846b68c77 | 144 | Stack Size: 512 |
nxf46245 | 0:24f846b68c77 | 145 | Stack Space: 352 |
nxf46245 | 0:24f846b68c77 | 146 | |
nxf46245 | 0:24f846b68c77 | 147 | ID: 0x20000f18 |
nxf46245 | 0:24f846b68c77 | 148 | Name: timer_thread |
nxf46245 | 0:24f846b68c77 | 149 | State: 3 |
nxf46245 | 0:24f846b68c77 | 150 | Priority: 40 |
nxf46245 | 0:24f846b68c77 | 151 | Stack Size: 768 |
nxf46245 | 0:24f846b68c77 | 152 | Stack Space: 664 |
nxf46245 | 0:24f846b68c77 | 153 | |
nxf46245 | 0:24f846b68c77 | 154 | ``` |
nxf46245 | 0:24f846b68c77 | 155 | |
nxf46245 | 0:24f846b68c77 | 156 | ## Troubleshooting |
nxf46245 | 0:24f846b68c77 | 157 | |
nxf46245 | 0:24f846b68c77 | 158 | 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. |
nxf46245 | 0:24f846b68c77 | 159 | |
nxf46245 | 0:24f846b68c77 | 160 | ## Related Links |
nxf46245 | 0:24f846b68c77 | 161 | |
nxf46245 | 0:24f846b68c77 | 162 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
nxf46245 | 0:24f846b68c77 | 163 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
nxf46245 | 0:24f846b68c77 | 164 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |