Welcome to
Code Exchange

As embedded electronics continues to transform our lives, engineers around the globe are looking for ways to increase their coding chops. To help engineers meet this need, element14 has unveiled Code Exchange-- a place where engineers can help each other.

Blog - Post List
  • embedded C++: manage a resource with a tiny* object

    *tiny like in: 0 bits of data, 0 code instructions added, 0 clock ticks scenario: you have a resource that needs to be initialised before use, and deactivated when done. We usually do that by calling some code before the actions, and some code after ...
  • embedded C++: add cheap bitwise conversion to a register structure

    This blog is based on real world work. I'm controlling a TI DRV8711 stepper motor controller via SPI. I need to modify 16-bit registers of that IC. TI provided a header file with register definitions, and code to convert that struct to a 16 bit ...
  • modern C++: restrict templated types with concept

    In C++, templates allow you to write generic code, that can handle many types. But almost always, there will be types you can't handle. In my case, I have a callback manager that supports functions that return a void, a number, a bool or a class...
  • C++ classes and operators

    This is a "classic C++" post, something that's been part of the language since conception: How to use an operator in your class design. I developed a callback class. Your "gizmo that needs to callback something" would hold an instance of that class (...
  • let CMake fetch your build dependencies

    When you work on a project, you often rely on external libraries and source code. If you use CMake as your build tool: it can download the artifacts for you. And make them available during build. By using FetchContent. use case: your pro...