|
Part I Language Technologies for Real-Time C++ |
|
|
|
1 Getting Started with Real-Time C++ |
|
|
3 | (18) |
|
|
3 | (3) |
|
|
6 | (1) |
|
|
6 | (4) |
|
|
10 | (2) |
|
1.5 Objects and Instances |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
14 | (2) |
|
|
16 | (1) |
|
1.9 The main () Subroutine |
|
|
16 | (1) |
|
1.10 Low-Level Register Access |
|
|
17 | (1) |
|
1.11 Compile-Time Constant |
|
|
18 | (3) |
|
|
19 | (2) |
|
2 Working with a Real-Time C++ Program on a Board |
|
|
21 | (14) |
|
|
21 | (1) |
|
2.2 Build and Flash the LED Program |
|
|
22 | (4) |
|
2.3 Adding Timing for Visible LED Toggling |
|
|
26 | (2) |
|
2.4 Run and Reset the LED Program |
|
|
28 | (1) |
|
2.5 Recognizing and Handling Errors and Warnings |
|
|
28 | (2) |
|
2.6 Reaching the Right Efficiency |
|
|
30 | (5) |
|
|
33 | (2) |
|
3 An Easy Jump Start in Real-Time C++ |
|
|
35 | (34) |
|
3.1 Declare Locals When Used |
|
|
35 | (1) |
|
3.2 Fixed-Size Integer Types and Prime Number Example |
|
|
36 | (6) |
|
|
42 | (1) |
|
3.4 Organization with Namespaces |
|
|
42 | (3) |
|
|
45 | (1) |
|
|
46 | (2) |
|
3.7 Nullptr Replaces NULL |
|
|
48 | (1) |
|
3.8 Generalized Constant Expressions with cons texpr |
|
|
49 | (2) |
|
|
51 | (1) |
|
|
51 | (1) |
|
|
52 | (1) |
|
3.12 Basic STL Algorithms |
|
|
53 | (1) |
|
|
54 | (1) |
|
3.14 atomic_load () and atomic_store () |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
56 | (1) |
|
3.17 User-Defined Literals |
|
|
57 | (3) |
|
3.18 Using alignof and alignas |
|
|
60 | (1) |
|
|
61 | (1) |
|
3.20 Alias as an Alternative to typedef |
|
|
62 | (2) |
|
3.21 Delimiting Pointer Ranges with <span> |
|
|
64 | (1) |
|
3.22 Generating Random Numbers with <random> |
|
|
64 | (5) |
|
|
68 | (1) |
|
4 Object-Oriented Techniques for Microcontrollers |
|
|
69 | (32) |
|
4.1 Object Oriented Programming |
|
|
69 | (5) |
|
4.2 Objects and Encapsulation |
|
|
74 | (2) |
|
|
76 | (1) |
|
4.4 Dynamic Polymorphism and a Detailed LED Example |
|
|
77 | (7) |
|
4.5 The Real Overhead of Dynamic Polymorphism |
|
|
84 | (1) |
|
4.6 Pure Virtual and Abstract |
|
|
85 | (1) |
|
|
86 | (2) |
|
|
88 | (1) |
|
|
89 | (4) |
|
4.10 Static Constant Integral Members |
|
|
93 | (2) |
|
|
95 | (2) |
|
4.12 Virtual Is Unavailable in the Base Class Constructor |
|
|
97 | (4) |
|
|
100 | (1) |
|
5 C++ Templates for Microcontrollers |
|
|
101 | (36) |
|
|
101 | (2) |
|
5.2 Template Scalability, Code Re-Use and Efficiency |
|
|
103 | (3) |
|
5.3 Template Member Functions |
|
|
106 | (3) |
|
|
109 | (1) |
|
5.5 Template Default Parameters |
|
|
110 | (1) |
|
5.6 Template Specialization |
|
|
111 | (2) |
|
|
113 | (3) |
|
5.8 Using the STL with Microcontrollers |
|
|
116 | (2) |
|
|
118 | (3) |
|
5.10 Template Metaprogramming |
|
|
121 | (4) |
|
5.11 Tuples and Generic Metaprogramming |
|
|
125 | (4) |
|
|
129 | (3) |
|
5.13 Template Integer Sequences |
|
|
132 | (5) |
|
|
136 | (1) |
|
6 Optimized C++ Programming for Microcontrollers |
|
|
137 | (40) |
|
6.1 Use Compiler Optimization Settings |
|
|
137 | (4) |
|
6.2 Know the Microcontroller's Performance |
|
|
141 | (1) |
|
6.3 Know an Algorithm's Complexity |
|
|
142 | (2) |
|
6.4 Use Assembly Listings |
|
|
144 | (1) |
|
|
145 | (1) |
|
6.6 Understand Name Mangling and De-mangling |
|
|
145 | (2) |
|
6.7 Know When to Use Assembly and When Not to |
|
|
147 | (2) |
|
6.8 Use Sensible Comments |
|
|
149 | (1) |
|
6.9 Simplify Code with typedef and Alias |
|
|
149 | (3) |
|
6.10 Use Native Integer Types |
|
|
152 | (2) |
|
6.11 Use Scaling with Powers of Two |
|
|
154 | (2) |
|
6.12 Potentially Replace Multiply with Shift-and-Add |
|
|
156 | (1) |
|
6.13 Consider Advantageous Hardware Dimensioning |
|
|
156 | (2) |
|
6.14 Consider ROM-ability |
|
|
158 | (5) |
|
6.15 Minimize the Interrupt Frame |
|
|
163 | (3) |
|
6.16 Use Custom Memory Management |
|
|
166 | (1) |
|
6.17 Use the STL Consistently |
|
|
167 | (2) |
|
6.18 Use Lambda Expressions |
|
|
169 | (1) |
|
6.19 Use Templates and Scalability |
|
|
170 | (1) |
|
6.20 Use Metaprogramming to Unroll Loops |
|
|
171 | (1) |
|
6.21 Potential Costs of Runtime Type Information (RTTI) |
|
|
171 | (6) |
|
|
174 | (3) |
|
Part II Components for Real-Time C++ |
|
|
|
7 Accessing Microcontroller Registers |
|
|
177 | (12) |
|
7.1 Defining Constant Register Addresses |
|
|
177 | (2) |
|
7.2 Using Templates for Register Access |
|
|
179 | (3) |
|
7.3 Generic Templates for Register Access |
|
|
182 | (3) |
|
7.4 Bit-Mapped Structures |
|
|
185 | (4) |
|
|
188 | (1) |
|
|
189 | (16) |
|
|
189 | (3) |
|
|
192 | (2) |
|
8.3 Initializing the Static Constructors |
|
|
194 | (2) |
|
8.4 The Connection Between the Linker and Startup |
|
|
196 | (2) |
|
8.5 Understand Static Initialization Rules |
|
|
198 | (2) |
|
8.6 Avoid Using Uninitialized Objects |
|
|
200 | (2) |
|
8.7 Jump to main () and Never return |
|
|
202 | (1) |
|
8.8 When in ma in (), What Comes Next? |
|
|
203 | (2) |
|
|
204 | (1) |
|
9 Low-Level Hardware Drivers in C++ |
|
|
205 | (34) |
|
9.1 An I/O Port Pin Driver Template Class |
|
|
205 | (2) |
|
9.2 Programming Interrupts in C++ |
|
|
207 | (5) |
|
9.3 Implementing a System Tick |
|
|
212 | (3) |
|
9.4 A Software PWM Template Class |
|
|
215 | (4) |
|
9.5 A Serial SPI™ Driver Class |
|
|
219 | (3) |
|
|
222 | (3) |
|
9.7 Controlling a Seven-Segment Display |
|
|
225 | (7) |
|
|
232 | (7) |
|
|
237 | (2) |
|
10 Custom Memory Management |
|
|
239 | (40) |
|
10.1 Dynamic Memory Considerations |
|
|
239 | (2) |
|
|
241 | (1) |
|
10.3 Allocators and STL Containers |
|
|
242 | (1) |
|
10.4 The Standard Allocator |
|
|
243 | (1) |
|
10.5 Writing a Specialized ring_allocator |
|
|
244 | (3) |
|
10.6 Using ring_allocator and Other Allocators |
|
|
247 | (2) |
|
10.7 Recognizing and Handling Memory Limitations |
|
|
249 | (2) |
|
10.8 Off-Chip Memory and Computing 100,001 Digits of it |
|
|
251 | (15) |
|
10.9 Using Ample RAM on Arm®-Based Single-Board Computer |
|
|
266 | (13) |
|
|
276 | (3) |
|
|
279 | (16) |
|
11.1 Multitasking Schedulers |
|
|
279 | (2) |
|
|
281 | (1) |
|
11.3 The Task Control Block |
|
|
282 | (2) |
|
|
284 | (1) |
|
|
285 | (1) |
|
11.6 Extended Multitasking |
|
|
286 | (2) |
|
11.7 Preemptive Multitasking |
|
|
288 | (3) |
|
11.8 The C++ Thread Support Library |
|
|
291 | (4) |
|
|
292 | (3) |
|
Part III Mathematics and Utilities for Real-Time C++ |
|
|
|
12 Floating-Point Mathematics |
|
|
295 | (34) |
|
12.1 Floating-Point Arithmetic |
|
|
295 | (3) |
|
12.2 Mathematical Constants |
|
|
298 | (2) |
|
12.3 Elementary Functions |
|
|
300 | (2) |
|
|
302 | (10) |
|
12.5 Complex-Valued Mathematics |
|
|
312 | (4) |
|
12.6 Compile-Time Evaluation of Functions with constexpr |
|
|
316 | (4) |
|
12.7 Generic Numeric Programming |
|
|
320 | (9) |
|
|
327 | (2) |
|
13 Fixed-Point Mathematics |
|
|
329 | (24) |
|
13.1 Fixed-Point Data Types |
|
|
329 | (3) |
|
13.2 A Scalable Fixed-Point Template Class |
|
|
332 | (4) |
|
13.3 Using the fixed_point Class |
|
|
336 | (2) |
|
13.4 Fixed-Point Elementary Transcendental Functions |
|
|
338 | (11) |
|
13.5 A Specialization of std: : numeric_limits |
|
|
349 | (4) |
|
|
351 | (2) |
|
14 High-Performance Digital Filters |
|
|
353 | (18) |
|
14.1 A Floating-Point Order-1 Filter |
|
|
353 | (3) |
|
14.2 An Order-1 Integer Filter |
|
|
356 | (4) |
|
14.3 Order-N Integer FIR Filters |
|
|
360 | (5) |
|
14.4 Some Worked-Out Filter Examples |
|
|
365 | (6) |
|
|
369 | (2) |
|
|
371 | (18) |
|
15.1 The nothing Structure |
|
|
371 | (3) |
|
15.2 The noncopyable Class |
|
|
374 | (2) |
|
15.3 A Template timer Class |
|
|
376 | (3) |
|
15.4 Linear Interpolation |
|
|
379 | (3) |
|
15.5 A circular_buffer Template Class |
|
|
382 | (4) |
|
|
386 | (3) |
|
|
387 | (2) |
|
16 Extending the C++ Standard Library and the STL |
|
|
389 | (38) |
|
16.1 Defining the Custom dynamic_array Container |
|
|
389 | (3) |
|
16.2 Implementing and Using dynamic_array |
|
|
392 | (4) |
|
16.3 Writing Parts of the C++ Library if None Is Available |
|
|
396 | (1) |
|
16.4 Implementation Notes for Parts of the C++ Library and STL |
|
|
396 | (9) |
|
16.5 Providing now () for <chrono>'s High-Resolution Clock |
|
|
405 | (2) |
|
16.6 Extended-Complex Number Templates |
|
|
407 | (3) |
|
16.7 An Embeddable Big Integer Class |
|
|
410 | (4) |
|
16.8 Customizing <random> |
|
|
414 | (10) |
|
16.9 Freestanding Implementation |
|
|
424 | (3) |
|
|
425 | (2) |
|
17 Using C-Language Code in C++ |
|
|
427 | (8) |
|
17.1 Accessing C Language Code in C++ |
|
|
427 | (1) |
|
17.2 An Existing C-Language CRC Library |
|
|
428 | (2) |
|
17.3 Wrapping the C-Based CRC Library with C++ Classes |
|
|
430 | (3) |
|
17.4 Return to Investigations of Efficiency and Optimization |
|
|
433 | (2) |
|
|
434 | (1) |
|
|
435 | (4) |
|
|
435 | (4) |
|
|
437 | (2) |
|
A A Tutorial for Real-Time C++ |
|
|
439 | (38) |
|
|
439 | (1) |
|
A.2 Uniform Initialization Syntax |
|
|
440 | (3) |
|
|
443 | (1) |
|
|
443 | (1) |
|
|
444 | (4) |
|
|
448 | (2) |
|
|
450 | (3) |
|
|
453 | (4) |
|
|
457 | (1) |
|
|
458 | (2) |
|
A.11 Type Inference and Type Declaration with auto and decltype |
|
|
460 | (2) |
|
|
462 | (1) |
|
|
462 | (4) |
|
|
466 | (2) |
|
A.15 The <type_traits> Library |
|
|
468 | (3) |
|
A.16 Using std: : any and std: : variant |
|
|
471 | (3) |
|
A.17 Structured Binding Declarations |
|
|
474 | (1) |
|
A.18 Three-Way Comparison |
|
|
475 | (2) |
|
|
475 | (2) |
|
B A Robust Real-Time C++ Environment |
|
|
477 | (6) |
|
B.1 Addressing the Challenges of Real-Time C++ |
|
|
477 | (2) |
|
B.2 Software Architecture |
|
|
479 | (1) |
|
B.3 Establishing and Adhering to Runtime Limits |
|
|
480 | (3) |
|
|
481 | (2) |
|
C Building and Installing GNU GCC Cross Compilers |
|
|
483 | (10) |
|
C.1 The GCC Prerequisites |
|
|
483 | (1) |
|
|
484 | (1) |
|
|
485 | (1) |
|
|
486 | (1) |
|
|
486 | (1) |
|
|
487 | (1) |
|
|
488 | (1) |
|
C.8 Building the Binary Utilities for the Cross Compiler |
|
|
488 | (2) |
|
C.9 Building the Cross Compiler |
|
|
490 | (1) |
|
C.10 Using the Cross Compiler |
|
|
491 | (2) |
|
|
492 | (1) |
|
D Building a Microcontroller Circuit |
|
|
493 | (3) |
|
D.1 The Circuit Schematic |
|
|
493 | (2) |
|
D.2 Assembling the Circuit on a Breadboard |
|
|
495 | (1) |
References |
|
496 | (1) |
Glossary |
|
497 | (2) |
Index |
|
499 | |