正常
LED Blinking: The Evolution from C to C++
One LED, a complete path of modern C++ refactoring — from HAL register operations to compile-time optimization with templates and
constexpr.
Motivation
- Part 6: Starting with the First LED — Why we use modern C++ for STM32
Hardware Fundamentals
- Part 7: What Exactly is GPIO — The history and principles of General-Purpose I/O
- Part 8: Push-Pull, Open-Drain, and PC13 — The hardware secrets behind lighting an LED
HAL Operations
- Part 9: HAL Clock Enable — Without a clock, a peripheral is just a sleeping piece of silicon
- Part 10: HAL_GPIO_Init — The ritual of telling the chip the pin configuration
- Part 11: HAL_GPIO_WritePin and TogglePin — Making the pins move
The C Macro Era
- Part 12: LED Driver in the C Macro Era — It works, but it isn't elegant
C++ Refactoring Evolution
- Part 13: First Refactor — enum class — Replacing macros, the start of type safety
- Part 14: Second Refactor — Templates — Compile-time binding of ports and pins
- Part 15: Third Refactor — if constexpr — Making clock enable selection automatic at compile time
- Part 16: Fourth Refactor — LED Templates — From generic GPIO to specific abstractions
- Part 17: Finishing with C++23 Features — Attributes, linkage, and the final proof of zero-overhead abstraction
Summary
- Part 18: Common Pitfalls and Practical Exercises — Doing more with the LED