MHVLib - An Efficiency Oriented Runtime Library for AVR Microcontrollers
deece — Tue, 30/08/2011 - 12:44am
Having been frustrated with many of the inefficiencies of the Arduino core libraries, we have built an alternate set with performance and size in mind. Alastair has given a talk at the Canberra Linux User Group about this library - the slides can be viewed on SlideShare.
Much of the efficiency gains comes from addressing some of the key design deficiencies of the Arduino runtime - we do not store pin/port information in tables in flash, needlessly preallocate objects nor dictate that excessively large buffers must be used. Instead, control of these are handed over to the developer at compile time.
We recommend using cppcheck and the CPPCeclipse Eclipse Plugin for further bug checking in your code.
Design for the architecture
Favour efficiency over simplicity
Hide complexity using macros
Provide a rich API that exposes all likely usages that are expected
Fix all warnings!
Use appropriate datatypes, and use strict typing where possible to minimise the wrong variable being passed
Favour C++ references over pointers to reduce bad usage which can lead to crashes
Leverage inheritance to make generic routines available for all objects that need it
Expensive operations should be asynchronous where possible, so they run in the background while your code does other things
Enable an event driven approach
BSD licensed to encourage commercial use (there is a separate GPL project for ports of GPL software to MHVLib, such as V-USB)
We recommend developing your MHVlib projects in Eclipse. For instructions on how to do so, please see our tutorial.
If an Arduino-style bootloader is required, we recommend Optiboot, which clocks at only a quarter the size of the Arduino bootloader (0.5kb vs 2kb), and a programming baud rate of 115,200bps.
If USB is more your thing, you may want to consider USBaspLoader, which clocks in at 2kb (the same size as the Arduino bootloader), and pretends to be a USBasp programmer. This uses software USB (based on the V-USB library), removing the need for a USB->serial chip, and allows you to flash your chip over USB using AVRdude.
You can grab the libraries from our GIT repository at git.makehackvoid.com:
git clone http://git.makehackvoid.com/mhvlib.git
To update later...
You can also grab a tarball from the releases at the bottom of the page.
This software is licensed under the BSD license. This means you can do what you like with it, including distributing it with your own software licensed under different terms. The only restriction is that you attibute us for our work, and reproduce our copyright:
Copyright (c) 2011, Make, Hack, Void Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Make, Hack, Void nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MAKE, HACK, VOID BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Serial (both busy-waiting and asynchronous)
Analogue to digital
Gamma correction - calculate on the fly, or lookup tables (recommended)
Fast synchronous serial shifter
Software H Bridge for driving naked transistors (with PWM support)
Realtime Clock & event triggering
Debouncing (detect button presses, as well as held buttons)
Software PWM Matrix (for passive LED matrices)
HT1632 based LED matrix displays such as the Sure Electronics DE-DP105 (search for 0832 led matrix on Ebay)