|
Adapter
Hardware-independent interfaces for MCU adapters.
|
Include the relevant module header, derive the adapter class from the interface, and implement each pure virtual method.
For example, an ADC adapter supplies its native types as template arguments:
The declarations above must be implemented by the adapter.
After the class definition, require it to be concrete:
The check verifies that all inherited pure virtual methods have implementations with matching signatures.
A concrete adapter can be an automatic or static object:
A peripheral library can receive it by reference to the interface:
No heap allocation is required. Calls through the interface use virtual dispatch.
Each device-specific adapter can define an MCU class with accessors for its supported peripherals:
The application creates the MCU directly:
No extra MCU creation interface is necessary. The MCU and its peripheral lifetimes belong to the device-specific adapter. See MCU composition.