|
Adapter
Hardware-independent interfaces for MCU adapters.
|
Each contract is an abstract class with a public virtual destructor and pure virtual operations.
An adapter derives from the relevant interface and implements every required operation. Use override on every implementation.
If a required operation is missing or its signature does not match, the adapter class remains abstract or the compiler reports an override error.
Place a compile-time check after the adapter class definition:
This makes an incomplete adapter fail at the point where the adapter is defined.
Each device-specific adapter may define an MCU class that exposes its supported peripherals. Applications construct it directly:
MCU construction is standard C++ object construction, not an interface contract. The MCU class is responsible for exposing and managing its concrete peripheral adapters.
The compiler can verify inheritance and method signatures. It cannot determine whether a method correctly configures a register or performs the intended hardware operation.
The adapter developer is responsible for the implementation's functional correctness and must follow the documented behaviour of each operation.
Template parameters preserve native types supplied by the adapter, including input selections, timer modes, counter values, channel identifiers and timeout selections.
Common enums are introduced only where the meaning is consistent across devices.
A base interface contains only operations expected to be available for that resource.
Features that may not exist on every device are represented by separate interfaces. An adapter implements those interfaces only when the corresponding hardware capability exists.
Examples include ADC trigger selection, GPIO pull configuration, timer input capture, PWM polarity control, clock prescaler control and peripheral clock gating.