mbino is a library that provides several mbed OS APIs for the Arduino platform.
Currently, the following APIs are - at least partially - supported:
- AnalogIn
- DigitalIn
- DigitalOut
- DigitalInOut
- Error
- InterruptIn
- I2C
- PortIn
- PortOut
- PortInOut
- PwmOut
- RawSerial
- Serial
- SPI
- Ticker
- Time
- Timeout
- Timer
- Wait
mbino is not a full port of the mbed operating system to 8-bit microcontrollers. It just implements some of the C++ APIs that are commonly used when developing applications for mbed OS. This means you will still write "sketches" for your Arduino board, and you can even use both mbed APIs and the "Arduino language", as well as native Arduino libraries, in your programs.
So, why would you want to use this?
-
You have to port existing mbed application code to the Arduino platform.
-
You want to write cross-platform libraries that target both mbed and Arduino, using a single code base.
-
You just happen to like mbed's C++ APIs, and don't want to go back.
Known Bugs and Limitations
-
Only AVR 8-bit microcontroller boards are supported. This means no support for Arduino Due, Zero or M0, for example.
-
To avoid ambiguities with Arduino's own global
Serial
andSPI
objects, you have to use the fully qualified class namesmbed::Serial
andmbed::SPI
when using these APIs. -
Since the default AVR Libc
printf()
family of functions does not support floating point conversions, floating point values cannot be used withSerial::printf()
orRawSerial::printf()
. -
To save on code size and SRAM usage,
stdin
,stdout
andstderr
are not connected to the USB debug port by default. Forprintf()
messages to be displayed in the Arduino IDE's serial monitor, you have to defineDEVICE_STDIO_MESSAGES
before includingmbed.h
, as shown in this example. -
For portability (and so
millis()
and PWM outputs still work), theTicker
API uses theTimer0
comparison register for generating ticker interrupts. Therefore,Ticker
only provides a resolution of about one millisecond. -
The
PwmOut::period()
andPwmOut::pulsewidth()
methods are only supported for PWM pins controlled by 16-bit timers, e.g. pins 9 and 10 on the Arduino Uno. For now, these methods are ignored for all other pins. Note that setting a period for one pin will also affect other pins controlled by the same timer. -
The
I2C
API is based on the Arduino Wire library. Since this library can substantially increase code size, I2C support is optional, and is disabled by default. To enable I2C support, you have to include<Wire.h>
before including<mbed.h>
. See the I2C examples for details. Also note that the Wire library does not support some of the lower-levelI2C
API methods, and that you are limited to reading and writing 32 bytes at a time. -
Serial interrupts are implemented using Arduino's serialEvent API. This means they are not really asynchronous, and may be deferred until your
loop()
function returns. Furthermore, onlyRxIrq
is supported withSerial::attach()
. -
Although mbino has been designed so that you usually don't pay for what you don't use, there still may be some overhead involved when compared to "native" Arduino code.
-
Keep in mind that you are still developing for an 8-bit platform, so only 8-bit variables can be read atomically, e.g. when passing data between an ISR and the main program. Also note that
int
is only 16 bits wide - that's why some APIs, such as thewait_ms()
andwait_us()
functions, have been changed to uselong
parameters. -
The library is called mbino, but in most cases you'll want to include
<mbed.h>
.
License
Copyright (c) 2017 Thomas Kemmer
mbed Microcontroller Library Copyright (c) 2006-2013 ARM Limited
Licensed under the Apache License, Version 2.0.