Making things do stuff – Part 8

We’ve been using templates to provide a hardware register abstraction for use with hardware manipulation problems, typical of what you’d find in a deeply-embedded (“bare-metal”) system.

Previously, we looked at using trait classes to establish pointers and tag-dispatch to handle special-case registers, such as read-only or write-only register.

In this article we’re going to add some syntactic sugar to our Register class, to allow the developer to access individual bits in the register using array-index ([]) notation.  This will allow us to explore the concept of proxy objects with a concrete and practical use case.

If you’re new to hardware manipulation in C++, I’d recommend going back to the basics article for a refresher of what we’re trying to achieve.

If you’re familiar with hardware manipulation, I’d highly recommend going back to article 2 to familiarise yourself with our problem domain.

Continue reading

Posted in General | Tagged , , , | 2 Comments

Making things do stuff – Part 7

In our previous article we explored using templates to build a generic ‘register’ type to allow programmers to access hardware without all the nasty syntax of integer-to-pointer casting, etc.

At the moment, this class gives us little extra functionality beyond cleaning up the syntax (although, in its favour, it also doesn’t incur any additional run-time cost/performance).

In this article we’re going to extend our design to consider special hardware register types – notably read-only and write-only registers – and see how we can add extra functionality to our Register type.

Although there is more than one way to solve this problem we’re going to use a simple function-overload selection mechanism called ‘tag dispatch’.

Continue reading

Posted in C/C++ Programming | Tagged , , , , , , | 2 Comments

Making things do stuff – Part 6

As code designers we tend to eschew specific ‘stove-pipe’ code in favour of reusable code elements.  Up until now we’ve been coding some very specific examples so it’s probably worth looking at some more generic solutions.

In this article we’ll look at building generic register manipulation classes (or, as one commenter referred to them, ‘register proxy’ classes).  Here, we’re really exploring code design rather than coding ‘mechanics’.  I’m using this to explore some factors like the balance between efficiency, performance and flexibility.

I’ll be making some design choices that you may not agree with.  That’s fine.  Leave your discussion points in the comments below.

If you’re new to hardware manipulation in C++, I’d recommend going back to the basics article for a refresher of what we’re trying to achieve.

Continue reading

Posted in C/C++ Programming | Tagged , , , , , , , | 2 Comments

Making things do stuff – Part 5

We’ve been looking at using C++ to manipulate I/O hardware.   Previously, we’ve looked at the fundamentals of hardware manipulation; and how to encapsulate these mechanisms into classes.  If you’ve not been following along I’d recommend reading the previous articles first before continuing.

This time we’ll explore a lesser-known feature of C++ and its application in hardware manipulation – placement new.

Continue reading

Posted in C/C++ Programming | Tagged , , , , , | Leave a comment

Making things do stuff – Part 4

In the last article we explored the design of a class to encapsulate a physical hardware device.  In that article I deliberately ignored how the class would actually interact with the hardware.

In this article we explore the options available to us for accessing hardware and the consequences of those choices.

Continue reading

Posted in ARM, C/C++ Programming, Cortex, General | Tagged , , , , , , | Leave a comment

Making things do stuff – Part 3

Previously, we’ve looked at the basics of hardware manipulation in C++ and applied that to a simple GPIO implementation.

In this article we’re going to have a look at encapsulating our code in a class and look at some of the design choices we have to make.

If you’re not familiar with hardware manipulation in C++ I’d highly recommend reading the previous articles in this series before continuing.

Even if you’re familiar with the concepts of hardware manipulation, if you haven’t read the second article I’d highly recommend reviewing it so your familiar with the problem we’re tackling.

Continue reading

Posted in C/C++ Programming, Cortex, Design Issues | Tagged , , , , , , , , | Leave a comment

Making things do stuff – Part 2

Last time we looked at the basics of hardware manipulation in C++.   This time we’ll apply this to some real hardware and have a look at the code generated.

Continue reading

Posted in C/C++ Programming, Cortex, General | Tagged , , , , , , , | 4 Comments

Agile for Embedded Conference – Early Bird registration ends this week

Our early bird offer ends on 31 March, so book now and join us on 3 May for a day dedicated to Agile for Embedded.

The agenda pronises an exciting event and included talks from industry guest speakers Ericsson Television, Altran, and Dyson, all sharing their experiences.

Click here to find out more about the speakers, presentation abstracts or to book your place.  https://www.feabhas.com/agile-for-embedded-conference.

Posted in Agile, General | Leave a comment

Making things do stuff – Part 1

C has long been the language of choice for smaller, microcontroller-based embedded systems; particularly for close-to-the-metal hardware manipulation.

C++ was originally conceived with a bias towards systems programming; performance and efficiency being key design highlights.  Traditionally, many of the advancements in compiler technology, optimisation, etc., had centred around generating code for PC-like platforms (Linux, Windows, etc).  In the last few years C++ compiler support for microcontroller targets has advanced dramatically, to the point where Modern C++ is a increasingly attractive language for embedded systems development.

In this set of articles we will explore how to use Modern C++ to manipulate hardware on a typical embedded microcontroller.

As the articles progress we’ll look at how we can use C++’s features to hide the actual underlying hardware of our target system and provide an abstract hardware API that developers can work to.  We’ll explore the performance (in terms of memory and code size) of these abstractions compared to their C counterparts.

We’ll begin by having a look at the very basics of hardware manipulation – accessing hardware devices and bit manipulation.

Continue reading

Posted in C/C++ Programming, Cortex | Tagged , , , | 13 Comments

Agile for Embedded Conference announcement

Whilst there are a number of conferences dedicated to Agile and Scrum, content dedicated to looking at Agile from an embedded systems development perspective is much more scarce and a topic in which many of us are interested.

Although we don’t generally use the Blog to promote events, we think our conference is unique and definitely worth a mention.Agile for embedded conference

3 May, Easthampstead Park, Berkshire

The day offers a pragmatic and practical approach to using Agile in the embedded development environment.

What’s on the agenda?

Using a mix of keynote sessions, user experiences, vendor presentations and an exhibition, the day will review modern Agile practices in the context of embedded development, share experiences of using Agile in this context, as well as stimulate discussion around Agile development and the specific challenges of being Agile in an embedded environment.

Who should attend?

It is aimed at senior engineers and managers responsible for the development of embedded systems, as well as at embedded developers and engineers with an interest in Agile.

Learn more.

Book your place

For information on sponsorship opportunities, please contact +44 (0) 1793 792909 or email conference@feabhas.com.

Posted in Agile, Testing, training | Tagged , | Leave a comment