Kormanyos | Real-Time C++ | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 441 Seiten

Kormanyos Real-Time C++

Efficient Object-Oriented and Template Microcontroller Programming
3rd Auflage 2018
ISBN: 978-3-662-56718-0
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark

Efficient Object-Oriented and Template Microcontroller Programming

E-Book, Englisch, 441 Seiten

ISBN: 978-3-662-56718-0
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark



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 third edition, the most recent specification of C++17 in ISO/IEC 14882:2017 is used throughout the text. Several sections on new C++17 functionality have been added, and various others reworked to reflect changes in the standard. Also several new sample projects are introduced and existing ones extended, and various user suggestions have been incorporated. To facilitate portability, no libraries other than those specified in the language standard itself are used. Efficiency is always in focus and numerous examples are backed up with real-time performance 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.

Christopher Kormanyos is a senior system architect at a major automotive supplier with 25 years of experience in software development, microcontroller system design and application deployment. Chris is well-connected in the microcontroller industry and has strong professional ties to both tier-one silicon suppliers as well as compiler and tool vendors. He received a PhD in experimental particle physics from the University of Colorado in 1994 and also holds several patents for automotive electronic technologies.

Kormanyos Real-Time C++ jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Preface to the Third Edition;6
1.1;New or Significantly Modified Sections;6
1.2;Improved or New Examples and Code Snippets;7
1.3;Companion Code;8
1.4;Further Notes on Coding Style;8
1.5;Updated Trademarks and Acknowledgments;9
2;Preface to the Second Edition;10
2.1;Companion Code;11
2.2;More Notes on Coding Style;11
3;Preface to the First Edition;13
3.1;About This Book;13
3.2;Companion Code, Targets and Tools;14
3.3;Notes on Coding Style;15
3.4;Acknowledgements;19
4;Contents;20
5;Acronyms;26
5.1;References;29
6;Part I Language Technologies for Real-Time C++;31
6.1;1 Getting Started with Real-Time C++;32
6.1.1;1.1 The LED Program;32
6.1.2;1.2 The Syntax of C++;35
6.1.3;1.3 Class Types;35
6.1.4;1.4 Members;39
6.1.5;1.5 Objects and Instances;41
6.1.6;1.6 #include;42
6.1.7;1.7 Namespaces;43
6.1.8;1.8 C++ Standard Library;45
6.1.9;1.9 The main() Subroutine;45
6.1.10;1.10 Low-Level Register Access;46
6.1.11;1.11 Compile-Time Constant;47
6.1.12;References;48
6.2;2 Working with a Real-Time C++ Program on a Board;49
6.2.1;2.1 The Target Hardware;49
6.2.2;2.2 Build and Flash the LED Program;50
6.2.3;2.3 Adding Timing for Visible LED Toggling;54
6.2.4;2.4 Run and Reset the LED Program;56
6.2.5;2.5 Recognizing and Handling Errors and Warnings;56
6.2.6;2.6 Reaching the Right Efficiency;58
6.2.7;References;61
6.3;3 An Easy Jump Start in Real-Time C++;62
6.3.1;3.1 Declare Locals when Used;62
6.3.2;3.2 Fixed-Size Integer Types;63
6.3.3;3.3 The bool Type;65
6.3.4;3.4 Organization with Namespaces;66
6.3.5;3.5 Basic Classes;68
6.3.6;3.6 Basic Templates;69
6.3.7;3.7 nullptr Replaces NULL;72
6.3.8;3.8 Generalized Constant Expressions with constexpr;73
6.3.9;3.9 static assert;74
6.3.10;3.10 Using ;74
6.3.11;3.11 std::array;75
6.3.12;3.12 Basic STL Algorithms;76
6.3.13;3.13 ;77
6.3.14;3.14 atomic load() and atomic store();78
6.3.15;3.15 Digit Separators;78
6.3.16;3.16 Binary Literals;79
6.3.17;3.17 User-Defined Literals;80
6.3.18;3.18 Using alignof and alignas;83
6.3.19;3.19 The Specifier final;84
6.3.20;3.20 Alias as an Alternative to typedef;85
6.3.21;References;87
6.4;4 Object-Oriented Techniques for Microcontrollers;88
6.4.1;4.1 Object Oriented Programming;88
6.4.2;4.2 Objects and Encapsulation;93
6.4.3;4.3 Inheritance;94
6.4.4;4.4 Dynamic Polymorphism;96
6.4.5;4.5 The Real Overhead of Dynamic Polymorphism;97
6.4.6;4.6 Pure Virtual and Abstract;98
6.4.7;4.7 Class Relationships;99
6.4.8;4.8 Non-copyable Classes;101
6.4.9;4.9 Constant Methods;102
6.4.10;4.10 Static Constant Integral Members;106
6.4.11;4.11 Class Friends;106
6.4.12;4.12 Virtual Is Unavailable in the Base Class Constructor;108
6.4.13;References;111
6.5;5 C++ Templates for Microcontrollers;112
6.5.1;5.1 Template Functions;112
6.5.2;5.2 Template Scalability, Code Re-Use and Efficiency;114
6.5.3;5.3 Template Member Functions;117
6.5.4;5.4 Template Class Types;120
6.5.5;5.5 Template Default Parameters;121
6.5.6;5.6 Template Specialization;122
6.5.7;5.7 Static Polymorphism;124
6.5.8;5.8 Using the STL with Microcontrollers;127
6.5.9;5.9 Variadic Templates;129
6.5.10;5.10 Template Metaprogramming;131
6.5.11;5.11 Tuples and Generic Metaprogramming;134
6.5.12;5.12 Variable Templates;137
6.5.13;References;139
6.6;6 Optimized C++ Programming for Microcontrollers;140
6.6.1;6.1 Use Compiler Optimization Settings;140
6.6.2;6.2 Know the Microcontroller's Performance;144
6.6.3;6.3 Know an Algorithm's Complexity;145
6.6.4;6.4 Use Assembly Listings;147
6.6.5;6.5 Use Map Files;147
6.6.6;6.6 Understand Name Mangling and De-mangling;148
6.6.7;6.7 Know When to Use Assembly and When Not to;150
6.6.8;6.8 Use Comments Sparingly;151
6.6.9;6.9 Simplify Code with typedef and Alias;152
6.6.10;6.10 Use Native Integer Types;154
6.6.11;6.11 Use Scaling with Powers of Two;156
6.6.12;6.12 Potentially Replace Multiply with Shift-and-Add;157
6.6.13;6.13 Consider Advantageous Hardware Dimensioning;158
6.6.14;6.14 Consider ROM-Ability;160
6.6.15;6.15 Minimize the Interrupt Frame;161
6.6.16;6.16 Use Custom Memory Management;164
6.6.17;6.17 Use the STL Consistently;164
6.6.18;6.18 Use Lambda Expressions;166
6.6.19;6.19 Use Templates and Scalability;167
6.6.20;6.20 Use Metaprogramming to Unroll Loops;168
6.6.21;References;168
7;Part II Components for Real-Time C++;169
7.1;7 Accessing Microcontroller Registers;170
7.1.1;7.1 Defining Constant Register Addresses;170
7.1.2;7.2 Using Templates for Register Access;172
7.1.3;7.3 Generic Templates for Register Access;174
7.1.4;7.4 Bit-Mapped Structures;177
7.1.5;Reference;179
7.2;8 The Right Start;180
7.2.1;8.1 The Startup Code;180
7.2.2;8.2 Initializing RAM;183
7.2.3;8.3 Initializing the Static Constructors;185
7.2.4;8.4 The Connection Between the Linker and Startup;187
7.2.5;8.5 Understand Static Initialization Rules;189
7.2.6;8.6 Avoid Using Uninitialized Objects;190
7.2.7;8.7 Jump to main() and Never return;192
7.2.8;8.8 When in main(), What Comes Next?;193
7.2.9;References;194
7.3;9 Low-Level Hardware Drivers in C++;195
7.3.1;9.1 An I/O Port Pin Driver Template Class;195
7.3.2;9.2 Programming Interrupts in C++;198
7.3.3;9.3 Implementing a System-Tick;202
7.3.4;9.4 A Software PWM Template Class;205
7.3.5;9.5 A Serial SPI™ Driver Class;209
7.3.6;9.6 CPU-Load Monitors;214
7.3.7;9.7 Controlling a Seven-Segment Display;216
7.3.8;9.8 Animating an RGB LED;222
7.3.9;References;228
7.4;10 Custom Memory Management;229
7.4.1;10.1 Dynamic Memory Considerations;229
7.4.2;10.2 Using Placement-new;231
7.4.3;10.3 Allocators and STL Containers;232
7.4.4;10.4 The Standard Allocator;233
7.4.5;10.5 Writing a Specialized ring allocator;234
7.4.6;10.6 Using ring allocator and Other Allocators;237
7.4.7;10.7 Recognizing and Handling Memory Limitations;239
7.4.8;References;241
7.5;11 C++ Multitasking;242
7.5.1;11.1 Multitasking Schedulers;242
7.5.2;11.2 Task Timing;244
7.5.3;11.3 The Task Control Block;245
7.5.4;11.4 The Task List;247
7.5.5;11.5 The Scheduler;248
7.5.6;11.6 Extended Multitasking;249
7.5.7;11.7 Preemptive Multitasking;251
7.5.8;11.8 The C++ Thread Support Library;252
7.5.9;References;253
8;Part III Mathematics and Utilities for Real-Time C++;254
8.1;12 Floating-Point Mathematics;255
8.1.1;12.1 Floating-Point Arithmetic;255
8.1.2;12.2 Mathematical Constants;258
8.1.3;12.3 Elementary Functions;260
8.1.4;12.4 Special Functions;261
8.1.5;12.5 Complex-Valued Mathematics;271
8.1.6;12.6 Compile-Time Evaluation of Functions with constexpr;275
8.1.7;12.7 Generic Numeric Programming;279
8.1.8;References;286
8.2;13 Fixed-Point Mathematics;288
8.2.1;13.1 Fixed-Point Data Types;288
8.2.2;13.2 A Scalable Fixed-Point Template Class;291
8.2.3;13.3 Using the fixed point Class;295
8.2.4;13.4 Fixed-Point Elementary Transcendental Functions;297
8.2.5;13.5 A Specialization of std::numeric limits;308
8.2.6;References;310
8.3;14 High-Performance Digital Filters;311
8.3.1;14.1 A Floating-Point Order-1 Filter;311
8.3.2;14.2 An Order-1 Integer Filter;314
8.3.3;14.3 Order-N Integer FIR Filters;318
8.3.4;14.4 Some Worked-Out Filter Examples;323
8.3.5;References;327
8.4;15 C++ Utilities;328
8.4.1;15.1 The nothing Structure;328
8.4.2;15.2 The noncopyable Class;331
8.4.3;15.3 A Template timer Class;333
8.4.4;15.4 Linear Interpolation;336
8.4.5;15.5 A circular buffer Template Class;339
8.4.6;15.6 The Boost Library;343
8.4.7;References;344
8.5;16 Extending the C++ Standard Library and the STL;345
8.5.1;16.1 Defining the Custom dynamic array Container;345
8.5.2;16.2 Implementing and Using dynamic array;348
8.5.3;16.3 Writing Parts of the C++ Library if None is Available;352
8.5.4;16.4 Implementation Notes for Parts of the C++ Library and STL;352
8.5.5;16.5 Providing now() for 's High-Resolution Clock;361
8.5.6;16.6 Extended-Complex Number Templates;363
8.5.7;References;366
8.6;17 Using C-Language Code in C++;367
8.6.1;17.1 Accessing C Language Code in C++;367
8.6.2;17.2 An Existing C-Language CRC Library;368
8.6.3;17.3 Wrapping the C-Based CRC Library with C++ Classes;370
8.6.4;17.4 Return to Investigations of Efficiency and Optimization;373
8.6.5;References;374
8.7;18 Additional Reading;375
8.7.1;18.1 Literature List;375
8.7.2;References;377
9;Appendices;375
10;A A Tutorial for Real-Time C++;380
10.1;A.1 C++ Cast Operators;380
10.2;A.2 Uniform Initialization Syntax;381
10.3;A.3 Overloading;383
10.4;A.4 Compile-Time Assert;384
10.5;A.5 Numeric Limits;384
10.6;A.6 STL Containers;388
10.7;A.7 STL Iterators;390
10.8;A.8 STL Algorithms;392
10.9;A.9 Lambda Expressions;396
10.10;A.10 Initializer Lists;397
10.11;A.11 Type Inference and Type Declaration with auto and decltype;398
10.12;A.12 Range-Based for(:);399
10.13;A.13 Tuple;399
10.14;A.14 Regular Expressions;402
10.15;A.15 The Library;404
10.16;A.16 Using std::any;406
10.17;A.17 Structured Binding Declarations;409
10.18;References;410
11;B A Robust Real-Time C++ Environment;411
11.1;B.1 Addressing the Challenges of Real-Time C++;411
11.2;B.2 Software Architecture;413
11.3;B.3 Establishing and Adhering to Runtime Limits;414
11.4;References;415
12;C Building and Installing GNU GCC Cross Compilers;416
12.1;C.1 The GCC Prerequisites;416
12.2;C.2 Getting Started;417
12.3;C.3 Building GMP;418
12.4;C.4 Building MPFR;419
12.5;C.5 Building MPC;419
12.6;C.6 Building PPL;420
12.7;C.7 Building ISL;421
12.8;C.8 Building the Binary Utilities for the Cross Compiler;421
12.9;C.9 Building the Cross Compiler;423
12.10;C.10 Using the Cross Compiler;424
12.11;References;425
13;D Building a Microcontroller Circuit;426
13.1;D.1 The Circuit Schematic;426
13.2;D.2 Assembling the Circuit on a Breadboard;428
13.3;References;429
14;Glossary;430
15;Index;432



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.