The foundation of piconomic-fwlib is knowledge and freedom: the knowledge and freedom to use the right microcontroller for the job and not trying to fit a square peg in a round hole.
piconomic-fwlib is a collection of C firmware and documentation for microcontrollers to develop code 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 Questions or Feedback (please!) .
This documentation is divided into the following sections:
Here are four 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.
C code mixed with generated assembly listing:
For IoT low power sensor nodes it is extremely important to wake up, do something as fast as possible and go back to sleep again. C efficiency trumps C++ flexibility. Less code translates to a cheaper solution.
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 CLI (Command Line Interpreter) that creates a "Linux Shell"-like environment running on the microcontroller so that you can experiment with GPIO, ADC, I2C and SPI using only an ANSI/VT100 terminal emulator (for example Tera Term).
Defining commands and using the CLI module is easy (I hope)
log_fs is a simple (but robust!) record-based file system to log data to AT45D DataFlash (or other similiar flash storage). It is perfect for IoT (Internet of Things) low power sensor nodes that need to log data periodically, because it can handle power loss gracefully, requires less code and data memory and executes quickly which means you can get away with a smaller, cheaper microcontroller.
A section of the external AT45D DataFlash can also be reserved for secure "over-the-air" encrypted firmware upgrades.
For a complete working example (with nice flash file system debugging), see Temp&Pressure Data Logger Application.
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. You don't know what you are missing! Try the evaluation version for the whole 30 days before dismissing my advice. 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 library requires time and money to improve and grow (neither of which is free). Despite this, an extremely lenient and fairly priced licensing model was selected to support both open or closed source (commercial) development. If you think it is unfair in any way or are discouraged from using or contributing to the library, PLEASE LET ME KNOW! See Questions or Feedback (please!) .
To comply with clause 3 of The Piconomic FW Library Open License, the following text and URL must be added to all internet publications (including advertisements) of your project or product:
Uses Piconomic FW Library <http://piconomic.co.za>
A significant amount of time and effort has been invested to create, publish and refine this library. Respect the license conditions!
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 info, please read the FAQ .
There's no such thing as a stupid question (only stupid answers?). A question posed is an opportunity for me to improve the library, because it will highlight areas that are unclear or difficult to understand.
Like it? Hate it? Think it has no value? Clear or confusing? Language too simple or too sophisticated? Pitched too low or too high? Either way, PLEASE send me a short (or long) message to let me know what you want or think so that I can try to improve the library and companion boards. Your brutally honest feedback (positive or negative) is vital to me so that I know if I'm on the right track or not.
Methods of communication:
I respect your privacy and won't divulge or use your contact details for any purpose without your explicit permission.
If you submit new code or a bug fix (please do!), it must:
To be clear: when you submit any new code, 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... Joking aside, why would you want to contribute new code or bug fixes if you don't benefit financially? When the library achieves critical mass, you will benefit from an extensively tried and tested ecosystem.
Share and Enjoy!