Barr Group TwitterBarr Group Vimeo

Course Overview

Course Length: 
3 Days
CEUs: 
2.0
Format: 
Hands-on (3 days) / Lecture-only (2 days)

 Download the Complete Course Syllabus

This course explains how to use C++ to write efficient and maintainable embedded programs.  More specifically, it shows how to leverage C++'s classes and templates to write readable, yet efficient, abstractions to represent and manipulate peripheral hardware in a bare metal environment.  Although the course focuses primarily on coding techniques that employ only standard features of the C++ programming language, a few non-standard approaches are demonstrated by necessity.

Most of the constructs that C++ provides for controlling hardware devices, including pointers, bitwise operators and bitfields, and the const and volatile qualifiers, are also features of C.  Despite this, C++ has a lot to offer to embedded programmers.  For example, classes can be very helpful in hiding the messy details of interacting with hardware behind clean APIs.  As well, templates and inheritance are able to capture commonality and promote reuse, and overloading and user-defined type conversions can support friendlier and safer user interfaces.  Modern C++ increases readability and aids in the prevention and handling of run-time errors with minimal impact on code execution time.

This course is available in both two-day and three-day versions. The three-day version covers more topics. See the Syllabus section below for details.  The three-day course also includes programming exercises designed to reinforce the lessons presented.

Topics covered during this course include:

  • Enumeration and Class Types
  • The const and volatile Qualifiers
  • Nested Constants and Types
  • Function and Operator Overloading
  • Inheritance
  • Templates
  • Language Linkage
  • Hardware Interfacing
  • Interrupt Handling (3-day only)
  • Error Handling

This course is appropriate for:

  • C++ programmers seeking to enhance their hardware interfacing skills
  • Embedded software developers moving from C to C++

Prerequisites:  Attendees should arrive with experience programming in C and at least some familiarity with the C++ programming language.  Experience writing device drivers is helpful but not required.  If your team is entirely new to C++, our two day "C++ for C Programmers" course should be taken prior to this advanced course.

Syllabus

The following is a summary of the major course topics and are not the section-by-subsection lecture breakdown.

Introduction

  • Course Overview
  • Expectations

Fundamental Concepts

  • Obsolete and Deprecated Features
  • Erroneous and Non-Portable Behaviors
  • Translation Units and Object Modules
  • Declarations and Definitions
  • Arguments and Parameters
  • Scope vs. Linkage vs. Storage Duration

Data Types

  • Static Checking
  • size_t and Extended Integer Types
  • New-Style Casts

The const and volatile Qualifiers

  • cv-qualifiers: const and volatile
  • The Structure of Declarations
  • Writing T const vs. const T
  • const as a Promise
  • Qualification Conversions
  • const and Class Design
  • const Member Functions
  • Symbolic Constants

Classes and Objects

  • Storage Layout for Class Objects
  • Implementing Member Function Calls
  • C++ Classes vs. C Structures

Device Register Addressing

  • Representing Memory-Mapped Registers
  • "Placing" Memory-Mapped Objects
  • Overly-Aggressive Optimization
  • Semantics of volatile
  • The Right Does of Volatility
  • Overloading for a Better Interfacing
  • Rethinking the ++ Operator
  • Enumeration Ranges
  • Improving Type-Safety
  • Referencing Memory-Mapped Objects
  • Constructors and new-Expressions
  • Capturing Device Commonality in a Base Class
  • Private Inheritance
  • Using-Declarations and Access-Declarations

Templates in Brief

  • Function Templates
  • Template Type Arguments and Parameters
  • Template Argument Deduction
  • Class Templates
  • Template Non-Type Arguments and Parameters

Build-Time Error Detection

  • Write-Only Class Templates
  • const vs. Read-Only
  • Read-Only Class Templates
  • Disallowing Copy Operations
  • Preventing Dynamic Allocation (3-day only)

Interrupt Handling (3-day only)

  • Polling vs. Interrupts
  • Interrupt Numbers, Vectors, and Vector Tables
  • Interrupt Service Routines
  • Linking C++ with C and Assembly
  • Name Mangling and Language Linking
  • Encapsulating Shared Data
  • Race Conditions
  • Critical Sections
  • Atomic Data Types

Advanced Interrupt Dispatch Techniques (3-day only)

  • Virtual Function Interrupt Dispatcher
  • Template-based Interrupt Dispatcher

Modern C++ Features

  • Type Traits
  • Enumeration Base Types and Scope
  • Generalized Constant Expressions
  • User-Defined Literals
  • auto as a Type Specifier
  • range-for Statements

Related Courses

Find out More

To find out more about our upcoming public trainings, go to our Training Calendar.

Contact Us to find out more about this course or to enquire about an on-site training at your company.

Recording Policy

All Barr Group Training Public and On-site courses may not be audiotaped, videotaped or photographed without consent from Barr Group's executive team.  Barr Group reserves the right to record portions or all of a training course for instructional purposes.  As a result, attendees present may also appear on the recording.