Mbed Studio
Mbed Studio is an IDE for embedded devices. It directly ties in with the firmware framework mbed-os
which provides a HAL and RTOS for ARM Cortex microcontrollers. Mbed Studio is based of the Eclipse Theia IDE, which is itself based of Visual Studio Code.
Mbed Studio uses ARM Compiler 6 (as of June 2020).
Installation
Mbed Studio can be installed on Linux, MacOS and Windows.
Default directory for projects is <user-home-directory>/Mbed Programs/<project-name>
.
Debugging
For flashing and debugging microcontrollers, Mbed Studio uses the PyOCD library. pyOCD is an open-source Python library for programming and debugging Arm Cortex-M microcontrollers.
Library Manager
With what feels like a breath of fresh air for the embedded community, Mbed Studio comes with a library manager which is designed quite well. Mbed Studio allows you to add libraries to your project via the GUI or CLI (using the mbed add
command). The source of the library must be os.mbed.com
URL (for open-source, shared libraries) or a git URL (for both open-source shared libraries and private libraries).
Once the library has been added, the code is downloaded into the project directory (with the exception of the large mbed-os
, which has the special ability of being able to be shared across multiple projects if desired). A <project-name>.lib
file is created in the project directory which tracks the URL and commit hash of library, so that you lock down the version and can reproduce the build exactly. e.g. mbed-os.lib
might look like:
Testing
Mbed Studio and the mbed CLI have built in support for various forms of testing. The have support for the following types of tests:
- Unit tests: These are defined as tests that run on the native development computer (i.e. not on target microcontroller).
- Functional tests: These run on the target hardware.
Unit Tests
All unit tests should be in a UNITTESTS
directory in the root of your project.
Mbed uses cmake
to drive the building of the unit tests.
Mbed Version Preprocessor Definitions
Mbed provides the following preprocessor #define
macros in mbed_version.h
:
Adding Custom Boards
See https://os.mbed.com/docs/mbed-os/v6.0/porting/porting-custom-boards.html.
HAL Support
If you get the pin configuration wrong, Mbed will print an error using printf()
at runtime, e.g. if I configured a BufferedSerial
and passed in the TX and RX pins in the wrong order:
You get the runtime error:
APIs
The mbed-os
API is documented with Doxygen-style in-code comments.
Timer
Timers can be used to keep track of periods of time in a precise manner (with typically sub-microsecond accuracy).
The timer API can be used from within interrupts.
Serial
As of mbed v6.0, Serial
has been deprecated in favour of BufferedSerial
and UnbufferedSerial
.
SPI
Interrupts
Interrupts based of digital pin changes can be created and managed with InterruptIn()
objects. For example, to create one for digital pin 5 and then print a message to the serial port everytime the voltage on the pin goes from low to high: