|
Adapter
Hardware-independent interfaces for MCU adapters.
|
This repository provides interfaces, not hardware implementations. A device-specific adapter implements the interfaces and exposes its peripherals through an MCU object.
Add this repository's include/ directory to your compiler include paths. For an ADC:
The Converter interface requires four types: input, reference, prescaler and result. A real adapter obtains the first three from its device's hardware definitions.
Implement each declared method using the device's hardware definitions and registers. The compiler requires every pure virtual method to be implemented before ADC can be instantiated; override checks the method signatures.
The device-specific adapter can own its peripheral objects in an MCU class:
The adapter defines MCU; this repository does not prescribe its peripheral list.
No factory or make() is needed:
The Input, Reference and Prescaler names above refer to types supplied by the device-specific adapter.
examples/getting-started.cpp is a complete C++11 example. It uses a simulated ADC to demonstrate the contract and MCU construction; it does not configure real hardware.
From the repository root, compile it with a C++11 compiler:
Expected output:
In a real device-specific adapter, replace the simulated behaviour with register operations and native hardware types. The adapter repository itself stays hardware-independent.