Embedded Office Blog

Embedded Market, Basics, Functional Safety, Embedded Security

Powerful new API perspective in embedded software development

by Embedded Office (comments: 0)

Technological advancements, enhanced system connectivity and new features have seen embedded software and security become more complicated in modern microcontroller systems. Consequently, more than ever, developers face the challenge of increasing system functionality and efficiency while reducing overall cost.

For these reasons, reusable code is growing in popularity within the embedded software development community. To facilitate this recycling of software, APIs (application programming interfaces) supplement the usually smaller and highly device-specific HALs (hardware abstraction layers), which traditionally use low-level code to access and manage the core processes and functions of microcontroller hardware.

This new tendency is gathering pace in the industry and will likely see a rise in higher level coding principles, in preference to the relatively dated methodology of detailed machine-based instructions. Here, we review some fundamental principles and best practices for developing embedded software APIs.

Project preparation phase

To achieve the highest standards in APIs, proper initial planning is crucial. According to prominent speakers at ESC (the Embedded Systems Conference) held in April in Boston, USA, the type of case studies that take place in business and the medical world can be applied equally to software development for embedded systems. Industry experts consider that such case studies play a valuable role in the evaluation process as they reduce errors that have already occurred elsewhere. Additionally, if suitable code segments or expertise are available, a case study means that the developer team concerned will not spend time and effort reinventing the wheel.

Getting it right

As is commonly the case with its larger scale IT development cousin, embedded software API development also needs to be an iterative process – i.e. not followed only once. From draft specifications through prototyping to user testing and feedback, changes will be necessary to ensure that the final version is fit for purpose.

Vendors and portability

Portability between different microcontrollers is an important issue. If a peripheral is likely to be fitted with similar controller hardware but from different vendors, the API development process needs to cater for these variants. Experts suggest that developer teams study the individual microcontroller data sheets and draw up a list of common features shared by each similar microcontroller model. The project can then incorporate these collective features into an industry standard API, with separate additional extensions as required for those features which are different.

Simplicity and subroutines

Simplicity is essential. More than ten or twelve maximum major code segments or interfaces can complicate understanding; multiple nested subroutine calls and returns can baffle even the most experienced developers.

Good coding practices include pre-conditions and built in checks when calling a routine, as well as sensing that post-conditions have been met – i.e. that the API has performed its function correctly. In other words, a defensive approach with double-checking tends to increase the robustness of the system, as opposed to merely assuming that the system hardware is in a given state when calling a subroutine. Proper interrupt handling such as callback registration also improves controller stability and memory protection.1

Additional considerations

Apart from future proofing by including the option to add future extensions if necessary, the interface extensions themselves also require testing and need to be free of defects. Finally, other recommended practices include using logical naming conventions – general first, specific second.

In summary, the drive to reduce costs and shorten the development lifecycle has long been a priority in embedded security and systems. Now, with the latest microcontrollers boasting processor capacities similar to the early x86-series computer chips, APIs and reused code will also become increasingly important.

Summary

In this post, we have looked at some key ideas and important technical considerations to help developers reuse their code and create quality APIs for embedded systems. Developing APIs in addition to HALs is now almost part of every embedded security and system project to shorten the development cycle, decrease costs and reduce time to market. In today’s systems, microcontrollers have attained such high levels of performance that APIs are now necessary to manage complexity, reuse code and gain a business advantage - while also following industry recommendations and best practices.


  1. Proper Interrupt Handling to improve controller stability. http://www.edn.com/Home/PrintView?contentItemId=4440897 ↩︎

Go back

Update Notification

For an automatic notification on new blog articles, just register your EMail address.

We are the Blogger:

Andrea Dorn

After my study of industrial engineering I worked at an engineering service provider. As team leader and sales representative, I was responsible for customers from aviation and mechanical engineering. I am part of the Embedded Office team since 2010. Here I am responsible for the Sales and Marketing activities. I love being outside for hiking, riding or walking no matter the weather.

Fridolin Kolb

I have more than 20 years experience in developing safety critical software as developer and project manager in medical, aerospace and automotive industries. I am always keen on finding a solution for any problem. The statement “This won’t never work”, will never work for me. In my spare time You can find me playing the traverse flute in our local music association, spending time with my family, or in a session as member of our local council and member of the local church council. So obviously I am lacking the ability to say “No” to any challenge ;-).

Michael Hillmann

I have been working for 20 years in safety critical software development. Discussing and solving challenges with customers and colleagues excites me again and again. In my spare time I can be found while hiking, spending time with my family, having a sauna with friends - or simply reading a good book.

Wolfgang Engelhard

I’m a functional safety engineer with over 10 years of experience in software development. I’m most concerned with creating accurate documentation for safety critical software, but lately found joy in destruction of software (meaning I’m testing). Spare time activities range from biking to mentoring a local robotics group of young kids.

Matthias Riegel

Since finishing my master in computer science (focus on Embedded Systems and IT-Security), I’ve been working at Embedded Office. Before that, I worked with databases, and learned many unusual languages (like lisp, clojure, smalltalk, io, prolog, …). In my spare time I’m often on my bike, at the lathe or watching my bees.