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

Discussion in 'C Programming' started by vishnusreenath, Jul 5, 2012.

  1. vishnusreenath

    vishnusreenath

    Joined:
    Jul 5, 2012
    Messages:
    1
    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...
     
    vishnusreenath, Jul 5, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Przemo
    Replies:
    5
    Views:
    543
    Teemu Keiski
    Jul 18, 2004
  2. =?Utf-8?B?RGlmZmlkZW50?=

    Question on optimizing a piece of code

    =?Utf-8?B?RGlmZmlkZW50?=, Jun 9, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    407
    Patrice
    Jun 9, 2005
  3. Hristo Stevic

    highlight the piece of code executed

    Hristo Stevic, Dec 7, 2003, in forum: Java
    Replies:
    0
    Views:
    350
    Hristo Stevic
    Dec 7, 2003
  4. Moritz Beller
    Replies:
    19
    Views:
    698
    Pete Becker
    Jun 4, 2004
  5. Patrick Plattes

    Download a file piece by piece

    Patrick Plattes, Nov 30, 2006, in forum: Ruby
    Replies:
    2
    Views:
    233
    Patrick Plattes
    Nov 30, 2006
Loading...

Share This Page