diff --git a/examples/chapter02_02/readme.md b/examples/chapter02_02/readme.md index 75cd0876a..d7444b134 100644 --- a/examples/chapter02_02/readme.md +++ b/examples/chapter02_02/readme.md @@ -1,9 +1,11 @@ # Example chapter02_02 + ## The LED program

- - + + godbolt +

This example implements the LED program (blinky) for the @@ -33,7 +35,7 @@ The steps of the build include the following. - Assemble : crt0.s to bin/crt0.o - Compile : led.cpp to bin/led.o - Link : objects to the absolute object file bin/led.elf -- Extract : executalbe hex file : from bin/led.elf +- Extract : executable hex file : from bin/led.elf - Extract : assembly list file : from bin/led.elf - Extract : size information : from bin/led.elf - Extract : symbol name information : from bin/led.elf @@ -47,7 +49,8 @@ frequency will be as fast as the microcontroller can execute the given toggle code, which will be too fast to resolve. The core of the LED program is listed below. - - Note: The program listing here has been slightly _modernized_ compared to the program listing in the book. + +- Note: The program listing here has been slightly _modernized_ compared to the program listing in the book. ```cpp #include @@ -105,8 +108,8 @@ namespace Use the commented out loop in the program to slow down the blinking for easier observation. The commented out -loop is reproduced below within its contect in `main`. -It is the line starting with `for(volatile std::uint8_t delay`...). +loop is reproduced below within its context in `main`. +It is the line starting with `for(volatile std::uint8_t delay...)`. ```cpp auto main() -> int @@ -125,12 +128,13 @@ auto main() -> int ``` ## In `Win*` + The `Win*` batch file searches for a pre-installed instance -of the avr-g++ tool chain. +of the avr-g++ tool chain. When in `Win*`, building the Example chapter02_02 project can -accomplished in a cmd window. Use a command command such as -shown below, where the full path of the pre-installed +accomplished in a cmd window. Use a command such as +shown below, where the full path of the pre-installed gcc-avr is listed in its entirety. ```DOS @@ -172,5 +176,6 @@ to [godbolt](https://godbolt.org). Upon close investigation, the bit-_clear_ and bit-_set_ opcodes (`cbi` and `sbi`) can be recognized. -These opcodes are responsible for actually toggling the mocrocontroller's +These opcodes are responsible for actually toggling the +microcontroller's port pin `portb.5`. diff --git a/examples/readme.md b/examples/readme.md index fc13e72e8..b7a22cd1e 100644 --- a/examples/readme.md +++ b/examples/readme.md @@ -1,16 +1,15 @@ -Real-Time-C++ - Examples -================== +# Real-Time-C++ - Examples

Build Examples Boost Software License 1.0 - - + + godbolt

-These examples are motivated by the book +These examples are motivated by the book C.M. Kormanyos, [Real-Time C++](https://www.springer.com/de/book/9783662629956): Efficient Object-Oriented @@ -26,68 +25,67 @@ Consider, for instance, It employs a self-fitted DIY custom breadboard. Other examples use even higher levels of customization such as [example chapter10_08a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_08a) -which requires sophistocated breadboard and laboratory techniques, +which requires sophisticated breadboard and laboratory techniques, providing a DIY challenge at an advanced level. ## Summary of the Examples -Example ![chapter02_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_02) The LED program.\ +Example [chapter02_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_02) The LED program.\ This example implements the LED program (blinky) for the target with the 8-bit microcontroller. -Example ![chapter02_03](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_03) The LED program with timing.\ +Example [chapter02_03](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_03) The LED program with timing.\ This example implements the LED program (with timing) for the target with the 8-bit microcontroller. -Example ![chapter02_03a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_03a) The LED program with cooperative multitasking scheduler.\ +Example [chapter02_03a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_03a) The LED program with cooperative multitasking scheduler.\ This example implements the LED program with a tiny cooperative multitasking scheduler for the target with the 8-bit microcontroller. -Example ![chapter02_06](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_06) The Led Program (with template LED class).\ +Example [chapter02_06](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_06) The Led Program (with template LED class).\ This example implements the LED program with a template LED class for the target with the 8-bit microcontroller. -Example ![chapter03_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter03_02) Integer Types Having Fixed Widths and Prime Numbers.\ +Example [chapter03_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter03_02) Integer Types Having Fixed Widths and Prime Numbers.\ This example focuses on integer types having fixed widths using a fascinating calculation -of prime numbers that is simultaneously intended to emphasize the usefullness and portability +of prime numbers that is simultaneously intended to emphasize the usefulness and portability of fixed-width integer types. -Example ![chapter04_04](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter04_04) LED Objects and Polymorphism.\ +Example [chapter04_04](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter04_04) LED Objects and Polymorphism.\ This example exhibits object oriented polymorphism through an intuitive LED class hierarchy. Base class pointers stored in an `std::array` are used in combination with dynamic polymorphism. -Example ![chapter04_04a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter04_04a) LED Objects and Polymorphism via References.\ +Example [chapter04_04a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter04_04a) LED Objects and Polymorphism via References.\ This example exhibits object oriented polymorphism in essentially the same way as in example chapter04_04. In example chapter04_04a, however, we use base class references instead of base class pointers stored in an `std::array` -in order to utilitze object oriented polymorphism. +in order to utilize object oriented polymorphism. -Example ![chapter06_01](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter06_01) A CRC Benchmark.\ +Example [chapter06_01](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter06_01) A CRC Benchmark.\ This example illustrates certain optimization techniques through the calculation of a standard CRC32 checksum (cycle redundancy check). -Example ![chapter06_14](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter06_14) A CRC Benchmark with ROM-Based Table and Data.\ +Example [chapter06_14](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter06_14) A CRC Benchmark with ROM-Based Table and Data.\ This example features essentially the same functionality as example chapter06_01. The checksum table and benchmark data, however, are ROM-able. -Example ![chapter09_07](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_07) Controlling a Seven Segment Display.\ +Example [chapter09_07](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_07) Controlling a Seven Segment Display.\ This example makes use of object oriented programming methods to control a seven segment display. -Example ![chapter09_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08) Controlling an RGB LED.\ +Example [chapter09_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08) Controlling an RGB LED.\ This example utilizes object oriented programming techniques to control an RGB LED. -Example ![chapter09_08a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08a) Controlling an RGB LED of Type WS2812.\ +Example [chapter09_08a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08a) Controlling an RGB LED of Type WS2812.\ This example controls an RGB LED using programming techniques similar to those used in the previous example. There are, however, several differences such as the refactored, modernized LED-class hierarchy. The main difference, however, is that a _digitally_-controlled industry-standard RGB LED of type WS2812 is used. In addition, the color transitions at and around $255~\text{bits}$-RGB are slowed down providing emphasized, longer-lasting RGB hues near these points. -Example ![chapter09_08b](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08b) Controlling an RGB LED of Type WS2812 (variation 32-bit microcontroller).\ +Example [chapter09_08b](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter09_08b) Controlling an RGB LED of Type WS2812 (variation 32-bit microcontroller).\ Example chapter09_08b utilizes essentially the same techniques to control its ws2812 RGB LED as were used in Example Chapter09_08a. In variation 09_08b, however, the open-platform [STM32F100 Value Line Discovery Kit](https://www.st.com/en/evaluation-tools/stm32vldiscovery.html) is used. - -Example ![chapter10_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_08) External SPI RAM and Computing $10,001$ Digits of Pi.\ +Example [chapter10_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_08) External SPI RAM and Computing $10,001$ Digits of Pi.\ This advanced example extends available RAM via SPI SRAM chips and uses a Pi Spigot algorithm to compute $10,001$ digits of the mathematical constant $\pi$ showing fascinating memory management iterators, containers and algorithms along the way. @@ -95,39 +93,39 @@ This example depicts algorithmic complexity running in a real-world system and highlights the real-time numeric expression of the detailed description of algorithmic complexity in the corresponding book section. -Example ![chapter10_08a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_08a) Parallel SRAM and Computing $100,001$ Digits of Pi.\ +Example [chapter10_08a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_08a) Parallel SRAM and Computing $100,001$ Digits of Pi.\ This advanced example extends RAM even further with a $2~\text{MByte}$ parallel SRAM brick. This extended memory is used for storage in Pi Spigot calculations of the mathematical constant $\pi$ up to $100,001$ decimal digits. -Example ![chapter10_09](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_09) $100,001$ Digits of Pi on Raspberry Pi(R).\ +Example [chapter10_09](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter10_09) $100,001$ Digits of Pi on Raspberry Pi(R).\ This advanced example ports the Pi Spigot calculation of $100,001$ decimal digits of $\pi$ to the powerful ARM(R)-based Raspberry Pi(R) single-board computer. -Example ![chapter11_07](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter11_07) Preemptive Multitasking.\ +Example [chapter11_07](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter11_07) Preemptive Multitasking.\ This example makes straightforward use of preemptive multitasking scheduling with a blinky-style application that features a main task and a low-priority background task. -Example ![chapter11_07a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter11_07a) Preemptive Multitasking and an Advanced, Memory-Intensive Mathematical Calculation.\ +Example [chapter11_07a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter11_07a) Preemptive Multitasking and an Advanced, Memory-Intensive Mathematical Calculation.\ In this example, advanced use of preemptive multitasking scheduling is used to combine a blinky-style application with a highly detailed and exciting calculation of the mathematical constant $\pi$ to high precision in the background task. -Example ![chapter12_04](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter12_04) Benchmarking Floating-Point Calculations.\ +Example [chapter12_04](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter12_04) Benchmarking Floating-Point Calculations.\ This example performs a variety of floating-point calculations of selected special functions of pure and applied mathematics. -Example ![chapter12_04a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter12_04a) Benchmarking Floating-Point Calculations (variation 32-bit microcontroller).\ +Example [chapter12_04a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter12_04a) Benchmarking Floating-Point Calculations (variation 32-bit microcontroller).\ The same special functions and arguments are used as in Example Chapter12_04. In variation 12_04a, however, the open-platform [STM32F100 Value Line Discovery Kit](https://www.st.com/en/evaluation-tools/stm32vldiscovery.html) is used directly out-of-the-box. -Example ![chapter16_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter16_08) Generating and displaying 128-bit Random Prime Numbers.\ +Example [chapter16_08](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter16_08) Generating and displaying 128-bit Random Prime Numbers.\ This advanced example uses an extended integer class to create 128-bit unsigned prime integers with primality testing performed via Miller-Rabin. This example also provides fascinating, intuitive, visual insight into the prime number theory of pure mathematics. -Example ![chapter17_03](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter17_03) Traditional C Language Code in a Modern C++ Project.\ +Example [chapter17_03](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter17_03) Traditional C Language Code in a Modern C++ Project.\ This example depicts some methods that potentially allow the successful use of traditional C-language code within a modern C++ project. -Example ![chapter17_03a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter17_03a) Traditional C-Language in Modern C++, Using Time Slices.\ +Example [chapter17_03a](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter17_03a) Traditional C-Language in Modern C++, Using Time Slices.\ This example is almost identical with example chapter17_03. In fact, it performs the same CRC calculations and uses essentially the same code technical methods for accessing traditional C-language code within a modern C++ project. @@ -136,19 +134,19 @@ over multitasking using time slices. ## Further Information on the Examples -For further informatin on the examples, see the readme notes +For further information on the examples, see the readme notes in each individual example directory. ## Try it at _godbolt_

- - + + godbolt

Use this [short link](https://godbolt.org/z/fxWzb6h6f) to [godbolt](https://godbolt.org) in order to further explore -Example ![chapter02_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_02) +Example [chapter02_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_02) (the LED program). In the link, the main source file of the example is compiled with a modern `avr-gcc` compiler and the compiler-generated assembly listing can also be investigated.