I am working on a C code base written specifically for one type of embedded processor. I wrote a generic “object oriented” psuedo code for things like LEDs, GPIO lines, and ADCs (using structures, etc.). I also wrote a large amount of code that uses these “objects” in agnostic / hardware mode.
Now we are moving a different type of processor to the mix, and I would like to keep the current code structure, so I can still use higher-level libraries. However, I need to provide various implementations of the lower level code (LEDs, GPIO, ADC).
I know that #includes in .C files usually looks down, but in this case, is this appropriate? For instance:
#ifdef TARGET_AVR
#include "led_avr.c"
#elseifdef TARGET_PIC
#include "led_pic.c"
#else
#error "Unspecified Target"
#endif
If this is inappropriate, what is better for implementation?
Thank!
source
share