Handling a Family of Hardware Devices with a Single Implementation
summary
Claims a single template implementation handles six Arduino Mega timers — two 8-bit and four 16-bit — by extracting differences into timer_traits with type aliases for clock select and count_t, using volatile register members and enum types for safety. Tools include templates, traits, enumeration types, operator overloading patterns and a class-specific operator new that maps the object to the hardware address. The result is one maintainable class template that compiles separately for each timer, preserves type safety, and keeps performance on par with handwritten register access.
AI-written summary · about
chapters (11)
- 0:00Start
- 0:52Device Registers
- 5:19Six Programmable Timers on the Arduino Mega 2560
- 10:16Layout for Timer Zero
- 11:46Interrupt Mask Register
- 15:44Timer Zero Class
- 16:54Clock Source Enumeration
- 19:56Timer Traits
- 25:12Counting Speed
- 27:51Timer 80 Class Template
- 30:40Function Implementations
related talks
54mModern Template Techniques
59mTemplate Metaprogramming: Type Traits (part 2 of 2)
01h 00mTemplate Metaprogramming: Type Traits (part 1 of 2)
01h 00mModern C++: C++ Patterns to Make Embedded Programming More Productive
07mC++ Hardware Register Access
55mC++ on small micro controllers
01h 38mMake Simple Tasks Simple!
49mA new look at TMP
