Example:
struct Led1_Mega128_BoardA
{
_inline_ Light(bool Onoff) { DDRblah=1; PORTblah=blah; }
};
struct Led2_Mega128_BoardA
{
_inline_ Light(bool Onoff) { DDRblah=1; PORTblah=blah; }
};
template class hal
struct Somesuch : public hal
{
using hal::Light;
void DoSomething() { Light(1); }
};
main()
{
Somesuch<Led1_Mega128_BoardA> thing1;
Somesuch<Led2_Mega128_BoardA> thing2;
thing1.DoSomething();
thing2.DoSomething();
....
Another nice aspect is if you put the hal in one file and the behavior in another file, all the processor-specific includes are in a single file, which can really un-yuck your hierarchy sometimes. Also it let's you conceal hardware details (such as inverted drive for leds) into a programmer-centric behavior ( i.e. 1=on always, regardless if led connected to Gnd or Vcc), which can make things nicer for teams with non-hw-savvy programmers on them.
Steve
--
Steve Franks, KE7BTE
Staff Engineer
La Palma Devices, LLC
http://www.lapalmadevices.com
(520) 312-0089
_______________________________________________ AVR-chat mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-chat
