Re: Hardware Abstraction
- From: Vladimir Vassilevsky <antispam_bogus@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 15:18:14 GMT
Michael N. Moran wrote:
I am looking for a concept for abstracting of a hardware. It is desired that the concept should be convenient, clear, consistent, logical and pretty universal.
I find that when abstracting hardware, like any other abstraction,
it is useful and important to separate the construction/initialization
and mode selection from the abstract interface that is used during
most of the application life cycle.
To use a GPIO pin as an example, a bit-banging application can
generally perform two operations:
setHIGH()
setLOW()
Actually, there should be a 3-level interface:
Application: set_something_meaningful(BOOL param)
Hardware abstraction: set_port_pin(BOOL param)
Low level: PORTA.1 = param
The initialization, that selects mutiplexed function routing,
direction, open-drain operation and other configuration belongs
to another interface that is most likely not abstract.
Initialization/deinitialization is a big potential source of errors. The initalizations should be consistent with the application interface.
IMHO, operations which are not available on a particular
piece of hardware should not appear in the abstraction
supported by that hardware.
Yes. And the attempt to use the unsupported function should be detected at the compile time.
For example, a having the
ability to read the value of a GPIO at the pin or as
a read-back of the register associated with the pin.
Some GPIO implementations have one or the other and
some have both. Thus there are two possible operations:
bool readAtPin()
bool readPinRegister()
A GPIO implementation that supports only one of these
should not have the other available in its interface.
The result is there is no error condition if an application
calls an "unsupported" operation.
All of this falls under the "Interface Segregation Principle"
The result is several very narrow abstract interfaces rather
than a single abstract interface. Though this suggests MI,
composition is generally better suited for the implementation.
:) We are growing out of this concept at this moment.
Initially it was copy/paste code reuse, then it came to a set of functions and macros, and finally it was realized that a new paradigm is required.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
.
- References:
- Hardware Abstraction
- From: Vladimir Vassilevsky
- Re: Hardware Abstraction
- From: Michael N. Moran
- Hardware Abstraction
- Prev by Date: Re: Hardware Abstraction
- Next by Date: embedded design within LISAtek
- Previous by thread: Re: Hardware Abstraction
- Next by thread: Re: interested in wombats
- Index(es):
Relevant Pages
|