piconomic-fwlib is a collection of C firmware and documentation for microcontrollers that proposes a unified approach so that code can be developed that is vendor and architecture independent (or easier to reuse). It is tough to find the best compromise between lean 8-bit targets, middle-of-the-road 16-bit targets, and resource rich 32-bit targets, but this cross-platform library aims to provide a good start before you are forced to add target specific code and getting locked in.
The library (source code and offline documentation) can be downloaded here.
My sincere hope is that seasoned veterans will pitch in and share their years of experience to mentor the future generations and raise the bar in terms of quality and quantity. See Feedback, bug fixes and code and documentation contributions .
Great athletes spend years tweaking tiny aspects of their performance to get a competitive edge: bicycle riders adapt their posture in a wind tunnel, golfers analyse their swing,... Like the shark became the apex predator of the sea, we as coders must be inspired to evolve and perfect our art or wither.
Without mentorship, we tend to get stuck with the first coding style and programming patterns that we learned and keep on using it without a second thought, sometimes even justifying and defending it religiously.
After you have written a piece of code, take a break, return and spend 15 minutes to question if the code you have just written is the optimal / best / most readable solution (applying advice from Edward de Bono, the father of lateral thinking). Refactor, rinse, repeat. Next time you will use this improved snippet instead of copying and adapting the same old, inferior code from memory.
Ask yourself: which is better?
Inspect the assembly generated by the compiler...
Evolve, improve or be left behind!
As artisans that code for food, we must buy and use the BEST editor, like SlickEdit, not the low budget / free one that we got used to. Think it through! If you use an editor every day to ply your trade and a better editor saves you just 5 - 15 minutes a day, then it will be the best personal tool investment you ever made and it will give you a legal edge over your colleagues and competitors. Don't just gloss over this advice, try the evaluation version for the whole 30 days and then make your decision. I am confident that SlickEdit will make a massive improvement in your productivity!
I have been discovering and using cool SlickEdit features since 1999.
This documentation is divided into the following sections:
A BSD license was modified and applied to promote and maximize adoption of the library and grant freedom to develop open or closed source (commercial) applications. Please familiarize yourself with the conditions of the license: The Piconomic FW Library Open License
A significant amount of time and effort has been invested to create, publish and refine this library. Respect the license conditions!
To comply with clause 3, the following text and URL must be added to all internet publications (including advertisements) of your project or product:
Uses Piconomic FW Library <http://www.piconomic.co.za>
A single developer commercial license or company commercial license can be purchased which will grant you or your company an exemption from clause 2 and 3 of the The Piconomic FW Library Open License. The proceeds will be used for the continuous development and refinement of this library, hosting costs, etc. For more information see The Piconomic FW Library Commercial License.
Here are three select examples to pique your interest:
This example demonstrates how easy it is to define and use a GPIO pin:
Even though it appears that functions calls are used, the lines reduce to single assembly statements for maximum efficiency and minimum code size:
This example demonstrates how easy it is to set up and use a UART peripheral. After the set up phase (using architecture specific options), the driver is abstracted and the same code can be used on different architectures:
This example demonstrates a Command Line Interpreter interfacing with a ANSI/VT100 terminal emulator.
Defining commands and using the CLI module is easy (I hope)
I strive for coding excellence and appreciate any constructive criticism, bug fixes, spelling or grammar improvements (Afrikaans is my 1st language), new code or better documentation that will improve and expand this library. At the moment it is supported in my free time (after work, family, friends, sport, ...) so please use your discretion when contacting me and be economical. For example:
Here is a bug fix patch generated with TortoiseSVN that fixes the "counter roll-over" bug in "counting_sheep.c". P.S. I love your library, even my wife gives it a thumbs up!
Methods of communication:
Please do not feel offended if I do not respond. It may just be that I finally figured out how to build a time machine and am immersed in that or spending some nice vacation time in 1992...
For consideration, your code or bug fix patch must:
To be clear: when you submit anything, you also give me explicit permission to sell an exemption to clause 2 and 3 of The Piconomic FW Library Open License and use the funds to take over the WORLD! Bwah Ha Ha!! Ahem...
Share and Enjoy!
Kom ons praat weer Afrikaans, laat ons kinders dans, loshande hang oor die krans met onverbeterlike balans. Kom ons vat die kans. Kom ons praat weer Afrikaans! -- Diana Ferrus --