Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

SimplePublish for ARM mbed

A SimplePublish example has been created on the mbed OS developer siteQSL SimplePublish. This  This is a free, online code editor and compiler that allows you to write code for the mbed OS. This makes it very easy to port code to the different supported platforms.

...

Tip

The example code is written and tested on the NUCLEO-L053R8, but you should be able to compile it for any mbed supported platform that has an avalilable UART by defining the correct UART RX/TX pins in dn_uart.cpp.pins (see the Adaptations section below).

Prepare Your Platform

Log into your mbed account (or signup for one if you haven't already) and get started by selecting your platform on the mbed developer page: https://developer.mbed.org/platforms/.

...

The page for your platform should include instructions on how to set it up and install any necessary drivers.
For our example, the page for NUCLEO-L058R8 informs us that we need to:

...

For the Nucleo boards you can follow the instructions on the SMT32 example page for the NUCLEO-L053R8 (the relevant pins are all the same).

Otherwise you should refer to the general instructions and the pinout of your platform.

...

The SimplePublish example program will send all standard output (e.g. debug prints) through the mbed default serial port (defined by SERIAL_TX, SERIAL_RX). For most platforms this will be a serial port that is spawned via USB: If you are using a Nucleo board you can see the instructions on the SMT32 example page on how to identify the correct portname; for other boards you should consult the mbed SerialPC page.

...

Tip
You can (de)activate debug and log messages with the NDEBUG and NLOG defines in dn_debug.h (located in sm_qsl/).
Note

Note that there appears to be an issue with the serial output from the ST-LINK/V2 on the Nucleo boards.


Compile and Run the Program

Import to Your Compiler Workspace

  1. Head to the Code page for the SimplePublish program and press the big yellow button:
  2. This should open the Import Program window in the Compiler online IDE:
    Source URL: httphttps://developer.mbed.org/usersteams/jhbrQSL/code/QSL_SimplePublish/
    Import As: Select Program
    Import Name: Rename the program if you want to
    Update: Check to update the libraries that the program depends on (only the main mbed library)
  3. Press Import.
  4. You should now see the program listed under My Programs.

...

  • dn_uart.cpp: Change the UART_MOTE_TX and UART_MOTE_RX defines to the correct pins for your platform.
  • main.cpp: Change the LED define passed to DigitalOut myled() to the correct one for your platform.
  • dn_endianness.c: These functions are implemented for a little-endian platform, hence you need to change them if your platform is big-endian.
Tip

You can find the correct names of relevant pins for your platform on its mbed platform page (the labels written in blue/white or green/white).

Build

To only build the program, select it in the Program Workspace window and press Compile > Build Only (Ctrl+B).
This will build the program for the platform you selected, and any errors/warnings should appear in the bottom Compile Output window. You will probably get some warnings about some depreciated declarations in the sm_clib (which you can safely ignore), but if you get any errors you should consult the previous section.

...

Again, with the program selected, press Compile > Compile (Ctrl+D).
This will build the program and compile it to a binary that is downloaded via your browser. To flash the binary to your platform, simply save it directly to the device. You can also save it somewhere on your computer and simply copy/drag it to your device afterwards.

For the Nucleo boards, the big LD1 LED will flash green/red alternately during the transfer, ending in solid green upon completion.

...