Skip to content
0:00 / 0:00

#c++#memory-mappedi/o#placementnew

Memory-Mapped Devices as Objects - Dan Saks - CppCon 2020

CppCon

189K subscribers • 136 videos on Hallway • Conference channel

YouTube
  • Recommended by 5 people: 5 in engineering communities.
  • Presented by Dan Saks
  • Linked in the descriptionCppCon/CppCon2020

Intermediate. Assumes working knowledge.

28K views6 years ago5 recommendations

Programming languagesSystems programmingC++Embedded systemsDesign patterns

Dan Saks explains how to use C++ techniques to represent memory-mapped device registers as objects with proper initialization and behavior.

cppcon.org/ github.com/CppCon/CppCon2020 --- Most, if not all, modern CPUs communicate with external devices via memory-mapped device registers. A memory-mapped register is circuitry that connects to a CPU’s bus structure and responds to bus signals almost as if it were ordinary memory. Almost, but not quite. C++ programs can use C features such as pointers and casts to access memory-mapped registers. This is still widespread practice. However, traditional C techniques tend to treat memory-mapped registers more as raw storage than as objects with constrained behaviors. C idioms for accessing memory-mapped devices leave too many opportunities for programming errors and late nights with a debugger. This session explains various C++ techniques for placing objects into memory-mapped locations and for guaranteeing proper initialization and destruction. It shows how you can use base classes and templates to capture commonalities among different devices that use similar register layouts. By applying these techniques, you’ll be able to package memory-mapped devices as lightweight class objects that are easy to use correctly and hard to use incorrectly. --- Dan Saks is the president of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. Dan used to write the “Programming Pointers” column for embedded.com online. He has also written columns for numerous print publications including The C/C++ Users Journal, The C++ Report, Software Development, and Embedded Systems Design. With Thomas Plum, he wrote C++ Programming Guidelines, which won a 1992 Computer Language Magazine Productivity Award. Dan has taught C and C++ to thousands of programmers around the world. He has presented at conferences such as Software Development, Embedded Systems, and C++ World. He has served on the advisory boards of the Embedded Systems and Software Development conferences. Dan served as secretary of the ANSI and ISO C++ Standards committees and as a member of the ANSI C Standards committee. More recently, he contributed to the CERT Secure C Coding Standard and the CERT Secure C++ Coding Standard. --- Streamed & Edited by Digital Medium Ltd - events.digital-medium.co.uk events@digital-medium.co.uk *-----* Register Now For CppCon 2022: cppcon.org/registration/ *-----*

Why it's here

5 people recommend this

What people say. Recommended as an excellent guide on using C++ features like placement new to safely model hardware registers in embedded systems.

u/dstdudein r/embedded • Recommends

On “C++ under the hood”

I also like the idea of using C++ on embedded systems. But this still seems to be a rebellious idea. I'd love to see us combing our researched sources here. I've found useful stuff from Dan Saks, Michael Caisse and Wouter van Ooijen. [video [video [video [video [video [video If you google "Dan Saks embedded c++ filetype:pdf" you will find the same ideas presented in the video in form of texts. Great mind, great guy, great presenter - his talk "Talking to C Programmers about C++" really chanced some of my mindset! I also found some stuff, where the authors were talking about themself using C++ in an embedded environment, but all their material I found online explained C++…

u/AudioRevelationsC++ Advocatein r/embedded • Recommends

On “Embedded c++”

As far as I know there aren't any embedded-specific c++ resources out there at the moment. If you find any I'd love to hear about them! There are a few speakers that tend to focus more on embedded like Dan Saks and Michael Caisse, but IMO most of their talks are either too general or not beginner friendly. Worth checking out, though! In general the things you have to keep in mind are: - you generally shouldn't use exceptions - you generally shouldn't use the heap/dynamic allocation (this can make using the STL a bit tricky, ETL is a good option) - usage of zero-cost abstractions (i.e. classes, structs, basic inheritance, etc.) are all fair game - folks are still out on if `virtual` ma…

u/kruizer23in r/embedded • Recommends

On “How to typecast from int to pointer at compile time in cpp (STM32 peripherals)”

Dan Saks did a pretty good presentation on this. You can find it here.

u/hachanuyin r/embedded • Recommends

On “Microcontrollers and C++ Placement New”

link to this video this may be something that interests you about this topic.

u/fjpoloC/C++14 | ARM | QCCin r/embedded • Recommends

On “Learn a new language after C. Rust or C++?”

Not much to add to the comments, I'm personally not that deep into Rust yet, but getting there and always learning new things about both C++ and C. But It did want to share some, in my opinion, cool conferences: Kate Gregory - Stop teaching C Dan Saks - extern c: Talking to C Programmers about C++ Dan Saks - Memory-Mapped Devices as Objects