|
px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
|
The foundation of px-fwlib is knowledge and freedom: the knowledge and freedom to use the right microcontroller for the job and not trying to force a square peg in a round hole.
px-fwlib is a collection of open source C firmware and documentation for microcontrollers to develop portable bare-metal code that is vendor and architecture neutral (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 foundation before you are forced to add target specific code and getting locked in.
Click HERE to download releases of the open source library (source code and offline documentation).

STM32L072 PX-HER0 Board now in stock at Crowd Supply! Click HERE
My sincere hope is that seasoned veterans will pitch in and share their years of experience to mentor the future generation and raise the bar in terms of quality and quantity. See 1.7 Questions or Feedback?
This documentation is divided into the following sections:
Here is the collection of boards that are supported with Board Support Packages (BSP), documentation and complete examples:
| Microcontroller | Board |
|---|---|
| Microchip ATmega328P | Arduino Uno R3 board |
| Microchip ATmega328P | Microchip ATmega328P-XMINI Board |
| Microchip ATmega328PB | Microchip ATmega328PB-XMINI Board |
| Microchip ATmega328P | Piconomix ATmega328P Scorpion Board |
| ST STM32L072RB | Piconomix STM32L072RB PX-HER0 Board |
| ST STM32L053R8T6 | ST Nucleo64 L053R8 Board |
Here are four examples selected to pique your interest:
Included with the library is a CLI (Command Line Interpreter) executing on an Arduino Uno R3 that creates a "Un\*x 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).

Connect your board, fire up the CLI and verify that it works:

The BMP280 is found at 7-bit slave address 0x76. The chip identification register value for the BMP280 is 0x58. This confirms that you are able to write to and read from the I2C slave.
For more info see CLI Explorer (Command Line Interpreter).
This example demonstrates how easy it is to set up and communicate with an I2C slave device after you have verified with the CLI that it works:
This example demonstrates how easy and efficient it is to define and use a GPIO pin:
Even though it looks like functions calls are used, the lines reduce to single assembly statements for maximum efficiency and minimum code size. This is the generated assembly to inspect:
For IoT low power sensor nodes it is extremely important to wake up, do the job as fast as possible and go back to sleep again. C efficiency trumps C++ flexibility. Less code translates to a cheaper solution.
px_log_fs is a basic (but resilient) record-based file system to log data to AT45D DataFlash (or similiar serial flash storage). It is perfect for IoT (Internet of Things) low power sensor nodes that need to log data periodically, because it has basic wear levelling, handles 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 serial flash can also be reserved for secure "over-the-air" encrypted firmware upgrades.
Usage example:
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 critically: which is better?
Or
Inspect the assembly generated by the compiler. Maybe the compiler is smarter than you give it credit for (or not... it depends)
Evolve, improve or be left behind!
Questions or feedback (positive and negative) is great and will help to improve the library:

Methods of communication:
You are most welcome to submit bug fixes, new code or documentation. It should:
A significant amount of time has been invested to craft and refine this free open source library. If you saved development time, acquired a new skill, or advanced your career, you are welcome to support this project with a visit to the shop.

Click HERE to visit the shop