mbed OS V5 BLE UARTService to USB/UART PassThru Example
Moxon Design : mbed OS V5 BLE UartService to USBUART passthru example
This example will advertise on BLE as "BLART" and allow BLE serial echo to the USB Serial port. Open a Bluetooth terminal application, like Nordic "nRF UART" and connect to "BLART", open a terminal emulator program, like "TeraTERM", and connect to the USB COM Port (like JLink CDC UART Port), and echo characters back and forth. Set UART_LoopBack = 1 for local loopback (e.g. BLE to BLE, USB-UART to USB-UART)
README.md@0:2d1d68397ff7, 2017-04-28 (annotated)
- Committer:
- moxondesign
- Date:
- Fri Apr 28 20:51:34 2017 +0000
- Revision:
- 0:2d1d68397ff7
- Child:
- 2:3e203cc2a88f
Local Loopback Tested Good.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moxondesign | 0:2d1d68397ff7 | 1 | # Getting started with Blinky on mbed OS |
moxondesign | 0:2d1d68397ff7 | 2 | |
moxondesign | 0:2d1d68397ff7 | 3 | This guide reviews the steps required to get Blinky working on an mbed OS platform. |
moxondesign | 0:2d1d68397ff7 | 4 | |
moxondesign | 0:2d1d68397ff7 | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
moxondesign | 0:2d1d68397ff7 | 6 | |
moxondesign | 0:2d1d68397ff7 | 7 | ## Import the example application |
moxondesign | 0:2d1d68397ff7 | 8 | |
moxondesign | 0:2d1d68397ff7 | 9 | From the command-line, import the example: |
moxondesign | 0:2d1d68397ff7 | 10 | |
moxondesign | 0:2d1d68397ff7 | 11 | ``` |
moxondesign | 0:2d1d68397ff7 | 12 | mbed import mbed-os-example-blinky |
moxondesign | 0:2d1d68397ff7 | 13 | cd mbed-os-example-blinky |
moxondesign | 0:2d1d68397ff7 | 14 | ``` |
moxondesign | 0:2d1d68397ff7 | 15 | |
moxondesign | 0:2d1d68397ff7 | 16 | ### Now compile |
moxondesign | 0:2d1d68397ff7 | 17 | |
moxondesign | 0:2d1d68397ff7 | 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: |
moxondesign | 0:2d1d68397ff7 | 19 | |
moxondesign | 0:2d1d68397ff7 | 20 | ``` |
moxondesign | 0:2d1d68397ff7 | 21 | mbed compile -m K64F -t ARM |
moxondesign | 0:2d1d68397ff7 | 22 | ``` |
moxondesign | 0:2d1d68397ff7 | 23 | |
moxondesign | 0:2d1d68397ff7 | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
moxondesign | 0:2d1d68397ff7 | 25 | |
moxondesign | 0:2d1d68397ff7 | 26 | ``` |
moxondesign | 0:2d1d68397ff7 | 27 | [snip] |
moxondesign | 0:2d1d68397ff7 | 28 | +----------------------------+-------+-------+------+ |
moxondesign | 0:2d1d68397ff7 | 29 | | Module | .text | .data | .bss | |
moxondesign | 0:2d1d68397ff7 | 30 | +----------------------------+-------+-------+------+ |
moxondesign | 0:2d1d68397ff7 | 31 | | Misc | 13939 | 24 | 1372 | |
moxondesign | 0:2d1d68397ff7 | 32 | | core/hal | 16993 | 96 | 296 | |
moxondesign | 0:2d1d68397ff7 | 33 | | core/rtos | 7384 | 92 | 4204 | |
moxondesign | 0:2d1d68397ff7 | 34 | | features/FEATURE_IPV4 | 80 | 0 | 176 | |
moxondesign | 0:2d1d68397ff7 | 35 | | frameworks/greentea-client | 1830 | 60 | 44 | |
moxondesign | 0:2d1d68397ff7 | 36 | | frameworks/utest | 2392 | 512 | 292 | |
moxondesign | 0:2d1d68397ff7 | 37 | | Subtotals | 42618 | 784 | 6384 | |
moxondesign | 0:2d1d68397ff7 | 38 | +----------------------------+-------+-------+------+ |
moxondesign | 0:2d1d68397ff7 | 39 | Allocated Heap: unknown |
moxondesign | 0:2d1d68397ff7 | 40 | Allocated Stack: unknown |
moxondesign | 0:2d1d68397ff7 | 41 | Total Static RAM memory (data + bss): 7168 bytes |
moxondesign | 0:2d1d68397ff7 | 42 | Total RAM memory (data + bss + heap + stack): 7168 bytes |
moxondesign | 0:2d1d68397ff7 | 43 | Total Flash memory (text + data + misc): 43402 bytes |
moxondesign | 0:2d1d68397ff7 | 44 | Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin |
moxondesign | 0:2d1d68397ff7 | 45 | ``` |
moxondesign | 0:2d1d68397ff7 | 46 | |
moxondesign | 0:2d1d68397ff7 | 47 | ### Program your board |
moxondesign | 0:2d1d68397ff7 | 48 | |
moxondesign | 0:2d1d68397ff7 | 49 | 1. Connect your mbed device to the computer over USB. |
moxondesign | 0:2d1d68397ff7 | 50 | 1. Copy the binary file to the mbed device. |
moxondesign | 0:2d1d68397ff7 | 51 | 1. Press the reset button to start the program. |
moxondesign | 0:2d1d68397ff7 | 52 | |
moxondesign | 0:2d1d68397ff7 | 53 | The LED on your platform turns on and off. |
moxondesign | 0:2d1d68397ff7 | 54 | |
moxondesign | 0:2d1d68397ff7 | 55 | ## Export the project to Keil MDK, and debug your application |
moxondesign | 0:2d1d68397ff7 | 56 | |
moxondesign | 0:2d1d68397ff7 | 57 | From the command-line, run the following command: |
moxondesign | 0:2d1d68397ff7 | 58 | |
moxondesign | 0:2d1d68397ff7 | 59 | ``` |
moxondesign | 0:2d1d68397ff7 | 60 | mbed export -m K64F -i uvision |
moxondesign | 0:2d1d68397ff7 | 61 | ``` |
moxondesign | 0:2d1d68397ff7 | 62 | |
moxondesign | 0:2d1d68397ff7 | 63 | To debug the application: |
moxondesign | 0:2d1d68397ff7 | 64 | |
moxondesign | 0:2d1d68397ff7 | 65 | 1. Start uVision. |
moxondesign | 0:2d1d68397ff7 | 66 | 1. Import the uVision project generated earlier. |
moxondesign | 0:2d1d68397ff7 | 67 | 1. Compile your application, and generate an `.axf` file. |
moxondesign | 0:2d1d68397ff7 | 68 | 1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). |
moxondesign | 0:2d1d68397ff7 | 69 | 1. Set breakpoints, and start a debug session. |
moxondesign | 0:2d1d68397ff7 | 70 | |
moxondesign | 0:2d1d68397ff7 | 71 | ![Image of uVision](img/uvision.png) |
moxondesign | 0:2d1d68397ff7 | 72 | |
moxondesign | 0:2d1d68397ff7 | 73 | ## Troubleshooting |
moxondesign | 0:2d1d68397ff7 | 74 | |
moxondesign | 0:2d1d68397ff7 | 75 | 1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0` |
moxondesign | 0:2d1d68397ff7 | 76 | |
moxondesign | 0:2d1d68397ff7 | 77 | ``` |
moxondesign | 0:2d1d68397ff7 | 78 | mbed --version |
moxondesign | 0:2d1d68397ff7 | 79 | ``` |
moxondesign | 0:2d1d68397ff7 | 80 | |
moxondesign | 0:2d1d68397ff7 | 81 | If not, you can update it: |
moxondesign | 0:2d1d68397ff7 | 82 | |
moxondesign | 0:2d1d68397ff7 | 83 | ``` |
moxondesign | 0:2d1d68397ff7 | 84 | pip install mbed-cli --upgrade |
moxondesign | 0:2d1d68397ff7 | 85 | ``` |
moxondesign | 0:2d1d68397ff7 | 86 | |
moxondesign | 0:2d1d68397ff7 | 87 | 2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size. |