I've been programming C for many years, but that was in past life, can't believe how rusty I got. Time to add oil to the rust :-)
So.. my device is connected to a 3rd party peripheral. I am evaluating two competing brands of the peripheral, unclear which one will make it to Production.
So, naturally, I am trying to encapsulate all the code specific to that brand, and decouple it from the rest of my code.
What's the cleanest way to do that?
In Java, I'd create a class or interface Peripheral and have two concrete peripherals subclassed from it.
In C++, I'd probably do the same, using virtual functions, which is probably not very efficient, but that's OK in my case. They'd be singletons. I'd then probably put them in .dlls if they are big enough.
What do I do in embedded C? In Energia?
The best I can think of is #ifdef macro, but I don't like it :-(
I'd have to encapsulate my entire code (not just headers) for Peripheral1 and Peripheral2 into giant #ifdef's, to save memory.
Is that the best practice?