Loading…
CppCon 2021 has ended
Thursday, October 28 • 10:30am - 11:30am
Handling a Family of Hardware Devices with a Single Implementation

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
Embedded software typically uses memory-mapped registers to communicate with hardware. These registers are often finicky and demanding. Software that accesses a hardware register in the wrong way often produces bugs that are hard to diagnose and fix. In this session, we’ll look at ways to use operator overloading, enumeration types, and other C++ features to craft interfaces that protect against such misuses. We’ll then look at techniques for generalizing that code so that one implementation works for many variations of the hardware.

Using real-world examples of 8-bit and 16-bit hardware timers, we’ll begin by constructing a safe interface for a specific hardware timer. From there, we’ll use templates to generalize the implementation to cover more timer variations. By isolating and extracting the differences between the timers, we’ll minimize the need for code duplication. We’ll also be able to write application code that works equally well with any of the timers. Along the way, we’ll deal with smaller problems, such as dealing with non-contiguous register layouts and guaranteeing that large values are locked during accesses.

This session uses concrete examples of timers in the ARM7 and Arduino MEGA 2560 architectures. However, the techniques from this session apply to a wide variety of platforms and hardware devices such as serial ports or I/O pins.

ALL TALK SESSIONS CAN BE ACCESSED FROM THE MAIN LOBBY: https://cppcon.digital-medium.co.uk/

Speakers
avatar for Ben Saks

Ben Saks

Chief Engineer, Saks & Associates
Ben Saks is the chief engineer of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. Ben has represented Saks & Associates on the ISO C++ Standards committee as well as two of the committee’s study groups: SG14 (low-latency... Read More →


Thursday October 28, 2021 10:30am - 11:30am MDT
  • Embedded, Online