Blog Reader

  • Home
  • Blog
  • Powerful new API perspective in embedded software development

 

 
 

Portfolio Projects

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. https://www.edn.com/Home/PrintView?contentItemId=4440897 ↩︎

Go back

You are interested in a free talk to an expert...

Arrange an expert meeting

We offer a free and non-committal interview with one of our experts. We can get to know each other, answer your open questions and also discuss the first requirements of your project.