I have a C Project in MPLAB IDE where I want the main.c file to be able to be used for more than one HWs I have. The main difference is that the pins of the PIC are differently connected.
The idea is to create different .h and .c files for each HW my main file supports and only include this one that corresponds to the HW for which I want to build.
Something like this:
#if defined( HW_1 )
#include "hw1.h"
#elif defined( HW_2 )
#include "hw2.h"
#endif
This extra files (hw1.c and hw2.c) include mainly definitions of the functions of the pins, such as:
#define GPI_PG_3V3 RD2
and related functions.
But the problem is that different HWs may have same functionalities, but on different pins. That means the same #define variables may exist for different HWs.
Although I include the respective .h file according to my HW, in the structure of the MPLAB I have the same project and this means I have to include all .h files at the same time. But this leads to the problem that the compiler thinks there are various definitions of the same variable, e.g.:
Error [237] S:\PIC_Code\ACCEED_4420\Source\acceed1480.c; 23. function "_initGpio" redefined
Does anyone have a good idea on how to solve this? One idea that came to me is to have different projects for all the different HWs I have. Is that the only solution? In such a case it would be difficult how to structure the project directories.