Real-Time C++, 4th Edition: Efficient Object-Oriented and Template Microcontroller Programming
- Length: 551 pages
- Edition: 4
- Language: English
- Publisher: Springer
- Publication Date: 2021-08-15
- ISBN-10: 366262995X
- ISBN-13: 9783662629956
- Sales Rank: #3634199 (See Top 100 Books)
With this book, Christopher Kormanyos delivers a highly practical guide to programming real-time embedded microcontroller systems in C++. It is divided into three parts plus several appendices. Part I provides a foundation for real-time C++ by covering language technologies, including object-oriented methods, template programming and optimization. Next, part II presents detailed descriptions of a variety of C++ components that are widely used in microcontroller programming. It details some of C++’s most powerful language elements, such as class types, templates and the STL, to develop components for microcontroller register access, low-level drivers, custom memory management, embedded containers, multitasking, etc. Finally, part III describes mathematical methods and generic utilities that can be employed to solve recurring problems in real-time C++. The appendices include a brief C++ language tutorial, information on the real-time C++ development environment and instructions for building GNU GCC cross-compilers and a microcontroller circuit.
For this fourth edition, the most recent specification of C++20 is used throughout the text. Several sections on new C++20 functionality have been added, and various others reworked to reflect changes in the standard. Also several new example projects ranging from introductory to advanced level are included and existing ones extended, and various reader suggestions have been incorporated. Efficiency is always in focus and numerous examples are backed up with runtime measurements and size analyses that quantify the true costs of the code down to the very last byte and microsecond.
The target audience of this book mainly consists of students and professionals interested in real-time C++. Readers should be familiar with C or another programming language and will benefit most if they have had some previous experience with microcontroller electronics and the performance and size issues prevalent in embedded systems programming.
Preface to the Fourth Edition New or Significantly Modified Sections Improved or New Examples and Code Snippets Companion Code Further Notes on Coding Style Updated Trademarks and Acknowledgments Preface to the Third Edition New or Significantly Modified Sections Improved or New Examples and Code Snippets Companion Code Further Notes on Coding Style Updated Trademarks and Acknowledgments Preface to the Second Edition Companion Code More Notes on Coding Style Preface to the First Edition About This Book Companion Code, Targets, and Tools Notes on Coding Style Acknowledgments Contents Acronyms References Part I Language Technologies for Real-Time C++ 1 Getting Started with Real-Time C++ 1.1 The LED Program 1.2 The Syntax of C++ 1.3 Class Types 1.4 Members 1.5 Objects and Instances 1.6 include 1.7 Namespaces 1.8 C++ Standard Library 1.9 The main() Subroutine 1.10 Low-Level Register Access 1.11 Compile-Time Constant References 2 Working with a Real-Time C++ Program on a Board 2.1 The Target Hardware 2.2 Build and Flash the LED Program 2.3 Adding Timing for Visible LED Toggling 2.4 Run and Reset the LED Program 2.5 Recognizing and Handling Errors and Warnings 2.6 Reaching the Right Efficiency References 3 An Easy Jump Start in Real-Time C++ 3.1 Declare Locals When Used 3.2 Fixed-Size Integer Types and Prime Number Example 3.3 The bool Type 3.4 Organization with Namespaces 3.5 Basic Classes 3.6 Basic Templates 3.7 nullptr Replaces NULL 3.8 Generalized Constant Expressions with constexpr 3.9 static_assert 3.10 Using <limits> 3.11 std::array 3.12 Basic STL Algorithms 3.13 <numeric> 3.14 atomic_load() and atomic_store() 3.15 Digit Separators 3.16 Binary Literals 3.17 User-Defined Literals 3.18 Using alignof and alignas 3.19 The Specifier final 3.20 Alias as an Alternative to typedef 3.21 Delimiting Pointer Ranges with <span> 3.22 Generating Random Numbers with <random> References 4 Object-Oriented Techniques for Microcontrollers 4.1 Object Oriented Programming 4.2 Objects and Encapsulation 4.3 Inheritance 4.4 Dynamic Polymorphism and a Detailed LED Example 4.5 The Real Overhead of Dynamic Polymorphism 4.6 Pure Virtual and Abstract 4.7 Class Relationships 4.8 Non-copyable Classes 4.9 Constant Methods 4.10 Static Constant Integral Members 4.11 Class Friends 4.12 Virtual Is Unavailable in the Base Class Constructor References 5 C++ Templates for Microcontrollers 5.1 Template Functions 5.2 Template Scalability, Code Re-Use and Efficiency 5.3 Template Member Functions 5.4 Template Class Types 5.5 Template Default Parameters 5.6 Template Specialization 5.7 Static Polymorphism 5.8 Using the STL with Microcontrollers 5.9 Variadic Templates 5.10 Template Metaprogramming 5.11 Tuples and Generic Metaprogramming 5.12 Variable Templates 5.13 Template Integer Sequences References 6 Optimized C++ Programming for Microcontrollers 6.1 Use Compiler Optimization Settings 6.2 Know the Microcontroller's Performance 6.3 Know an Algorithm's Complexity 6.4 Use Assembly Listings 6.5 Use Map Files 6.6 Understand Name Mangling and De-mangling 6.7 Know When to Use Assembly and When Not to 6.8 Use Sensible Comments 6.9 Simplify Code with typedef and Alias 6.10 Use Native Integer Types 6.11 Use Scaling with Powers of Two 6.12 Potentially Replace Multiply with Shift-and-Add 6.13 Consider Advantageous Hardware Dimensioning 6.14 Consider ROM-ability 6.15 Minimize the Interrupt Frame 6.16 Use Custom Memory Management 6.17 Use the STL Consistently 6.18 Use Lambda Expressions 6.19 Use Templates and Scalability 6.20 Use Metaprogramming to Unroll Loops 6.21 Potential Costs of Runtime Type Information (RTTI) References Part II Components for Real-Time C++ 7 Accessing Microcontroller Registers 7.1 Defining Constant Register Addresses 7.2 Using Templates for Register Access 7.3 Generic Templates for Register Access 7.4 Bit-Mapped Structures Reference 8 The Right Start 8.1 The Startup Code 8.2 Initializing RAM 8.3 Initializing the Static Constructors 8.4 The Connection Between the Linker and Startup 8.5 Understand Static Initialization Rules 8.6 Avoid Using Uninitialized Objects 8.7 Jump to main() and Never return 8.8 When in main(), What Comes Next? References 9 Low-Level Hardware Drivers in C++ 9.1 An I/O Port Pin Driver Template Class 9.2 Programming Interrupts in C++ 9.3 Implementing a System Tick 9.4 A Software PWM Template Class 9.5 A Serial SPI Driver Class 9.6 CPU-Load Monitors 9.7 Controlling a Seven-Segment Display 9.8 Animating an RGB LED References 10 Custom Memory Management 10.1 Dynamic Memory Considerations 10.2 Using Placement-new 10.3 Allocators and STL Containers 10.4 The Standard Allocator 10.5 Writing a Specialized ring_allocator 10.6 Using ring_allocator and Other Allocators 10.7 Recognizing and Handling Memory Limitations 10.8 Off-Chip Memory and Computing 100,001 Digits of π 10.9 Using Ample RAM on Arm®-Based Single-Board Computer References 11 C++ Multitasking 11.1 Multitasking Schedulers 11.2 Task Timing 11.3 The Task Control Block 11.4 The Task List 11.5 The Scheduler 11.6 Extended Multitasking 11.7 Preemptive Multitasking 11.8 The C++ Thread Support Library References Part III Mathematics and Utilities for Real-Time C++ 12 Floating-Point Mathematics 12.1 Floating-Point Arithmetic 12.2 Mathematical Constants 12.3 Elementary Functions 12.4 Special Functions 12.5 Complex-Valued Mathematics 12.6 Compile-Time Evaluation of Functions with constexpr 12.7 Generic Numeric Programming References 13 Fixed-Point Mathematics 13.1 Fixed-Point Data Types 13.2 A Scalable Fixed-Point Template Class 13.3 Using the fixed_point Class 13.4 Fixed-Point Elementary Transcendental Functions 13.5 A Specialization of std::numeric_limits References 14 High-Performance Digital Filters 14.1 A Floating-Point Order-1 Filter 14.2 An Order-1 Integer Filter 14.3 Order-N Integer FIR Filters 14.4 Some Worked-Out Filter Examples References 15 C++ Utilities 15.1 The nothing Structure 15.2 The noncopyable Class 15.3 A Template timer Class 15.4 Linear Interpolation 15.5 A circular_buffer Template Class 15.6 The Boost Library References 16 Extending the C++ Standard Library and the STL 16.1 Defining the Custom dynamic_array Container 16.2 Implementing and Using dynamic_array 16.3 Writing Parts of the C++ Library if None Is Available 16.4 Implementation Notes for Parts of the C++ Library and STL 16.5 Providing now() for <chrono>'s High-Resolution Clock 16.6 Extended-Complex Number Templates 16.7 An Embeddable Big Integer Class 16.8 Customizing <random> 16.9 Freestanding Implementation References 17 Using C-Language Code in C++ 17.1 Accessing C Language Code in C++ 17.2 An Existing C-Language CRC Library 17.3 Wrapping the C-Based CRC Library with C++ Classes 17.4 Return to Investigations of Efficiency and Optimization References 18 Additional Reading 18.1 Literature List References A A Tutorial for Real-Time C++ A.1 C++ Cast Operators A.2 Uniform Initialization Syntax A.3 Overloading A.4 Compile-Time Assert A.5 Numeric Limits A.6 STL Containers A.7 STL Iterators A.8 STL Algorithms A.9 Lambda Expressions A.10 Initializer Lists A.11 Type Inference and Type Declaration with auto and decltype A.12 Range-Based for(:) A.13 Tuple A.14 Regular Expressions A.15 The <type_traits> Library A.16 Using std::any and std::variant A.17 Structured Binding Declarations A.18 Three-Way Comparison References B A Robust Real-Time C++ Environment B.1 Addressing the Challenges of Real-Time C++ B.2 Software Architecture B.3 Establishing and Adhering to Runtime Limits References C Building and Installing GNU GCC Cross Compilers C.1 The GCC Prerequisites C.2 Getting Started C.3 Building GMP C.4 Building MPFR C.5 Building MPC C.6 Building PPL C.7 Building ISL C.8 Building the Binary Utilities for the Cross Compiler C.9 Building the Cross Compiler C.10 Using the Cross Compiler References D Building a Microcontroller Circuit D.1 The Circuit Schematic D.2 Assembling the Circuit on a Breadboard References Glossary Index
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.