To add a piece of code from a .c file to a .h file

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top