Drivers, Frameworks and Threads, oh my!

The road to developing robust connected devices in a timely manner does not start by duplicating efforts and reinventing the wheel. Successful development teams build their applications on proven, ready-made drivers and frameworks. These building blocks are then stacked together using threads within a real-time operating system (RTOS) to create the end-application. In order to effectively use the Renesas Synergy Platform™, developers need to understand the drivers and frameworks that are available in addition to how to properly create threads. In this post, we will walk through these components and get a better idea how to use them within our development environment.


The first step to building any application is to identify the microcontroller peripherals that need to be used in the application. In order to operate these peripherals, a device driver needs to be added to the project. Now a device driver provides a contractually specified interface that allows higher level application code such as middleware or an RTOS to access low level hardware peripherals and registers without a detailed understanding for how the hardware works. Each microcontroller will have its own peripheral set that may vary slightly from one microcontroller to the next. The Synergy Software Package (SSP) and toolchain automatically take this into account and adapt the device drivers and configuration based on the target microcontroller. The image below demonstrates the different peripheral types a developer would find on a Synergy S7 Series microcontroller, in particular from the S7G2 MCU Group:





Device drivers make the microcontroller easier to understand and control. Frameworks perform a similar function but at a higher level within the software architecture. Frameworks provide a ready-made scaffolding that allow developers to quickly and efficiently develop applications. A framework may contain individual components, libraries and even development tools such as compilers and code analyzers. You can consider a framework to be a specialized toolset that is focused on providing an application specific function. Frameworks encourage software reuse and can drastically speed up the development cycle. In many instances, frameworks will have a dependency on the device drivers that control the hardware.


In order to get a good feel for the device drivers and frameworks that are provided with the Synergy Platform, it can be useful to examine the high level component diagram for the SSP shown below where frameworks are named Application Frameworks within the SSP. As can be seen from a quick glance, every imaginable driver is provided within the Hardware Abstraction Layer (HAL) such as CAN, UART, USB, watchdog and low power mode drivers. Complicated but repetitive functions such as capacitive touch sensing, graphics generation and power profiling are packaged as Application Frameworks.




Drivers and Application Frameworks are the basic building blocks that Synergy Platform developers use to jump start their application development. Developers stitch these components together in their application using an RTOSes thread capability. Many developers use the terms threads and tasks interchangeably which is probably okay for an embedded software developer but it is useful to realize that there is a subtle difference between the two.


The ThreadX® documentation for the Synergy Platform (I highly recommend readers peruse this document since there are some great insights into how to develop real-time embedded systems) provides a great definition for tasks, processes and threads. From the documentation, “A task is a semi-independent portion of the application that carries out a specific duty. It sometimes means a separately loadable program. In other instances, it may refer to an internal program segment.


A process is a completely independent program that has its own address space, while a thread is a semi-independent program segment that executes within a process. Threads share the same process address space. The overhead associated with thread management is minimal.”


Now in English, basically a task is a vague and generic term that can mean multiple things when applied to software applications. Threads on the other hand, are specifically referring to a “mini-program” that is running on the embedded system. In a traditional embedded systems environment, creating a thread looks pretty nasty and complicated. For example, initializing a thread that simply blinks an LED would look something like the following:



Pull out your documentation because there is no way you are going to remember what all those parameters are actually doing. Most are obvious but all those ones in a row makes it easy to forget (which is also why good documentation in coding is important). The Synergy Tools make creating a thread super simple. A developer needs to open the SSP configuration file associated with their project and under the Threads tab simply click the add thread button. Clicking on the properties tab reveals a simple tabular approach to initializing the thread:



Wow! That is much simpler than having to write code and figure out what all those function parameters need to be. Adding device drivers and Application Framework components to be executed with the thread is just as simple. From the exact same threads tab, a developer can select the thread that a driver or Application Framework should be added to and then they simply add the desired driver or Application Framework from a menu. It sounds too simple but check out the following screenshot and you can see for yourself that adding drivers and Application Frameworks to a SSP project is all done using easy to use graphical wizards, configurators or menu options.



Drivers, Application Frameworks and threads are the fundamental software blocks that developers use to build their applications. Drivers and Application Frameworks are provided as part of the SSP and it’s up to the application developers to use threads to piece together their application.


Next week we will take a closer look at threads and how to setup inter-thread communication using the messaging framework.


Live long and profit!





Hot Tip of the Week?


Explore these new Sample Projects -


Learn how to use the Capacitive Touch Sensing Unit (CTSU) for slider and wheel functions using the DK-S124 kit as an example.

App Note:            Application Note document

Project:                Sample Project file


Pair the DK-S7G2 or the DK-S3A7 kit to an iOS-based device using Bluetooth Low Energy

App Note:           Application Note document

Project:               Sample Project file