Few bit from the past
Fig.1 - IDE or Text Editor?
I had the impression of traveling to the past! Where is the function call hierarchy view? How to move around the source code? To find a function definition I had to to use the “Find in files…” command, like the first version of a text editor … I struggled to identify design pattern in a monolithic source code made by a main function and very long ISR. RTOS and the concept of multi tasking were ... well, they were something like evil, good only to increase the memory footprint and to reduce the performance!
That was the beginning of the computer programming science, just after the punched card, it doesn’t look like 2004.
Fig.2 - A punched card
I thought that there was work to be done. As we said in Italy, it is time to "rimboccarci le maniche". The first step was to look around in the Open Source world to find the good things available for STM32. The idea was to use Eclipse as IDE and to integrate some interesting open source project like FatFS and lwIP in a multi-tasking environment. And FreeRTOS was the best choice.
In this way the ODeV idea was born, as reported in my first web site:
At the beginning it was the makefile, then I switched to a managed build system based on the GNU-MCU Eclipse plugin.
The first interesting project was a power metering system connecting millions of nodes. Working on it I started to see, in my everyday work, how important is to have a robust runtime environment for tasks. This allow me to reuse the code and so, to improve it while working to the next project. And to implement this approach I need a framework common to all my applications.
A GPS tolling system was another import project and an important step to consolidate my approach to the firmware development. In that project I introduced the concept of Managed Task. It was not a perfect implementation, but the idea was already clear in my mind.
I thought that it was the time for the next step in the embedded firmware development: Object Oriented Programming (OO). With my passion for programming and design pattern I start working at the idea of a C++ framework for multi tasking embedded application, the FreeRTOS Embedded Class (FreeRTOS_EC), and the firmware was like this:
/**
* Heap allocated task object
*/
CHelloWorld *g_pLed1Task;
/**
* Global task objects.
*/
CHelloWorld g_Led2Task(GPIOE, GPIO_Pin_14, 1000);
CCheckTask g_checkTask(4000/portTICK_RATE_MS);
/**
* Main program.
*/
int main() {
prvSetupHardware();
// While usually dynamic memory is not a good practice in an embedded
// program, this task is allocated on the heap only to test if the low
// level layer works fine.
// (linker script and runtime support)
g_pLed1Task = new CHelloWorld(GPIOD, GPIO_Pin_13, 2000);
g_pLed1Task->Create("Led1", configMINIMAL_STACK_SIZE, mainFLASH_TASK_PRIORITY);
g_Led2Task.Create("Led2", configMINIMAL_STACK_SIZE, mainFLASH_TASK_PRIORITY);
// Static task object
static CHelloWorld led3Task(GPIOD, GPIO_Pin_3 | GPIO_Pin_4, 3000);
led3Task.Create("Led3", configMINIMAL_STACK_SIZE, mainFLASH_TASK_PRIORITY);
CFreeRTOS::InitHardwareForManagedTasks();
CFreeRTOS::StartScheduler();
while(1);
return 0;
}
The application is defined by a set of managed tasks implementing a common base abstract class. All FreeRTOS object are wrapped in a correspondent class that owns the native handle. This is implemented in a efficient way.
But it was too far ahead of the times, and most of the firmware engineers were not comfortable to program their app in C++.
This bring the story to recent day and the ODeV framework available in this web site. The same idea, refined during the years and tested with many real projects and products like the firmware of keyboards you can find in your favorite shop.
And thanks to ST, now, Hardware and Firmware and IDE are more and more integrated…