- Joined
- Jul 5, 2012
- Messages
- 1
- Reaction score
- 0
hi all,
I want to create a user defined header file which will contain a few piece of code from my main.c file.
like for the code below,
void Vol_VohTest(void)
{
#if defined (__18F4620)
AddrPtr = CONFIG1H;
ConfigWord = ReadFlash (AddrPtr);
if ( (ConfigWord & 0x0F) != 0x01)//select XT
{
ConfigWord = ConfigWord & 0xF0;
ConfigWord = ConfigWord | 0x01;
ConfigWrite(AddrPtr,ConfigWord);
}
#endif
#if defined (__18F46J11)
AddrPtr = CONFIG2L;
ConfigWord = ReadFlash (AddrPtr);
if ( (ConfigWord & 0x07) != 0x04)//select HS
{
ConfigWord = ConfigWord & 0xF8;
ConfigWord = ConfigWord | 0x04;
ConfigWrite(AddrPtr,ConfigWord);
}
#endif
ConfigTrisRegOutput();
switch (TestType & 0x7F)
{
case VOL_TEST:
ConfigIOPortLow();
break;
case VOH_TEST:
ConfigIOPortHigh();
break;
}
OSCCON = 0xFC ;
}
///////////////////////////////////////////////////////////////////////
i want to create a new user defined header file to contain the if defined cases. The principle i wanted use was using macros... plz help...
I want to create a user defined header file which will contain a few piece of code from my main.c file.
like for the code below,
void Vol_VohTest(void)
{
#if defined (__18F4620)
AddrPtr = CONFIG1H;
ConfigWord = ReadFlash (AddrPtr);
if ( (ConfigWord & 0x0F) != 0x01)//select XT
{
ConfigWord = ConfigWord & 0xF0;
ConfigWord = ConfigWord | 0x01;
ConfigWrite(AddrPtr,ConfigWord);
}
#endif
#if defined (__18F46J11)
AddrPtr = CONFIG2L;
ConfigWord = ReadFlash (AddrPtr);
if ( (ConfigWord & 0x07) != 0x04)//select HS
{
ConfigWord = ConfigWord & 0xF8;
ConfigWord = ConfigWord | 0x04;
ConfigWrite(AddrPtr,ConfigWord);
}
#endif
ConfigTrisRegOutput();
switch (TestType & 0x7F)
{
case VOL_TEST:
ConfigIOPortLow();
break;
case VOH_TEST:
ConfigIOPortHigh();
break;
}
OSCCON = 0xFC ;
}
///////////////////////////////////////////////////////////////////////
i want to create a new user defined header file to contain the if defined cases. The principle i wanted use was using macros... plz help...